The GNU GRand Unified Bootloader automatically enters the rescue shell when it fails to find the root device or the path to its configuration file. This problem usually happens when you change the partition scheme without updating GRUB or write over some of the bytes in the master boot record. Use the GRUB rescue shell to manually set the root device and the path to the configuration file, and when GRUB enters this fallback mode, you need to reinstall the bootloader.
GRUB Rescue offers a limited set of commands to help you configure a one-time normal boot and repair GRUB from your operating system. Just because GRUB doesn’t load properly doesn’t mean your operating system is unbootable; the Linux filesystem is usually still intact and in good condition. However, Linux may be unbootable if you performed an unsafe operation such as moving a bootable partition.
From the rescue shell, list the connected drives by entering at the prompt:
A drive’s number corresponds to the letter in its block ID. For example,
(hd0, msdos1) stands for
(hd1, msdos2) stands for
(hd2, gpt5) stands for
/dev/sdc5 and so on.
You can also see the values of the GRUB variables by entering the command:
set command to temporarily point GRUB to your root device and configuration file. After finding the device ID, enter the following commands to set the root and configuration path variables:
set root=(hd0, msdos2) set prefix=(hd0, msdos2)/boot/grub
Use the appropriate device ID in place of
(hd0, msdos2) in the example.
prefix variable points GRUB to the grub.cfg file, which is located in
/boot/grub on the primary partition. If your partition has moved or has a new name, pointing GRUB to the new location may still work.
After setting the necessary variables, you can manually open the GRUB menu and boot as normal. Enter the following commands to load the normal module and open the GRUB menu:
insmod normal normal
Select your primary operating system using the arrow keys from the GRUB menu and then press “Enter” to boot.
If the menu isn’t displayed and you are dropped into the GRUB shell, that means you don’t have a configuration file and you have to load the necessary files by hand. To boot Linux, GRUB needs the
initrd image locations as well as the root and configuration file paths. These files are located in the
/boot directory along with the
grub/ folder, but you must name them properly for GRUB to find them.
Substitute your device ID in the following command to list the file names:
ls (hd0, msdos2)/boot
Set the kernel and initrd variables using the following commands:
linux (hd0, msdos2)/boot/vmlinuz-linux root=/dev/sda2 ro initrd (hd0, msdos2)/boot/initrd.img
Substitute your device for
(hd0, msdos2) and the correct file names for
initrd.img in the example. Alternatively, you may be able to type part of the file name and press “Tab” to complete the file name.
After booting into Linux, open a terminal window and reinstall GRUB on the device MBR. The installation command varies between Linux distributions, but in Ubuntu, you can use the following command:
sudo grub-install /dev/sda
Substitute your device’s block ID for
/dev/sda in the example, and do not specify a partition number, such as