How to reinstall grub2 efi bootloader on ubuntu

Published by shyam jos on

In this tutorial I will show you how to reinstall grub2 bootloader on a ubuntu system with efi partition.

Boot from a live usb/cd

Boot from the ubuntu live usb/cd and select the option “try ubuntu without installing”

Check if EFI is enabled in bios

Enter below command in terminal
[ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD"

If you see “EFI boot on HDD” Message then you are already running on efi mode or if you see “Legacy boot on HDD” message then your system is not running on efi mode, you must change the boot options to efi before proceeding to next step.

Note: First you have to find the partition name where ubuntu is installed, You can use “sudo fdisk -l” to list all hard disks and partitions in your computer. In my case /dev/sda is the name of my harddisk, /dev/sda2 is the partition where ubuntu is installed (root partition) and /dev/sda1 was the efi partition.

Mount and chroot into local filesystem

Note: You have to replace the sda with device name of your HDD, In most cases it is sda, assuming that you have only one hard disk installed.

Note: If you get any errors while trying to mount your efi partition (/dev/sda1), You may need to reformat your efi partition, Incase if it got corrupted or if you  accidently formatted it. Follow this tutorial to restore or reformat your efi partition.

Open terminal and enter below command

sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /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/sda

Important : use blkid command to check UUID of your efi partition, check if it matches  the value in your /etc/fstab entry , otherwise ubuntu will not boot , You may need to update the UUID especially if you have formatted EFI partition . (Eg: sudo blkid /dev/sda1)

That’s it!  Now reboot to test the bootloader

Categories: Tutorials

shyam jos

My name is Shyam Jos, I am a passionate Linux system administrator from Kochi, India. I am a strong advocate of using Linux and Open-Source software.


kanak · February 8, 2018 at 7:45 PM

Thanks to help me in fixing the issue in minutes.

Rinus Loof-van Overmeeren · July 27, 2018 at 12:40 AM

This tutorial really helped me out! Thank you so much.

bahha · November 2, 2018 at 6:09 PM

This saved me from reinstalling everything from scratch
Thanks a lot .

How to create or restore efi partition in ubuntu · August 24, 2017 at 10:44 PM

[…] After restoring or formatting efi partition your system will not boot since bootloader needs to be reinstalled on the new efi partition, Follow this tutorial to reinstall grub efi bootloader in your ubuntu system. […]

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.