GRUB repair plus installation to floppy

Repairing the GRUB installation is a very usual task for many Linux users. There are many excellent articles on this topic on the net. This small article intends to be a summary of them and to serve as a small reference for those who do not care about the details. Some links to external relative articles exist in the end of this document.

Entering the Rescue Mode

The Rescue Mode, in simple terms, is an “isolated” environment, which exists in the system RAM, from where you can perform some system maintenance or repair tasks. To enter such an environment you can use any of the so called “Live CDs” or use your distribution’s installation media if they provide such an option.

For Fedora users there are a separate Fedora Rescue ISO image, which can be burned to a cd, and the first of the installation media, which can be used to enter the Rescue Mode. Since you will be booting from the cd, you will have to adjust your boot sequence in your motherboard’s BIOS. Having accomplished this, insert the proper cd into the drive and reboot.

If you use the Fedora Rescue CD, just hit the [Enter] key. If you use the installation media, type:

> linux rescue

and hit the [Enter] key.

Answer the questions about your language, your keyboard and if you would like to bring up the network interfaces. You will not be needing the latter, so you may answer negatively.

The last question you have to answer before you enter the Rescue Mode is if you would like to mount your Fedora system partition or not, or if you would like to mount it as read-only. I would suggest that you let this wizard mount it for you.

Re-installing GRUB on the MBR

If you have let the wizard mount your system, it can be found at the following directory:
/mnt/sysimage/

Issue the following commands:

# chroot /mnt/sysimage/
# grub-install /dev/hdX

Substitute hdX with the proper hard drive, on whose MBR you would like GRUB installed. Usually this is hda.

GRUB is installed.

The first command is optional, but, if you don’t issue it, you would have to provide the full path to grub-install. For example:

# /mnt/sysimage/sbin/grub-install /dev/hdX

Creating a GRUB diskette

If you have a reason to have GRUB installed on a diskette and boot your system from there, here is the info on how to do. You can issue the following commands either from the Rescue Mode or while you use the system. If you are in the Rescue Mode, issue the following command to make your life easier:

# chroot /mnt/sysimage/

Insert a diskette into the floppy drive and type:

# dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
# dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1

These copy the necessary GRUB images to the diskette.

Finally install GRUB to the diskette:

# grub-install /dev/fd0

That’s it. You can adjust your boot sequence in the BIOS, so that your system boots from the diskette.

Note that this diskette is only valid for the specific kernel and partition configuration. If you modify any of these you will have to repeat the last command.

Further Reading

Some exceptional articles on this topic:

  1. The GRUB Documentation.
  2. Grub From the Ground Up by Steve Litt
  3. How to install GRUB on the MBR by Gonzalo

GRUB repair plus installation to floppy by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.