Grub Rescue: Repairing GRUB When Linux Won’t Boot

PowerADM.com / Linux / Grub Rescue: Repairing GRUB When Linux Won’t Boot

Most often, you will see the Grub Rescue console on dual boot computers with Linux first and then Windows installed on the computer.

GRUB (GRand Unified Bootloader) – it is a universal bootloader that is installed with the Linux operating system. Most Linux systems currently use GRUB2.

During the installation, Windows overwrites the Linux bootloader, and when booting, instead of the menu with OS boot options, an error appears:

Error: unknown filesystem
Entering rescue mode

or

Error: no such partition

And the Grub rescue console opens.

Most often, these errors appear if the GRUB cannot find the grub folder, or if the file system of the drive or partition is corrupted.

The grub bootloader console supports a number of basic commands. You can list them by typing:

help

grub rescue commands

List the available partitions on the disk:

ls

check partitions with grub

In our example, there is one disk hd0 with a partition msdos1.

Check if there are grub bootloader files on this partition:

ls (hd0,msdos1)/boot/grub/

Check that there is a grub.cfg file in the specified directory. If you have more partitions and disks, check them all.

locate grub.cfg file

Create a prefix for the bootloader folder:

set prefix=(hd0, msdos1)/boot/grub

Make the partition the primary one:

set root=(hd0, msdos1)/boot/grub

Load additional modules and start your Linux:

insmod ext2
insmod normal
normal

After booting Linux, you need to reinstall the bootloader:

sudo grub-install /dev/sda
Enter your boot partition instead of sda.

Update grub2 bootloader config in grub.cfg file:

sudo update-grub

Grub should automatically detect installed operating systems and add them to the boot menu.

If you are unable to restore the bootloader using the above method, you can fix the grub using a USB stick with a Live Linux image.

I booted my computer from an Ubuntu Live image. Open a terminal and run the command:

sudo su -

List disks and partitions:

fdisk -l

Find the partition with Linux installed (sda1 in my case). Mount this partition to the /mnt directory:

mount /dev/sda1 /mnt

Make sure there is a /boot/ directory under this partition:

ls -l /mnt/boot/

If there is no boot directory, mount it separately:

mount /dev/sdaX /mnt/boot

Mount the following partitions from the Live image:

mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

Log in to your local system on disk using chroot:

chroot /mnt

Now you can rewrite the bootloader configuration on disk:

grub-install /dev/sda
update-grub

Unmount partitions and restart your computer.

umount –R /mnt
reboot

Your grub is now working properly and should show the OS boot selection menu.

Leave a Reply

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