Tuesday, March 27, 2007

How to: Reinstalling Grub in Ubuntu Edgy, Fixing Windows Boot Record

Since windows likes to play with MBR and can't live without it, it overrode the boot record of my hard disk - wiping Linux boot info :(.

If you ran in similar problem, Here's a quick way of fixing it,

Boot from Ubuntu Live CD
sudo grub
grub> root (hd0,0)
grub> setup (hd0)
grub> exit

In (hd0,0) hd0 suggests first hard disk and 0 is the partition number (starting from 0, 0 means first partition). Also you can find out where the grub is installed by keying the command "find /boot/grub/stage1" in grub prompt.

Then, Add following lines to /boot/grub/menu.lst or wherever grub is installed.
title Windows XP
root (hd0,)
chainloader +1
Just in case, if you have lost the boot record altogether ("Can't boot: Invalid Disk"): Boot from Windows CD and start repair just before installation, it will start recovery console. There, type in "fixboot". It is one of the risky windows command, see details here fixboot. Running it will restore the partition boot record and your system should boot (also you may like to use "fdisk /mbr" to restore, default jump on first partition boot record, your master boot record).

No comments: