Ubuntu – Does this answer work for UEFI computers

bootgrub-efigrub2uefi

One of my most popular answers is instructions on how to repair grub. Over time, others have contributed bug fixes to the answer. A recent comment, though, made me wonder if it works on newer UEFI hardware.

Gabor wrote:

I get a "cannot find EFI directory" at step 7 and cannot boot. Any ideas?

All my hardware is older, pre-UEFI hardware. So my question is this: Are my instructions, particularly step 7, applicable to UEFI hardware? If not, what changes need to be made?

Best Answer

If you have EFI, then there will be an EFI System Partition (ESP) on the disk. This partition has to be mounted on /boot/efi, so that GRUB can use it. The partition:

  • is formatted FAT32,
  • is usually small (100MB < size < 500MB)
  • will have the boot flag enabled
  • contains an EFI folder
  • could be labelled EFI by the OEM, but no guarantees

I don't have one on hand, but you can see examples of how such a partition will look:

So, the task here is, somewhere around steps 3 & 4:

  1. Find the ESP
  2. Mount it:

    sudo mount /dev/sdXY /mnt/boot/efi
    

Then you can proceed with your usual answer. I have done it myself. Consider it similar to mounting a /boot partition if you have one separate.

You can mount it anywhere you like. In that case, just specify the mount directory to GRUB while installing:

grub-install --efi-directory=/foo/bar /dev/sdX