Monday, April 26, 2010

How To Restore GRUB



GNU GRUB (short for GNU GRand Unified Bootloader) is a boot loader package from the GNU Project. GRUB (shortened form of GNU GRUB) is the reference implementation of the Multiboot Specification, which enables a user to have multiple operating systems on their computer, and choose which one to run when the computer starts.

You have windows XP and linux on the same hard disk and you choose GRUB as boot loader.At boot time you see a menu to choose windows or linux.
But one day you reinstall Windows XP and it rewrites your MBR and the menu has gone, now you only can boot windows.

What to do:
Put the redhat boot disk you created on the installation on the floppy drive, boot the system and run grub command

Remember that for grub (hd0,1) means hda (primary controller master), second partition.

Now we need to tell grub where are the grub files:

If you know where they are, type something like:
root (hd0,1)

else if you have no idea, type:
find /boot/grub/stage1
and then the root command with the correct parameters:

setup (hd0)
to install it on hd0, that is MBR of the first HD.

type quit and reboot.
The menu will appear again.
If you want to make some changes to the boot menu, you must edit the file: /boot/grub/menu.lst

A sample menu.lst file is this:

default=0
timeout=5
splashimage=(hd0,1)/boot/grub/splash.xpm.gz

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

No comments: