Wednesday, February 3, 2010

Restore Fedora's Grub after Windows 7 Install

Installing Windows 7 on a partition on your linux box will overwrite the MBR so that you can no longer boot into your OS of choice. But don't worry because the OS hasn't been harmed in anyway. Here's what I did after finishing the windows install to restore my MBR to allow me to dual boot.

After booting from a Fedora 12 Live CD, open a terminal and get root.

# mkdir /mnt/fedora
# mount /dev/sda3 /mnt/fedora
# mount /dev/sda1 /mnt/fedora/boot
# grub-install --root-directory=/mnt/fedora /dev/sda

These commands mount the fedora root partition and the boot partition if necessary and then write the boot instruction to the MBR. As long as there's no error message, you should be good to go ahead a reboot. You may have to add the windows boot menu option manually.

Add the following to /boot/grub/grub.conf. Be sure to replace (hd0,3) with the appropriate value for your setup.

title windows 7
root (hd0,3)
chainloader +1

No comments:

Post a Comment