Home Terminal Tuts How to repair the GRUB bootloader using a Ubuntu Live USB drive

How to repair the GRUB bootloader using a Ubuntu Live USB drive

by Hend Adel
fix grub issues ubuntu live usb drive

Ubuntu Live CD or a USB drive comes in handy at times when something goes wrong. You can do things like recovering data, check for hard disk errors, or even restore the Grub bootloader.

It’s easier to mess up the Grub when you have changed the configuration of your computer. For instance, Grub can become inaccessible after you installed Windows in a dual boot configuration with a Linux distro because Windows Boot Manager takes over the bootloader and it doesn’t recognize Linux. If you have an Ubuntu Live CD or USB drive lying around, you can use it to reset bootloader so that Grub can retake the boot screen.

If you haven’t created an Ubuntu Live USB drive yet, check out our guide “Creating Ubuntu Live USB drive” and come back and follow the steps:

Resetting Grub Bootloader using a Ubuntu Live USB drive

This is a command-line way of restoring the grub. If “Terminal” is not your cup of tea, I suggest you check the graphical user interface way by using Grub Repair.

Step 1. Insert your Ubuntu Live USB or CD, then power on your machine.

Step 2. From the Install window, choose the “Try Ubuntu” option to open an Ubuntu live session.

Try Ubuntu

Try Ubuntu

Step 3. Open a new terminal window from the left panel or simply you can use the next shortcut from your keyboard CTRL+ALT+T.

Step 4. First, we need to know which partition is Ubuntu installed. You can know where Ubuntu is installed by using the “fdisk” or the “blkid” command.

Using the “fdisk” command:

fdisk -l

After executing the previous command, you will get an output like the below screenshot. As you can see Ubuntu is installed on the “/dev/sda1” partition.

Determine the Partition on Which Ubuntu is Installed Using fdisk

Determine the Partition on Which Ubuntu is Installed Using fdisk

Also, you can check where Ubuntu is installed using the “blkid”. The “blkid” command can provide you with more information about the partitions especially if they are labeled.

sudo blkid

After executing the previous command, it will list all partitions. Just search for the partition with type “ext4”. As you can see in our case Ubuntu is installed on the “/dev/sda1” partition.

Determine the Partition on Which Ubuntu is Installed Using blkid

Determine the Partition on Which Ubuntu is Installed Using blkid

Step 5. Next, we need to mount the partition where Ubuntu is installed to the “/mnt” mount point.

sudo mount /dev/sda1 /mnt
Mount The Partition with Ubuntu Installed On It

Mount The Partition with Ubuntu Installed On It

As shown in the above screenshot the “/dev/sda1” is mounted successfully.

Step 6. Now we will use the “grub-install” command to restore all the missing files into the grub folder.

sudo grub-install --boot-directory=/mnt/boot /dev/sda
Restore Missing Grub Files Using the Grub Install Command

Restore Missing Grub Files Using the Grub Install Command

Finally, you can now reboot your Ubuntu and the Grub boot menu should now appear.

Congratulations you have just restored the Ubuntu Grub boot menu.

You may also like

18 comments

Vijay Anand June 7, 2020 - 1:15 AM

I have installed Peach OSI: The Patriot on a 64 GB USB 3.0 pendrive and have customized many things according to my choices and also have many data on it. I used EaseUS Partition tool in Windows 7 and cloned full pendrive with .ext4 partition onto a microSD card, but it failed to boot. I tried Boot-Repair tool with net connection, then also booting was not successful. I tried to run Live CD of Peach OSI and tried to install grub from command line, but it showed some error like failed to get canonical path of ‘/cow’ I am really surprised to know there is only either Boot Repair or command line option to repair a non-booting Linux OS!!!

Reply
Sid June 9, 2022 - 9:42 AM

Hey, did you find any solution yet? I have the same problem 🙁

Reply
Aditya Anand November 12, 2022 - 8:43 AM

Use –force in end

Reply
arul July 25, 2020 - 1:59 PM

Thanks. Stuck with Ubuntu 20.04 dual. Plain and simple…

Reply
Mellow September 12, 2020 - 12:17 AM

Wow…. Thank you so much…. I’ve been stuck on this for days… You guys are the best

Reply
Mellow September 12, 2020 - 12:20 AM

But I hope it’s a permanent solution???

Reply
cat January 15, 2021 - 3:04 AM

Yes it is, unless you want to install Windows again. In which case you would have to repeat all this

Reply
Anto September 19, 2020 - 2:54 PM

Thanksssssssssssssssssssssssss!!!!!!!!!!!! I was really not expecting to find a solution.
Back again in Ubuntu and Windows!

Reply
Jordan December 15, 2020 - 3:15 PM

Spilt water on my laptop leading to a invalid partition and boot error but this seems to have worked thanks.

Reply
Allan January 27, 2021 - 1:37 AM

thank you””

Reply
DaveyOgravey June 7, 2021 - 7:10 PM

What are my options since this didn’t work for me? Thanks!

Reply
viz June 24, 2023 - 11:29 AM

Nice

Reply
simonsomeone July 3, 2021 - 2:49 PM

thankyou very much mate

Reply
andi September 26, 2022 - 6:21 PM

Thank you very very much!!! i am really thankful

Reply
tom July 15, 2023 - 5:43 PM

Doesn’t work for me. I always get error: cannot find EFI directory after sudo grub-install –boot-directory=/mnt/boot /dev/sda

Reply
Kiran Kumar July 15, 2023 - 8:43 PM

If you cannot find the EFI directory, it could be because your system is not booting in UEFI mode but rather in Legacy mode. This article should help. https://www.fosslinux.com/121832/fix-a-deep-dive-into-efi-directory-errors-after-grub-install.htm

Reply
John Kozak November 24, 2023 - 3:40 AM

$ sudo mkdir /media/EFI
$ sudo mount /dev/YOUR-EFI-PARTITION /media/EFI
$ sudo grub-install –boot-directory=/mnt/boot –efi-directory=/media/EFI/ /dev/TERGET_DEVICE

Reply
DUNCAN BAYLISS November 27, 2023 - 8:48 AM

Hi John Kozac
Is that a typo?
TERGET_ or TARGET_

Reply

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.