Grub Rescue command fixes startup problems

GRUB representative G Rand u Nitrification B ootloader. This is the first software program that runs when the computer starts. The bootloader is responsible for loading and booting the operating system kernel. GRUB is the default boot program for operating systems based on the Linux kernel.

In some cases, you must run both Linux and Windows on the same computer (laptop or PC), so GRUB may encounter some problems. For example, if you install Windows after Linux installation, Windows will start its own boot program on the MBR (Master Boot Record). Therefore, GRUB is no longer available and you cannot boot to the Linux OS.

This tutorial will introduce some solutions that cause GRUB to fail to start, and how to use the GRUB command to restore the Linux operating system from boot.

When is the grub rescue command used?

Today, most Linux systems use GRUB2 (grub version 2). GRUB2 replaces the GRUB bootloader.

If GRUB cannot find the grub folder or its contents are damaged, the GRUB prompt is as follows:

                      error: no such partition.
grub rescue > _



                      error: unknown filesystem.
grub rescue > _



                      grub > _


This error prevents you from starting the operating system. The following sections explain how to solve this problem.

Flathead Rescue Command

Each GRUB failure mode can be repaired via grub terminal or Live CD installer.

At the grub command prompt, enter’ls’ to view the disk drive and available partitions:

                      grub > ls
(hd0) (hd0,msdos2) (hd0,msdos1)
grub > _



hd0 :hard disk

msdos : Partition type

Usually, the operating system is started from the first partition of the hard disk. In this case, to verify that the bootable partition is “msdos1”, let’s run the following command:

                      grub > ls (hd0,msdos1)/


Next, let’s explore the grub2 directory by running the following command:

                      grub > ls (hd0,msdos1)/grub2



              fonts  grub.cfg  grub.cfg.1590068449.rpmsave  grubenv  i386-pc  locale


As you can see, grub in Linux has its own configuration file: “grub.cfg”.

If you cannot see this file, you can create it by running the following command:



To guide your system, we enter:

                      grub > set root=(hd0,msdos1)



                      linux (hd0,msdos1)/vmlinuz-3.10.0-1127.13.1.el7.x86_64 root=/dev/sda1


Running “Set Root Directory” will define the bootable partition. The default kernel is linux v3.10.

Now, we must define the path to the grub2 directory:

                      grub > set prefix=(hd0,msdos1)/grub2
grub > insmod normal



                      initrd (hd0,msdos1)/initramfs-3.10.0-1127.13.1.el7.x86_64.img


Again, here, you need to change the partition to the boot partition.

If you cannot start the system (probably due to a damaged file system or missing GRUB configuration file), you need to start from another medium. You can use some bootable emergency CDs or distribution live CDs (if available).

After booting into the system, if you are missing or misconfigured, you may need to create a GRUB configuration file. To create these configuration files, run:

                      $ update-grub

This command requires super user privileges. Therefore, run this command as the root user (and the following commands in this article).

The next step is to install GRUB on the MBR. This will solve the problem caused by Windows, that is, after installing Windows through Linux, Windows installs its bootloader on the MBR. Here, I assume that you have booted from Live or Rescue CD.

Now, before detailing GRUB installation on MBR, we need to mount the root partition of Linux.

                      $ sudo mount /dev/sda1 /mnt

Here, the root partition is assumed to be “/dev/sda1”. The partition is installed in the /mnt directory. You can choose your own mount point, and the root file system partition may be different.

Now, we are ready to install GRUB. Run the following command:

                      $ sudo grub-install --root-directory=/mnt/ /dev/sda

This will install GRUB on the master boot record. If you want to install it on a partition, replace the last parameter of the above command with the appropriate partition.

Rescue through guided repair

Another way to save grub on Ubuntu and almost Linux distributions is to use a boot repair tool. This is a graphical utility that can repair the Grub2 bootloader with just a few clicks.

You need to prepare Live USB/DVD installer and boot into live Linux environment. Then, let you connect the real-time operating system to the Internet and install the startup repair by running the following command:

                      $ sudo add-apt-repository -y ppa:yannubuntu/boot-repair
$ sudo apt-get update
$ sudo apt-get install -y boot-repair && boot-repair


The boot repair tool will start, you can select the “Recommended Repair” button, and then perform some subsequent steps to repair the boot loader.

in conclusion

In this tutorial, we learned how to use the grub rescue command to repair operating system startup errors. Thanks for reading, please leave your suggestions in the comment section below.

Related Posts