Friday, September 15, 2006

How to Restore GRUB

  1. Boot from CD and mount the system. We used the install disc because I never bothered to burn a rescue CD, har har. When you get to the splash screen, type "linux rescue" and hit return. It will ask you a couple things about your language and keyboard, and will offer to bring up the network interfaces -- I said no. Then it gave me the option to let it try to detect and mount the system read-writable, or read-only, or no auto-detect. I chose the first option and it worked.
  2. Fiddle with grub.conf, if necessary. Open /mnt/sysimage/boot/grub/grub.conf in an editor and check to make sure it looks okay. If you want to revert to a previous kernel option, you can add its parameters here, or they may already be in the list -- newest kernel info gets appended to the top. You can also change the default option (what gets highlighted in the grub menu) by changing the "default=0" line to something else; the first block is 0, second is 1, etc.

    If your grub.conf is missing or corrupted, you're kind of on your own. Here's a sample:


    title Red Hat Linux (2.4.18-14)
    root (hd0,1)
    kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdc=ide-scsi
    initrd /boot/initrd-2.4.18-14.img
    title Red Hat Linux (2.4.18-openmosix3)
    root (hd0,1)
    kernel /boot/vmlinuz-2.4.18-openmosix3 ro root=/dev/hda2 hdc=ide-scsi
    initrd /boot/initrd-2.4.18-openmosix3.img
    title WindowsME
    rootnoverify (hd0,0)
    chainloader +1
  3. Write to the MBR. Assuming grub.conf is intact, continue with the process. Type "grub" (return) to enter the grub shell.

    Tell grub where to find the requisite files. If you know where they are, enter something like:

    root (hd0,1)

    (hd0,1) means primary controller master, second partition. If you DON'T know where they are, type:

    find /boot/grub/stage1
    and then enter the root command with the correct parameters. Note: If you are using a separate /boot partition , as the official documentation says: "... if you have the partition /boot and you install GRUB images into the directory /boot/grub, GRUB recognizes that the images lies under the directory /grub but not /boot/grub.' Thus, if 'find /boot/grub/stage1' does not find the file, try 'find /grub/stage1'."

    Next, type:

    setup (hd0)
    This command will install grub on the MBR of the first drive.
  4. Test. Type quit and reboot. Everything should proceed normally.


1 comment:

sofia said...

Or how about this recipe:

Fold two hands together
And express a dash of sorrow
Marinate it overnight
And work on it tomorrow

Chop one grudge in tiny pieces
Add several cups of love
Dredge with a large sized smile
Mix with the ingredients above

Dissolve the hate within you
By doing a good deed
Cut in and help your friend
If he should be in need

Stir in laughter, love, and kindness
From the heart it has to come
Toss with genuine forgiveness
And give your neighbor some

The amount of people served
Will depend on you
It can serve the whole wide world
If you really want it to