Thursday, May 26, 2011

reinstalling GRUB2

GRUB --- is Truly Grand !
And forgiving too.....

I have a triple boot system - fedora 11, ubuntu (Maverick Meerkat) and windows Vista.
The last one is purely due to my love for Microsoft Flight Simulator !

My fedora install is more than a year old, my ubuntu install is also a few months old and both are robust and fine. But as is expected...I have had to reinstall Vista three times during the last one month or so. Twice due to the trojans and once just becoz the OS decided that some file is missing and quit on me with the blue screen of death.

This post is about my experience with reinstalling windoz and getting GRUB back on the MBR so that I can boot up all the OSs.

As we all know, if one reinstalls windoz after installing linux, then the MBR is overwritten and GRUB is removed during the windoz installation without any prompt. This will lead to a situation wherein, one can boot only into windoz and the linux OS though existing can't be booted into. So the only solution is to get GRUB back on the MBR. But how to do that ?

Follow these easy steps :-
  • Boot up using a ubuntu live CD.
  • Fire up a terminal.
  • Check the partition info to ascertain where is the linux distro located:-
sudo fdisk -l
( For this post we will assume the ubuntu install is in /dev/sda6)
  • Next mount it
sudo mount -t auto /dev/sda6 /mnt
  • Reinstall GRUB2 using the following command
sudo grub-install --root-directory=/mnt /dev/sda
( The first loc i.e /mnt will ensure the grub2 required files are put in the
respective locations and the second argument /dev/sda specifies the
MBR of sda is to be replaced.)
  • Reboot your system

Congrats you have your familiar GRUB2 menu back and you can now boot back into both linux and windoz !

For a nice tute on GRUB2 check out this link.

No comments:

Post a Comment