As usual my windows OS got infected with viruses and trogens.So i want to reinstall it to format C drive.I was knowing that if i reinstall windows then system's MBR will be overwritten without considering about any other operating systems working in the system.This is not good at all.So I've to do something to recover the boot loader - GRUB.
One post from official Ubuntu support pages insists that we have to use 'alternative installation CD' (ie., not the live CD but another one which can be downloaded) to recover GRUB which is not true!We can use live CD (for machines which have at least 512RAM, others may have to use alternative installation CD) for recovering GRUB.
I reinstalled Windows XP Pro so my GRUB disappeared, then i put my Ubuntu Live CD in tray and did boot from it.
Then I entered "Live Session" and opened terminal (Applications >> Accessories >> Terminal).
It will show Ubuntu@Ubuntu:~$ as current user.Then I executed following commands
sudo grub |
find /boot/grub/stage1 |
you will get something like (hd0,6)
root (hd?,?) |
replace (hd?,?) with what you got
setup (hd0) |
quit |
Thats all.....Then I restarted my computer..It should have worked normally.
BUT
I got an error message while I'm selecting Ubuntu 8.04, kernel 2.6.24-16-generic from GRUB list.The problem may be a mismatch between existing boot configuration and things I have entered previously.
If you also find the same then the solution is...
Boot from live CD, as a live session user open Terminal just like above.
execute first two codes
sudo grub |
find /boot/grub/stage1 |
you will get something like (hd?,?)
then
>> Find the partition on which you have previously installed Ubuntu
>> Mount it by clicking on it
>> Find the location of /boot/grub/menu.lst
It should be somwhere like /media/disk/boot/grub/menu.lst
open that file for editing
sudo gedit /media/disk/boot/grub/menu.lst |
Scroll to last part of menu.lst then you will find boot configuration like this
#######################################
title Ubuntu 8.04, kernel 2.6.24-16-generic
root (hd0,8)
kernel /boot/vmlinuz-2.6.24-16-generic root=UUID=c6a46b73-a759-451b-85c7-d6ff582d04f1 ro quiet splash
initrd /boot/initrd.img-2.6.24-16-generic
quiet
title Ubuntu 8.04, kernel 2.6.24-16-generic (recovery mode)
root (hd0,8)
kernel /boot/vmlinuz-2.6.24-16-generic root=UUID=c6a46b73-a759-451b-85c7-d6ff582d04f1 ro single
initrd /boot/initrd.img-2.6.24-16-generic
title Ubuntu 8.04, memtest86+
root (hd0,8)
kernel /boot/memtest86+.bin
quiet
################################
Compare the address (hd?,?) you got with the (hd?,?) of 2nd line.for me (hd0,8)
If it is different from what you got then change (hd?,?) to the value (hd?,?).Once you completed editing menu.lst, then close it and execute the remaining commands.
root (hd?,?) |
setup (hd0) |
quit |
Your GRUB will be OK now!
Note: Reverse will not work.That is you cannot change (hd?,?) to (hd?,?).
0 Responses to "Recovering GRUB after reinstalling Windows"
Post a Comment