Wednesday, April 13, 2011

Recovery of GRUB after re-installing Windows

To get back your Grub, you need to boot your system using  Ubuntu Live CD and after making your Cd work , follow these steps:
  • To check the version of Grub , in Terminal type-                                                          grub-install -v    
GRUB2 should display a version number of 1.96 or later.If you don't 
have Grub2 installed,you can install it from Synaptic.After that go to 
Places and mount your Ubuntu partition.Then Go into boot/grub 
directory and check for the existence of the file grub.cfg. 
       Now you need to switch to the terminal-
  • Verify if you mounted the right partition by typing-
                    mount | tail -1 
It will show an output like this- 
/dev/sda9 on /media/0d104aff-ec8c-44c8-b811-92b993823444 type 
ext4 (rw,nosuid,nodev,uhelper=udisks)
To make sure this is indeed the Ubuntu boot partition,run-
ls /media/0d104aff-ec8c-44c8-b811-92b993823444 
but replace '0d104aff-ec8c-44c8-b811-92b993823444' with your UUID.
Output of this command should be similar to this-
config-2.6.18-3-686        initrd.img-2.6.18-3-686.bak   System.map-2.6.18-3-686
grub                           lost+found                          vmlinuz-2.6.18-3-686
initrd.img-2.6.18-3-686    memtest86+.bin 
Now we just need to reinstall GRUB by specifying the correct 
directory and the correct drive name , type - 
 sudo grub-install --root-directory=/media/ 
0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda 
If all went well, you should see something like this-
Installation finished. No error reported.
Now Reboot.Grub should be installed and both Ubuntu and Windows 
should have been automatically detected and listed in the menu.