Wednesday, June 17, 2009

How to recover your ubuntu after reinstalling Windows

Yesterday I got mood to give a try windows7 rc which I downloaded 2 days back. But I got problem because i had to reinstall ubuntu which is already there. And i don't wanted to do that. I did some googling and finally I got how to recover ubuntu. Actually after installing windows it remove previous bootloader from MBR(Master Boot Record) and reinstall fresh bootloader in MBR. To reinstall previous bootloader boot from ubuntu linux live cd and open a terminal. Follow the following step :

1> sudo grub
You will get "grub>" command prompt.

2> find /boot/grub/stage1
If you get "Error 15: File not found", try the following:
find /grub/stage1

3> Using this information, set the root device (fill in X,Y with whatever the find command returned):
grub> root (hdX,Y)

4> grub> setup (hd0)

5> Exit Grub:
grub> quit

Enjoy !!
ps: For extra information click here.

Update:
If you are updating/recovering grub with ubuntu 10.04 or later, try following command: (source)

You’ll need to know the device name of your primary ubuntu partition, in this example I’m assuming it’s /dev/sda5
mount /dev/sda5 /mnt
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot /mnt
update-grub2
grub-install /dev/sda


Enjoy Linux !!

No comments:

Post a Comment