Tuesday, 15 April 2014

HP Microserver Gen8 - Boot from 5th SATA ODD Port using USB + GRUB


I discovered that my HP Microserver Gen8 does not boot from the 5th SATA port (the Optical Bay) when the controller is in AHCI mode. The server does boot from this drive if the controller is set to SATA Legacy mode (by changing the controller boot order for #2 to be first in sequence, ODD bays 1-4 are on controller #1, ODD port is on controller #2). I believe it can also boot from this port using the B120i RAID but regardless, I wanted to use AHCI mode.

This solution is not ideal, but it's a decent workaround. I wanted to boot Linux (Debian 7.4 with OpenMediaVault installed). I use a permanently connected USB with grub installed to boot the operating system installed on a 500gb 2.5" drive I installed in the top drive bay.

Remove all drives in the 4 main bays
Install Linux, then from inside the new Linux installation:
 1. Zero the USB
   dd if=/dev/zero of=/dev/sdd

2. Create a 128 mb partion at the start of the USB
   fdisk /dev/sdd
   ... use 'n' to create a partition
   mkfs -t ext2 /dev/sdd1
   mkdir /tmp/myusb
   mount /dev/sdd1 /tmp/myusb
   mkdir /tmp/myusb/boot

3. Install grub to the USB, making sure the boot directory is on the USB drive:
   grub-install --boot-directory=/tmp/myusb/boot /dev/sdd

3. Update the grub config, outputting to the USB.
   update-grub --output=/tmp/myusb/boot/grub/grub.cfg

4. Reboot the system and it should now boot grub from the usb (make sure the BIOS is configured for USB boot). The drives can now be reinstalled in to the main drive bays.

  
 
  

21 comments:

  1. Command in step 3 is wrong, it must be:

    update-grub --output=/tmp/myusb/boot/grub/grub.cfg

    because grub.cfg must be located in /boot/grub

    ReplyDelete
    Replies
    1. you are correct, thanks for pointing that out I have updated the post.

      Delete
    2. Thank you for the post. After following your guide, I found the USB stick is not able to boot the system, then I found that the "active" flag is not set, so I used fdisk tool to execute the "a" command on the partition, and the USB stick is able to boot my Ubuntu at SATA bay 5 successfully.

      Delete
    3. I can confirm that the described solution also works using an internal microSD card instead of a USB pen drive. Setting the boot flag for the SD device (command 'a' in fdisk) is also mandatory, otherwise it won't boot (in my case a Debian 8). Thank you so much guys, you saved my day!

      Delete
    4. Update: Don't know why, but I got an error in step 3 (grub-install) when I installed Debian directly from USB without booting into a live session first. The other way around (starting the installation out of a live session) produced no error in step 3. Reason unclear ...

      The images I tried to install on an SSD in bay 5:
      - debian-8.1.0-amd64-CD-1.iso (grub-install to microSD got error message)
      - debian-live-8.1.0-amd64-mate-desktop.iso (grub-install to microSD worked without errors)

      Sadly, installing from a live session automatically installs a desktop environment (in this case Mate) so you need to remove a lot of stuff if you want a clean server setup with SSH access only.

      Delete
  2. Hast du Grub am ende der Debian-Install in den MBR installiert?

    Es funktioniert für mich einfahc nicht -.- Debian bootet nicht

    ReplyDelete
    Replies
    1. Ja, am Ende der Debian-Installation installierst du Grub ganz normal auch in den MBR des Devices am 5ten SATA-Port. Wenn in Bay 1-4 keine Platten sind, sollte das System dann schon bootbar sein, ohne den oben beschriebenen Fix. Erst wenn mindestens eine Platte in den Bays ist, brauchst du den USB- oder SD-Boot-Workaround.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi Jerrod,

    I have no access to a linux system to set this up, however looking to do exactly as you have, other than use the internal MicroSD card slot.
    Just wondered if you had an image of the card you would be willing to share?

    I'll be honest and say i wouldn't mind running as you have using the internal USB, however the microSD is there, so may as well use it and leave the USB port free if i can. Either way would do :D

    Cheers
    Paul

    ReplyDelete
    Replies
    1. Sorry - Image of the boot USB rather... sorry!

      Delete
  5. Hi Jerrod,

    bei mir ist USB Boot eingestellt im BIOS vom internen USB, die oben genannte Schritte habe ich durchgeführt, aber es wird kein bootbares "System" auf dem USB gefunden. Hast Du da eine Idee? Ich möchte auch den AHCI verwenden, kommt also Legacy Mode überhaupt nicht in Frage :)

    VG,
    Peter

    ReplyDelete
    Replies
    1. Du musst USB bootbar machen:
      fdisk -l
      fdisk /dev/sda
      a

      Delete
  6. NICE job!

    you save me a few days...

    ReplyDelete
  7. Thanks to this I successfully ran a ubuntu 14 for two years and over 300 days uptime!

    One question however: When I upgrade the kernel it does not get picked up by grub, how do I fix this?

    ReplyDelete
  8. i followd u`r tutorial and at updating of the grub got following massage:

    "Changing display/entry units to cylinders (DEPREACTED)"

    Is that ok or not? What now?

    ReplyDelete
  9. Dear Mr. Jarrodl
    U`r manuel worked also for me installing OMV3+HP Gen8
    But i must adress a few critic`s 4 u`r deed!
    I wonder for who did u made this help in this form?!

    For novices/beginners definitely NOT!

    However i would like to contribute for next visitors(beginners) of u`r page...

    But firs type "LSBLK"-small leters & without,to found a name of u`r devise a side of ssd or hdd.Follow the guide of Darrel changeing the name of his "SDD" for your`s(in my case was SDB).

    1.First line is not needed if SD/USB stick is unformated/unlocated.

    2.fdisk /dev/sdd
    ... use 'n' to create a partition

    -In my case was SD card with 8Gb. Simply typeing "n" does not help very much. This link will help beginners to avoid error massages later in u`r tutorial.

    http://www.tldp.org/HOWTO/Flash-Memory-HOWTO/ext2.html

    Be alert! After command "p" should see in what "type/format"(can not recollect what was the case) is u`r SD/USB stick.In my case was : Dos.

    If is that case with others users, u must add a "boot flag" and than "w"-enter.

    If is u`r device in GPT,there is no need for.

    Continue further with a line:

    mkfs -t ext2 /dev/sdd1

    Till the and.

    Hopefully this wil help for others and u`r not takeing my insults personally?!

    Reggards,

    L.P.P.

    ReplyDelete
  10. Actualy there is no need for formating device on Darrels page if u used a command from link above. Also i did not go further with "8.3. Tests -- ext2". There is no need for.

    So,go further with command : "mkdir /tmp/myusb"

    ReplyDelete
  11. I tried three USB flash discs, but it's ignored during booting process. Can't find out why. Do you know what HP MS Gen8 needs for working USB boot? I get no errors during your tutorial and can't find out what's the problem.

    ReplyDelete
  12. @ Standa

    I`m using two different media,one usb old kingston stick(2or4GB) and Verbatim micro sd hc class4(8gb). There is also an HP usb stick but you must pay some $€$ OMV 64bit is way easyer to install from 32bit. And of course maby u`r proble lay`s in BIOS options?!!!!!

    ReplyDelete
  13. 1. Identify the name of your USB drive using the command line command:
    lsblk
    For the purposes of these instructions we will work on sdb

    2. If the drive is not already blank, zero it using:
    dd if=/dev/zero of=/dev/sdb

    3. Create a 128 mb partion at the start of the USB
    sudo fdisk /dev/sdb
    Press 'n' to create a partition at the prompt

    select the defaults and enter 128M as the size

    Press 'a' and select partition 1 to make it bootable

    Press 'p' and ensure there is an asterisk in the boot column

    press 'w' to write the changes to the disk

    4. sudo mkfs -t ext2 /dev/sdb1
    5. mkdir /tmp/myusb
    6. sudo mount /dev/sdb1 /tmp/myusb
    7. sudo mkdir /tmp/myusb/boot

    8. Install grub to the USB:
    grub-install --boot-directory=/tmp/myusb/boot /dev/sdb
    9. Update the grub config:
    update-grub --output=/tmp/myusb/boot/grub/grub.cfg
    9b. (optional) you may wish to

    sudo gedit /tmp/myusb/boot/grub/grub.cfg

    and edit the 30 second delay down to something more to your preference. Save and exit gedit.
    10. Reboot the system and ensure the USB Key entry is shown at the top of the boot order in the BIOS.

    The drives can now be reinstalled in to the main drive bays. The boot procedure should run through normally and try to boot from c:.

    ReplyDelete
    Replies
    1. I was struggling on not being able to boot F10 or ODD SSD after adding more disks, then I followed every steps of your post and it is perfectly working in minutes.
      A great thank you sir :)

      Delete