Adventures in EFI boot

I have a server that didn’t boot on it’s own, requiring manual intervention each startup. This is not optimal for a server-type machine (though the motherboard was never intended for that purpose. This machine had originally booted via Windows, and the Bios on the motherboard would not let me set an MBR entry above an EFI entry via conventional means.

First problem I encountered – I couldn’t set EFI settings while booted in classic (MBR) Mode. This was resolvable through pretty simple means, I booted into an installer/recovery linux image. This was enough for me to be able to use efibootmgr to set up boot order priority, and move the entry it had created for the classic MBR into that position.

That was enough for me to resolve my basic issue, but I wanted to do one better – I wanted to boot via EFI on my existing Ubuntu install. Grub supports EFI and it wasn’t that hard to get installed, but there’s some gotchas. My first attempt was thus:

grub-install --target=x86_64-efi --efi-directory=/boot/efi --debug

grub-install will install to the default subdirectory /boot/grub, with the EFI directory specified separately. The EFI System Partition is a FAT32 formatted disk; That’s all that’s required.

Next, I had to create the boot entry (Grub will generally do this for you, but because I was doing my grub install from my MBR disk:

efibootmgr -c -L "ted" -l '\efi\ubuntu\grubx64.efi' -d /dev/sda -p 2

This didn’t quite work. Eventually I gave up and reinstalled from scratch. 🙂

I’ve had more fun EFI adventures – I had a motherboard that wouldn’t respect a Grub EFI image unless there was a “Windows” image around, so I had to install with grub-install --removable which creates a BOOT.EFI file, otherwise the same.

Last but not least of my recent EFI problems, I managed to partially reinstall grub – My grub modules directory was updated, but grub itself was an old version, and the system was in a crash loop because of grub.cfg loading modules. Reinstalling grub was enough to fix it.