Thursday, September 15, 2011

Restore Grub of Installed Linux

I have machine with dual boot. 4 years back I installed Windows XP Pro and Ubuntu 7.10. After 4 years it was time to reinstall XP the only issue was restoring GRUB as on Ubuntu 7.10 back to MBR as XP will rewrite the MBR. Here are the steps to achieve it.

After successful re-installation of XP.
  • Boot system with Live CD of Linux can be ubuntu/Knnopix etc.
  • mount the Linux Partition after Live CD is done.
    sudo mkdir /mnt/root
    sudo mount -t etx3 /dev/sda6 /mnt/root
  • Then have to mount the proc subsystem and dev inside /mnt/root
    sudo mount -t proc none /mnt/root/proc
    sudo mount -o bind /dev /mnt/root/dev
  • Doing this allows grub to discover drives.
  • Now time to run grub
    sudo chroot /mnt/root grub
    find /boot/grub/stage1
  • I had (hd0,5)
    root (hd0,5)
    setup (hd0)
  • Thats it. Grub is now restored on MBR.