Grub Rescue Mode — All About Solving The Error
If you only used Windows OS all your life, it’s unlikely you would have ever come across the dreaded situation of your screen going blank into the grub rescue mode and this article is not for you but if you are Linux user, you might know the pain of this situation.
This article will guide you through the process of getting your system booted up properly again from the grub rescue mode.
What is GRUB?
In simple terms, GRUB is the default bootloader for many of the Linux distributions.
Now GRUB comes under the GNU project and actually means “Grand Unified Bootloader”. GRUB has a lot of functionality features ( which we won’t be covering in this article ) but it gets cumbersome when we are trying to boot into a Linux system and due to some reasons, we land in “Grub rescue” mode.
It’s hard for someone not aware of GRUB to tackle this situation ( But its not that complex at all ). Before we get into how to come back to your OS, we need to learn some basic things.
What is Bootloader?
A boot loader also called a boot manager, is a small program that places your operating system (OS) into memory.
Most of the systems comes preinstalled with a bootloader for windows or MAC but if you intend to use a Linux distribution then a special bootloader must be installed ( yes you guessed it right… its GRUB ).
Anytime our system boots into OS, It’s the bootloader which is responsible for loading your Operating system and hence when there are some issues with the bootloader, We are unable to load our OS.
GRUB Installation
One of the reasons for you entering into the grub rescue mode can be the improper installation of GRUB package.
GRUB automatically becomes the default loader after it is installed.
The root shell prompt is opened and the command
/sbin/grub-install
is run after the GRUB package is installed. The in the command is the location where the GRUB stage 1 boot loader should be installed.
The booting process after this is another topic and out of the scope of this blog.
Why your system booted into GRUB rescue mode?
This is one of the most common questions people usually have. The answer is pretty simple once you know about what GRUB actually is.
You entered GRUB rescue because there were some issues ( like corrupt or missing files ) due to which GRUB ( Bootloader of Linux distributions ) was unable to boot into your OS.
Now in this situation GRUB does not know where to find your OS ( although it still has the capability to boot into the OS once GRUB knows where exactly to find the OS ).
In this case, GRUB gives its user a command-line interface and expects the user ( you ) to guide it to the OS. ( This is not exactly what happens but it is the easiest way to understand the situation ).
so here comes the part you were waiting for. I assume at this moment ( when you are stuck in GRUB rescue mode ) your screen might look something like this.
Now you have to search for your OS using this command-line interface and there are few commands which can help you to do that easily.
It’s not that hard to get out of this situation, just follow the following steps and you will be good to go -:
Step-1=> Type “ls” command to get the list of partitions available in your disk ( one of it is supposed to have your boot files ). In most cases, you will not know beforehand in which of those partitions the file is but that is totally fine.
Step-2=> Now you have to check for each and every partition. Now you have to look inside each partition. Type “ ls (hd0,msdos5) ” (Replace (hd0,msdos5) with whichever partition you are checking for). If it gives a message “no file system found”, Move to forward and check other partitions but if it gives a message like “ext4: file system”, Move to step 3 with this partition.
Step-3=> Now you know which partition contains the file we are looking for. Type the following commands in order to complete the process.
set boot=(hd0,msdos6)
set prefix=(hd0,msdos6)/boot/grub
insmod normal
normal
In all these commands replace (hd0,msdos6) with the partition you got in step-2.
Now after the normal command, your system shall automatically boot into the required OS but your work is not done yet. If you left at this point, you will again enter the grub rescue mode once you reboot.
To avoid that type the following commands in the Linux terminal
sudo update-grub
sudo grub-install /dev/sda
This shall solve the issue completely as you will now have proper GRUB configuration files in your system.
Some extra knowledge about GRUB 2
Here is the list of some other commands that you can use in the GRUB 2 rescue shell.
1) boot (Initiate the boot, also F10 or CTRL-x)
2) cat (view the contents of config or txt files; cat (hd0,1)/boot/grub/grub.cfg)
3) configfile (Load a GRUB 2 configuration file such as grub.cfg; configfile (hd0,5)/boot/grub/grub.cfg.)
4) initrd (Loads the initrd.img, necessary for booting; initrd (hd0,5)/initrd.img.)
5) insmod (Loads a module; insmod (hd0,5)/boot/grub/normal.mod, or insmod normal.)
6) linux (Loads the kernel; insmod /vmlinuz root=(hd0,5) ro.)
7) loop (Mount a file as a device; loopback loop (hd0,2)/iso/my.iso.)
8) ls (lists the contents of a partition/folder; ls, ls /boot/grub, ls (hd0,5)/, ls (hd0,5)/boot.)
9) lsmod (List loaded modules.)
10) normal (Activate the normal module, if loaded.)
11) search (Search for a device. Type help search for the available options.)
12) set (Review current settings, or set XXX to set a variable such as colors, prefix, root.)
13) vbeinfo (Display GRUB 2 available resolutions.)
▲