Friday, December 09, 2005

Linux tips: Guide of recovering GRUB after reinstalling Windows

Assuming that you dual-boot between windows & linux on the same pc. After re-installing windows, the GRUB bootloader will be replaced with ntbootloader & your linux os will not be accessible though you know it is still there.

Here is how you restore it. Before resinstalling windows, do

vi /etc/grub.conf

For my case, my linux partitions looks like this:

title Coyote's Custom Kernel (2.6.14.2)
root (hd0,6)
kernel /bzImage-2.6.14.2 ro root=/dev/VolGroup00/LogVol00 rhgb quiet enforcing=0

root (hd0,6) means, my linux os lies in hd0(first harddisk) & partition 6.

After finished installing windows, your grub bootloader will be overwritten. To recover do the followings:

Boot up with the first CD of your linux OS, for my case, it's Fedora Core 4's CD 1. At boot: type

linux rescue

to go into rescue mode.

When at the sh# prompt, do

chroot /mnt/sysimage

to gain root priviledge. Then

do

grub

to enter into grub. Type

root (hd0,6)

setup (hd0)

The first command, root (hd0,6), sets my linux root to (hd0,6), that is 1st harddisk & partition 6. The second command, setup (hd0), instruct grub to rewrite the MBR.

Upon completion, the output reads 'Running "install /grub/stage1 (hd0) (hd0)1+15.../grub/grub.conf"... succeeded'

Type 'exit' twice. Once to exit grub & second time to exit rescue mode & reboot the pc.

There, my FC4 recovered. Now, I can reinstall my windows as many times as I like, without ever loosing my linux os.

0 Comments:

Post a Comment

<< Home