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 .

Jerry Warrington · January 5, 2019 at 8:29 AM

Did not work for me after EFI reformat. Please be kind enough to tell me how to update the UUID?
I started out with a new HP Pavillion AIO PC w. Win 10, I have spent 3 days and found nothing that works to create a boot. I finally erased Win 10 and reformatted the HDD and still no success.

Jerry Warrington · January 5, 2019 at 8:32 PM

If the UUID of the efi partition is suppose to match the UUID in /etc/fstab, which one do you change? How does one make those changes, e.g., what are the terminal entries?

    shyam jos · January 5, 2019 at 8:43 PM

    Make changes to /etc/fstab file based on output of command `sudo blkid /dev/YOUR-EFI-PARTITION`

Koresh · February 22, 2019 at 3:29 PM

grub-install: error: unknown filesystem.

What was done:
* Efi partition was formatted to ext4 (experiment), then to fat32
* after that fdisk -l shows “/dev/sda1 2048 1050623 1048576 512M EFI System”
* Update /etc/fstab with new UUID of efi partition.

but still got
grub-install: error: unknown filesystem.

Mallory · September 8, 2019 at 2:17 PM

Works great until it makes computer freeze :/ I get the same freeze when it is installing grub2 from the classic ubuntu installer.

Any idea ?

nyx · December 6, 2019 at 12:10 AM

Dude, thank you! I had been awake for 20 some hours pushing for a deadline, was trying to format an external drive… Was so tired i deleted my boot partition instead. Seriously, I would be dead in the water if it was for people like you who take the time to give clear instruction and helpful solutions. Much love man.

    shyam jos · December 6, 2019 at 12:26 AM

    I’m glad I was able to help 🙂

Juan · February 5, 2020 at 3:03 AM

Thanks!! This work for me

Robert · February 21, 2020 at 8:31 AM

Thank you. Worked great!

Sebastian · March 30, 2020 at 11:36 PM

I have an issue by running sudo chroot /mnt:

chroot: failed to run command ‘bin/bash’: no such file or directory

If you can help me, i will thank you too much

Brian · December 27, 2020 at 9:00 PM

Thanks so much for posting this! Fixed my system in 5 minutes.

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.