Recovering Grub when you make a Mistake - Fedora on a second hard drive in the system

It is possible to recover grub, when you have not set up your system correctly, or need to repair the grub installation. This may happen when the following occurs;

1. You fail to set grub to boot from the correct hard drive during the installation

2. Change the logical order of your hard drives after the installation

3. Add, remove or modify partitions on the affected drive after the installation

The Fedora installation CD or DVD allows you to boot into "rescue mode" to make any necessary repairs on your Fedora system.

NOTE: This section assumes that you did not change anything relative to the logical order of the hard drives since you installed Fedora. It also assumes that you have only IDE drives in your system and no sata drive that is your actual boot drive. If you have sata drives on your system, or a combination of sata and IDE drives, read the section "Notes on sata drives" below.

Booting from the installation disk and choose Linux rescue at the installation menu.

Try getting to the root Fedora filesystem, after using the rescue disk, by typing in the console chroot /mnt/sysimage

This gets you to the root of the Fedora filesystem.

Then try typing in the console grub-install /dev/hda

Note: space between grub-install and /dev/hda

DO NOT type hda1, you want the MBR of the hda drive, not hda1, which is the first partition on the drive.

If you have a sata drive on your system and this is your boot drive, see the section on sata drives below.

Reboot the system and see if you get grub, with the option to boot both Fedora and Windows.

The other issue is that grub defaults to only a few seconds before booting the first listed OS. Depending on what you chose to boot first (hopefully not Windows) during the installation of Grub, that OS will boot quickly.

Let us know what happens, then we can change the timeout of the booting via Grub.

Essentially what you want to do is get into the /boot/grub/menu.lst file and change the line that starts with timeout from 10 to 50.

Now, this is where things get cloudy. You boot into rescue mode.

Did you make sure that the sysimage was loaded? in Fedora Core 5, during the rescue boot, Fedora tries to see the installation and mount the sysimage. You get a message asking if you want to do this, or skip the detection. If you choose the former option and there is something wrong, the image is not mounted fully and you should have received a message that not all the files were loaded.

If you choose the skip this step, then you need to mount the sysimage manually.

What if I changed the logical order of the drives in the bios, either physically or in the bios and the above solution does not work?

Then you can apply the alternate command  grub-install --recheck /dev/hda after getting into the chroot of Fedora. This command tells grub to recheck the drives and their order and reference the boot files correctly. The correct syntax is grub-install <space> <two hash marks>recheck <space>/dev/hda

The Grub Bug:

In some cases, the above solutions will work and in others they will not. There seems to be a bug in how grub works in some systems.

Assuming that you are chooted into the Fedora installation successfully, try the following commands at a root terminal window (bold text are the actual commands). This assumes that you did not change the order of the drives since you installed Fedora.

grub (hit the enter key & after each command below)
grub> root (hd1,0) (since fedora /boot is on /hdb or the second hard drive)
grub> setup (hd0) (the MBR of the first hard drive)
grub> quit

What these commands do;
Typing Grub enters the grub editing mode, referenced at grub>
root (hd1,0) tells grub that the root files on the system are on hdb, or the primary slave drive.
setup (hd0) tells grub to install the bootloader on the primary master MBR
quit quits the grub edit mode

Remember, the logical order of you drives depends on how they are set in the bios and jumpered when you installed them. Grub sees them with the following naming convention;

hd0 = the primary master drive
hd1 = is the primary slave drive
hd2 = is the secondary master drive
hd3 = is the secondary slave drive The actual partitions are the second numerical code.

hd0,0 - the first hard drive on the system, first partition.

Notes on sata Drives:

If you have sata drives on your system, or a combination of sata and pata (IDE) drives, then the naming scheme is a little different.  These drives are not jumpered like IDE (pata) drives, but seen by the bios on the physical channel they are on, or in the order where they are connected on the motherboard connector. They will be seen by Linux, as sda, not hda (ie; the first sata drive on the system vs. the first IDE drive). So, all commands to change grub with the grub-install --recheck command are relative to their naming scheme. For example, grub-install --recheck/dev/sda would be the proper syntax. For more information on sata installations, See the next page on sata drives.