This post is a short one, a note intended to my future self, and maybe others who would need to do the same.
Context
Since a few weeks, I own an HP Microserver Gen8, which I bought to replace my trusty Microserver G7 N54L.
The Gen8 provides 4 disk trays, and also a 5th internal SATA port. This port is originally intended for the internal DVD drive, but I have no use for it and instead plugged an SSD in place, in order to host the operating system.
One of the quirks of this Gen8, is that when you set the SATA controller for the 4 main disks to AHCI mode (instead of one of the fake-RAID modes, which I don’t want since I will be using ZFS), you cannot boot anymore from the 5th SATA port.
But since this server provides an internal USB port, which is always bootable, one could theorically use it as a gateway to boot anything else, even not directly bootable by the BIOS.
So, I used an old 2GB USB drive that was laying in the drawer and did this.
How
From whatever Linux with grub available:
- plug and identify your USB drive (
/dev/sdb
here) - create a single vfat partition on the USB drive (
/dev/sdb1
here), with boot flag - format it as vfat
- mount it
- create a
/boot
directory in it - install grub on the MBR, specifying the
./boot
directory as the boot directory - add your custom
grub.cfg
containing a minimal chainloading entry
> mkfs.vfat -n grub2 /dev/sdb1
> mount /dev/sdb1 /mnt
> mkdir /mnt/boot
> grub-install --force --no-floppy --boot-directory=/mnt/boot /dev/sdb
> vim /mnt/boot/grub.cfg
> unmount /mnt
Here is the grub.cfg
I used:
set timeout=5
set default=0
menuentry "chainload" {
insmod part_msdos
insmod chain
set root=(hd3)
chainloader +1
}
There is a single menu entry that is automatically booted after 5s (during which you can drop to an interactive grub session if needed).
Speaking of this, if you need to identify your disk ((hd3)
for me), you may do that and then use ls
in the grub shell to see your available options.
Finally, you can install your OS on the target drive, and make sure to install a bootloader on it (not on the USB drive), as if it was directly bootable.
Conclusion
Another possibility is telling grub to use the grub.cfg
of the target OS, but I prefer my way: your USB grub is completely independent, and you can even use it to boot a completely different OS if needed (such as Windows or FreeBSD), as a dumb chainloader should do.
Once done, you can forget it, grub updates in the targeted OS won’t affect our chainloader, which will always hand over to the desired drive, no matter what.