Skip to main content

Restoring GRUB for Linux

· 2 min read

Frequent Linux users who dual boot their machines with Linux and Windows will inevitably find their GRUB boot loader corrupted at some point in time. This post will help you restore your GRUB boot loader.

Step 1: Boot Using Rescue Mode

Insert the installation disc into the machine and boot up from the disc. At the boot screen where there is a list of selections, choose Rescue mode. The system will take some time to boot and then you will be brought to the login prompt. (Note that in the rescue mode, there is no GUI component - only console.) Type in root. There is no need to enter a password. You will then see a 'rescue' prompt.

Step 2: Start GRUB

From the rescue prompt, type 'grub' to start the GRUB program. The rescue prompt will then turn into the grub> prompt. If you know where the GRUB files are placed in your Linux installation, simply proceed to Step 3.

If you don't know where the GRUB files are, use the following command:

find /boot/grub/stage1

This command will return the location of the GRUB files. The location is in the form like (hd0,2). Use this returned value for the next step.

Step 3: Set up the GRUB Location

Set up the GRUB location by running the command 'root' with the location of the GRUB file (which you obtain from Step 2). E.g.

root (hd0,2)

Step 4: Install the Boot Loader

The next step is to install the boot loader. Typically you want to install the boot loader into the master boot record (MBR) of the disk (which the machine boots into). The boot loader is installed with the following command:

setup (hd0)

where hd0 is the primary master hard disk. Note that this command will install the boot loader into the MBR of the disk, overriding any bootloader that was there. If you are using this command, you probably know what I'm talking about.

Step 5: Reboot

The installation of the boot loader is the last step to take. After the installation, type 'quit' to exit the GRUB command prompt, then type 'reboot' to restart the machine. Your boot loader should reappear.