Fixing a broken UEFI Grub boot loader

I recently installed Arch Linux on a new Dell Laptop with hybrid GPUs and UEFI. The firmware did not allow switching to legacy MBR boot mode, which I normally prefer because it is easier to install, so I had no choice in this case. To aggravate things, the newly created UEFI partition wasn’t recognised by the firmware and the computer didn’t boot. If you are in a similar situation, the following instructions might help.

I assume that you have created an UEFI partition of at least 300 MB using type “EFI SYSTEM” and GUID partition table on /dev/sdb1. Your actual device may differ, for example it could be /dev/sda1 or /dev/sda2. I also assume that you have mounted the the UEFI partition as follows:

# mkdir /boot/efi
# mount /dev/sdb1 /boot/efi

Furthermore, I assume that you have installed Grub successfully with:

# grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi
# grub-mkconfig -o /boot/grub/grub.cfg

Normally this should leave you with a bootable system. In my case, however, I had old “ghost” bootloader entries left which were invalidated by recreating the UEFI partition. I first had to manually remove these. For this purpose, I used efibootmgr. Invoking the command without parameters shows a list of boot loader entries. For example:

# efibootmgr
BootCurrent: 0007
Timeout: 0 seconds
BootOrder: 0002,0003,0004,0005,0006,0007
Boot0000* grub_arch
Boot0001* GRUB
Boot0002* Preinstalled
Boot0003* Diskette Drive
Boot0004* USB Storage Device
Boot0005* CD/DVD/CD-RW Drive
Boot0006* Onboard NIC
Boot0007* UEFI: SK hynix SC311 SATA 256GB, Partition 1

Let’s assume that 0002 is an invalid entry. You can delete it with:

# efibootmgr -b 2 -B

Not that 2 is written without preceding zeros. You can also change the boot order or activate and deactivate single boot loaders with the same command. If this should not work, it can also be done using the firmware user interface in most cases.

Before I got my system to boot from my SSD, I executed two more steps to help the computer locating the Grub bootloader. First, I copied the bootloader itself to an alternative location. Keep in mind that /boot/efi still refers to the mounted UEFI partition (/dev/sdb1 in my case).

# mkdir /boot/efi/EFI/BOOT
# cp /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI

Second, I created a boot startup script:

# vi /boot/efi/startup.nsh

Of course, you can use another editor such as nano if you prefer. The script contains only one line:

bcf boot add 1 fs0:\EFI\GRUB\grubx64.efi “Grub Bootloader”

After saving, unmounting, and rebooting the system, I was able to boot from the SSD.

Leave a Reply

Your email address will not be published. Required fields are marked *