Thursday, July 23, 2009

Recover grub after Installing Windows

So you have installed the necessary evil OS called a windows. I had to... coz the MMORPG I play won't release a linux version. Now Windows will obviously remove grub.

Here is a simple and sure shot way of recovering it:

1. Get a ubuntu live bootable CD and boot from CD. Any version will do.

2. Start console.

3. Create a directory:
$ mkdir /media/tmp
, we will use it to mount the file system.

4. My defalt linux installtion resided on /dev/sda3 which is pretty common.

5. If you don't know which is yours check by the following command
$ grub
The grub prompt will appear
grub> find /boot/grub/stage1

This should output something like (hd0,2) meaning my partition is sda3

6. Mount the drive
$ mnt /dev/sda3 /media/tmp

7. Now reinstall grub by this command
$ sudo grub-install --root-directory=/media/tmp /dev/sda

8. Now simply re start the PC and it should configure your grub automatically and detect windows.

9. If you want to tweak further /boot/grub/menu.lst contains the list of the boot menu options.