How can I reinstall GRUB to the EFI partition?

Solution 1:

Reinstall the GRUB boot loader to your Ubuntu installation in EFI mode this way ...

Boot from the Ubuntu installation medium and select 'Try Ubuntu without installing'.
(Boot your install medium in EFI mode, select the Ubuntu entry with UEFI in front.)

Once you are on the Live desktop, open a terminal and execute these commands :

sudo mount /dev/sdXY /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub  

Note : sdX = disk | sdXX = efi partition | sdXY = system partition

To identify the partitions use GParted, the tool is included in the installation medium.
After having run the commands GRUB will be installed in the separate EFI partition.

Solution 2:

this is the only way that worked for me: (System: sdb8, boot: sdb6, efi: sdb2)

sudo mount /dev/sdb8 /mnt 
sudo mount /dev/sdb6 /mnt/boot 
sudo mount /dev/sdb2 /mnt/boot/efi

sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys

sudo chroot /mnt

grub-install --target=x86_64-efi /dev/sdb

grub-install --recheck /dev/sdb

exit &&
sudo umount /mnt/sys &&
sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts &&
sudo umount /mnt/dev &&
sudo umount /mnt

Solution 3:

This is how I did it on a standard x86_amd64 EFI desktop, without chrooting, assuming you have a partition containing Ubuntu on your hard drive and possibly an EFI partition where GRUB should be installed.

# boot on a live Ubuntu, I used 18.04 but more recent should work

# if you have currently no EFI partition (maybe it was deleted,
# or you are migrating to a new drive):
# sudo gparted
# - create a FAT 32 partition of around 100 MB on the disk of your choice
# (in general the one that host the Ubuntu partition). If you plan to
# move or resize some paritions, anticipate that (for instance by
# creating the EFI partition at the end of the free space).
# - set the flag esp on this partition (the flag boot will also be selected)

# now assuming that the Ubuntu partition is `/dev/sda2` and the (possibly new) EFI partition is `/dev/sda1`
sudo apt install grub-efi
sudo mkdir /media/root && sudo mount /dev/sda2 /media/root
sudo mkdir /media/efi && sudo mount /dev/sda1 /media/efi
sudo grub-install --target=x86_64-efi /dev/sda --efi-directory=/media/efi --boot-directory=/media/root/boot

This should give:

Installing for x86_64-efi platform.

Installation finished. No error reported.

Then reboot and you should be done. You may have to tell your BIOS which drive to use, or which EFI partition to use, or which EFI binary to use.

If you created a new EFI partition, you may have to add it to /etc/fstab to have update-grub working correctly.

For more information : https://wiki.archlinux.org/index.php/Multiboot_USB_drive#Hybrid_UEFI_GPT_+_BIOS_GPT/MBR_boot

Solution 4:

Thanks to @cl-netbox for the instructions!

After I upgraded (Linux Mint 18.2 Sonya to 18.3 Sylvia) my system wouldn't boot so I followed the instructions above but still no success. I noticed however that my machine has /boot in a separate partition (possibly because I am using LVM) so my slightly modified process was:

sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXY /mnt/boot
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub 

Note : sdX = disk | sdXX = efi partition | sdXY = boot partition | sdXXX = system partition