Thursday, April 08, 2010

Restore Grub2 to MBR

It used to be so easy to get Grub1 back into the MBR if you happened to mess it up somehow. Just a matter of booting from Linux install CD, opening a terminal and going through some very simple commands.
However, I had never done this with Grub2 until a few days ago.
It's just a little more complicated to restore Grub2, but will take less than 5 minutes to complete.
Here's the essence of what you do but the details are available here (See the section Recover Grub 2 via LiveCD):

1. Boot to a Linux LiveCD (I used Ubuntu Karmic)
2. Open a terminal and mount the device holding your main Linux partition with
sudo mount /dev/sdXY /mnt
3. Mount all your other devices with
sudo mount --bind /dev /mnt/dev
4. Now chroot to your system with
sudo chroot /mnt
5. Next, in the Linux system, update Grub with
6. Finally, install Grub2 to the MBR with
grub-install /dev/sdX

Note that X and Y refer to the device number. For example, /dev/sdb2 usually refers to the second partition on the second disk (although not necessarily the second disk).
After this, you should be able to use your Grub boot menu as it was before you messed it up.

No comments:

Post a Comment