1
0
jcktrue.dk/content/post/grub-trampoline/index.md
Jens True 049a568c60
All checks were successful
continuous-integration/drone/push Build is passing
Cleanup code highlighting
2021-05-17 16:35:11 +02:00

2.3 KiB

title subtitle summary date highlight
GRUB Trampoline Install GRUB on a spare drive Using a spare drive to act as a trampoline during the boot process. 2021-05-03T15:28:14+02:00 true

Background

Due to a BIOS bug in my HP MicroServer I have been forced to applied a workaround.

The MicroServer Gen8 has a bug that prevents the use of the 5th SATA port as the primary boot device. It will automatically attempt to boot from SATA port 1 if a drive is inserted, then port 2 and so forth. By removing all the fixed drives it is possible to make the system boot from port 5.

It is however possible to boot from the internal USB port or the internal MicroSD slot by default. So to solve this issue we are going to install GRUB onto a spare MicroSD card or a USB stick. The size or quality of the drive should not matter since it is only needed for GRUB to jump to the drive present on the 5th SATA port.

Steps

Format the USB/SD Card

First we need to correctly format the new disk as a bootable FAT drive.

{{% callout warning %}} Be very cautious when formatting storage drives. Executing a command on the wrong drive could have disastrous consequences. {{% /callout %}}

Find the correct device identifier.

lsblk

Clear the drive by writing all zeros to the drive (for good measure)

sudo dd if=/dev/zero of=/dev/sdX

Format the disk

sudo fdisk /dev/sdX

Fdisk provides a shell where you can enter commands.

  • Set the type to "o" for MSDOS
  • Set the disk to be bootable "a"
  • Make a new primary partition "n" followed by "n" Accept the remaining as default.
  • Use "w" to commit the changes and exit the tool.

Now create a filesystem in the newly created partition.

sudo mkfs -t ext2 /dev/sdX1

Prepare for GRUB install

Create a mount point

mkdir /tmp/mysub

Mount the new partition

sudo mount /dev/sdX1 /tmp/myusb

Create a folder named "boot" on the drive

sudo mkdir /tmp/myusb/boot

Install GRUB

Install GRUB by running the grub-install script

sudo grub-install --boot-directory=/tmp/myusb/boot /dev/sdX

Update the GRUB configuration

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

Test

Finally unmount and reboot

sudo unmount /tmp/myusb
sudo reboot