Grub EFI Reinstall – Debian

Starting with Windows 8 most Desktop PC have EFI as firmware instead of the legacy BIOS. If your EFI based PC is not booting debian, here is an easy way to reinstall grub-efi, the bootloader used by debian on these PCs.

To reinstall grub, you need either a live CD/USB to access your current system , or you can use the rEFInd boot manager on a live CD/USB to boot your current system.

Using the rEFInd rescue media

At the author’s web page, you will find updated direct links to all sorts of packaging. To boot from a rescue media, select either the CD iso or the image for USB stick, most firmware offers the choice nowadays. If choosing the latter make sure to follow the instructions in the readme. It is recommended to read the author’s web pages to get a better understanding of what you are doing.

Boot your computer with the Refind media

Refind will parse your hard drive for installed kernels, and provide you a graphic menu to boot them. Choose your Linux Kernel and boot it.

Reinstalling grub-efi on your hard drive

Check that the computer booted in computer in EFI mode:

[ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD"
should return "EFI boot on HDD".

After starting a root shell ( if you boot from a live media, you should start a chroot shell instead, as explained in ) check that your EFI system partition (most probably /dev/sda1) is mounted on /boot/efi

mount /dev/sda1 /boot/efi

Reinstall the grub-efi package

apt-get install --reinstall grub-efi

Put the debian bootloader in /boot/efi and create an appropriate entry in the computer NVRAM

grub-install /dev/sda

Re create a grub config file based on your disk partitioning schema


You should check afterwards that: 1. the bootloader is existing in /boot/efi/EFI/debian/grubx64.efi and

file /boot/efi/EFI/debian/grubx64.efi

/boot/efi/EFI/debian/grubx64.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows

1. the nvram entry was properly created.

efibootmgr --verbose | grep debian

You can now reboot, and Grub should greet you.


If after this steps you’re not booting, the EFI of your PC might have some bugs.

Problem1: Weak EFI implementation only recognizes the fallback bootloader

The uefi firmware refuses to boot the debian/grubx64.efi bootloader, and so we have to hijack the uefi fallback boot loader. See for details.

Using debian installer in rescue mode, /dev/sda1 being the FAT32 ESP partition, /dev/sda2 the root partition

mkdir /target
mount /dev/sda2 /target
mount /dev/sda1 /target/boot/efi
for i in /sys /proc /dev; do mount --bind $i /target$i; done
chroot /target

cd /boot/efi/EFI
mkdir boot
cp debian/grubx64.efi boot/bootx64.efi
for i in /sys /proc /dev; do umount /target$i; done
umount /target/boot/efi
umount /target

Once booted into your normal Debian, tell grub to ensure the fallback boot loader up to date. To do that, run the following:

echo "grub-efi-amd64 grub2/force_efi_extra_removable boolean true" | sudo debconf-set-selections

Note: The above command will permanently hijack the fallback boot loader, which might be undesirable in dual-boot setups.

Problem2: EFI boot entries disappear after reboot

The uefi firmware did not create a proper boot entry in NVRAM. This has been seen in a Lenovo Thinkcenter M92Z. The symptom for this will be a missing HD path after the debian entry in the efibootmgr --verbose output.

BootCurrent: 0024
Timeout: 0 seconds
BootOrder: 0024,0022,0023,0016,0000,0001
Boot0000* debian        Vendor(99e275e7-75a0-4b37-a2e6-c5385e6c00cb,)
Boot0016* Generic Usb Device    Vendor(99e275e7-75a0-4b37-a2e6-c5385e6c00cb,)
Boot0022* UEFI: IPv4 Intel(R) 82579LM Gigabit Network Connection        ACPI(a0341d0,0)PCI(19,0)MAC(d43d7e6d8bfc,0)IPv4(<->,0, 0AMBO
Boot0023* UEFI: IPv6 Intel(R) 82579LM Gigabit Network Connection        ACPI(a0341d0,0)PCI(19,0)MAC(d43d7e6d8bfc,0)030d3c000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000AMBO
Boot0024* UEFI: Generic Flash Disk 8.00 ACPI(a0341d0,0)PCI(1d,0)USB(1,0)USB(1,0)HD(1,800,2a5f,02f23208-1aa9-4b6c-b6e1-8155390eb9db)AMBO

You can then try to install Refind as your bootloader in the hard drive, following the steps at this gist:

Source : GrubEFIReinstall – Debian Wiki