Saturday, July 2, 2011

Reinstall grub2 after installing windows 7 (XP/Vista)


You may need to reinstall grub when windows is installed after ubuntu (or if you reinstalled windows in dual boot (Windows and ubuntu) system). I used following steps for reinstalling grub in order to login to my Ubuntu 10.04 after reinstalling Windows 7 on my machine.

1. boot the ubuntu LiveCD

2. Open a terminal and type
sudo fdisk -l


This list the partition tables, and in my case root (/) partition is on /dev/sda9.

3. Mount that partition using following command.

sudo mount /dev/sda9 /mnt

4. Run the grub-install command as below. This will reinstall the grub 2
sudo grub-install --root-directory=/mnt /dev/sda
Here "sda" is the hard disk on which your Linux distribution is installed!

5. Reboot

6. Finally Refresh the grub 2 menu using following command

sudo update-grub

Now everything should be fine :)



17 comments:

MaTachi said...

Thanks, worked great! :)

pavol slovakia said...

Thanks , super

Anonymous said...

THIS IS THE Clearest post for reinstalling grub2 on 10.04. Ive done this process like three times and its always a hassle finding instructions for 10.04...emailing myself this link now....thanks:-)

Kasun Weranga Gunathilake said...

Thanks all for commenting, it is a pleasure to see everybody's doing it successfully by following the post.

olinews said...

Worked like a charm for me too on xubuntu 11.10-amd64 + Win7-x64. Thanks alot for sharing this.

Anonymous said...

Thanks very much, I spend 3 hours without your help, but by your help, it was only 5 minute.. very great..

Anonymous said...

Thank you! This was perfect

Shivku said...

Worked very good, now got back my BackTrack 5 and Win7 64bit OS running too :)

ge0rge04 said...

Tnx !

LuDi said...

Much Appreciated!

Anonymous said...

Just wanted to say: Thank you very much :) works like a charm

Anonymous said...

Worked perfectly for my lady's laptop after she wanted Windows 7 installed next to an existing Xubuntu installation. Interestingly, both the official Ubuntu-provided solutions, Boot-Repair and a terminal walk through, did not work at all. Perhaps consider sending this upstream so it makes it into the Ubuntu documentation?

Thanks again! Made me look like a genius. :)

Roshnal Lihinikadu said...

Thanks a lot bro! I had installed Windows 8 after Ubuntu 12.04 and this got me back my grub easily.. Thanks again!

ismail said...

thank you very much man... you saved my day.. :)

Anand Roshan said...

Hi thanks nice tutorial . very useful. Thank you very much

Anonymous said...

thank you. Your tutorial is simple, correct and very useful , Cheer:)

windows 8 free download trial verision official demo said...

Ive done this process like three times and its always a hassle finding instructions for 10.04...emailing myself this link now....thanks:-)