There might be many reasons for your GRUB rescue mode to show up. Such as you accidentally deleted the Linux partition in multi-boot operating system environment or you messed up the grub configuration file, even worse you accidentally deleted it. If any of these things happen, you are presented with a rescue mode. Now grub rescue is a great way to get back into your system without the help of any external installation media just by typing in few commands.
GRUB rescue mode
GRUB rescue mode is a manual way to get into the system when you are put out of the system. Now the first step is to locate the partition with your Linux or whatever operating system you want to restore as your primary boot partition such as Windows partition. So issue ls command to list out all the available partitions. The ls command here is bit different than the Linux ls command which will list all the files and directory available. ls Command here will list all the available partition that grub can locate.
Now I have two partition system here. So it’s showing up the two partitions (You might see more). As shown above (hd0, msdos2) and (hd0, msdos1), one of these partition might have a working operating system which you need to boot from. Type in the following command
grub rescue> ls (hd0,msdos1)
grub rescue> ls (hd0,msdos1)
As shown above, here I get the errors for both the partition “Filesystem is unknown”. That means none of these partitions are bootable. On the other hand if you get output something like “File system is ext3 or ext4.” then this is the partition you are looking for. But that’s not the case with us.
Now issue the set command on grub rescue shell. set command prints out the currently used boot settings.
grub rescue> set
The set command review current boot settings and also used to set variables such as colors, prefix, root.
Output shown in the picture above reveals that there’s another partition (hd0, msdos5) that grub is set to boot from which contains the root file system along with all the grub files. Now we need to execute the following commands one by one to set the new boot parameters to get back to the normal grub boot loader screen.
grub rescue> set boot=(hd0,msdos5)
grub rescue> set prefix=(hd0,msdos5)/boot/grub
grub rescue> insmod normal
grub rescue> normal
Voila! Now we are in the grub boot menu.
Also check How to change GRUB boot order
A few of the more important commands of grub rescue mode:
|boot||Initiate the boot sequence, also F10 or CTRL-x|
|cat||Display the contents of readable files; cat (hd0,1)/boot/grub/grub.cfg|
|configfile||Load a GRUB 2 configuration file such as grub.cfg; configfile (hd0,5)/boot/grub/grub.cfg|
|initrd||Loads the initrd.img, necessary for booting; initrd (hd0,5)/initrd.img|
|insmod||Loads a module; insmod (hd0,5)/boot/grub/normal.mod, or insmod normal|
|linux||Loads the kernel; insmod /vmlinuz root=(hd0,5) ro|
|loop||Mount a file as a device; loopback loop (hd0,2)/iso/my.iso|
|ls||Lists the contents of a partition/folder; ls, ls /boot/grub, ls (hd0,5)/, ls (hd0,5)/boot|
|lsmod||List loaded modules|
|normal||Activate the normal module, if loaded|
|search||Search for a device. Type help search for the available options.|
|set||Review current settings, or set XXX to set a variable such as colors, prefix, root|
|vbeinfo||Display GRUB 2 available resolutions|