Sunday, April 26, 2009

Repair a broken Linux boot sector

Dual booting Linux and Windows can cause boot sector problems because the Linux boot loader GRUB, plays nicely with Windows but Windows, especially XP, does not like to play with Linux. Of course, reinstalling an operating system will fix this but repairing the boot sector is a much nicer solution.

I am currently dual booting Windows XP and Ubuntu on my desktop and lucky me, I reinstalled Windows and lost the ability to boot into Ubuntu. In the likely chance that this will eventually happen to you, here's how you do it.

Insert your Ubuntu live installation CD and start a new Terminal session. Type this:
sudo grub
This starts the GRUB console. The prompt should change to look like this: "grub> ". Now type:
find /boot/grub/stage1
This should return something that looks like this: "(hd0,0)". Remember what the numbers are. In my case both were zeros but it could be different for you. Now type these commands:
root (hd0,0)
setup (hd0)
quit
Make sure the values you enter correspond to the response you received earlier. That should fix your booting problems. Now just restart and you should be able to boot into your Linux installation.

2 comments:

  1. What a great post! Just one suggestion:If you add some pics, it would be easiler to follow!
    By Jordan 4

    ReplyDelete
  2. What a great post! Just one suggestion:If you add some pics, it would be easiler to follow!
    By Jordan 4

    ReplyDelete