Most often, you will see the Grub Rescue console on dual boot computers with Linux first and then Windows installed on the computer.
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
Error: no such partition
And the Grub rescue console opens.
The grub bootloader console supports a number of basic commands. You can list them by typing:
List the available partitions on the disk:
In our example, there is one disk
hd0 with a partition
Check if there are grub bootloader files on this partition:
Check that there is a grub.cfg file in the specified directory. If you have more partitions and disks, check them all.
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
Update grub2 bootloader config in grub.cfg file:
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:
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:
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.