Reinstalling Grub EFI on Ubuntu

Recently, whilst migrating some Hyper-V VMs to ESXi, I ran in to issues booting the VMs after migration. On boot, the EFI partition wasn’t found and couldn’t be booted. Thankfully, it’s a rather simple procedure to reinstall Grub EFI.

  1. Power on the VM and allow it to get stuck on the boot screen searching for an EFI partition.
  2. Grab the rEFInd Boot Manager ISO and attach it to the VM.
  3. Hit Control + Alt+ Insert to reboot the VM without removing the ISO. The VM should now boot in to rEFInd which will search for and locate your existing Ubuntu install. It’s normally the default/first, so hit Enter to boot.
  4. Log in to your Ubuntu installation as normal.
  5. Reinstall the grub-efi package using  sudo apt-get install --reinstall grub-efi .
  6. Install the grub bootloader on to your disk using sudo grub-install /dev/sda . Don’t forget to adjust  /dev/sda to an alternative disk if  /dev/sda isn’t your boot disk.
  7. Generate a new grub configuration using  sudo update-grub .
  8. Shutdown the VM and disconnect the rEFInd ISO. Turn the VM back on and now ESXi will find a bootable EFI partition and Ubuntu will boot as normal.

This process was adapted from Debian’s Grub EFI Reinstall instructions. If you run in to issues, there are a few other things on there to try. I’ve also found that some EFI installations don’t like being moved between computers due to path changes, and have used the above process to get a working EFI boot again.

You may also like...

Leave a Reply

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