How do I restore grub?

Asked by bp on 2008-03-01

I'm dualbooting between Windows XP and Ubuntu 7.10. Since the former became unusable (heh), I now have to reinstall WinXP in the first partition.

Doing this will conveniently reset my MBR boot sector to Microsoft's bootloader. How can I then restore the MBR to GRUB's configuration?

Question information

Language:
English Edit question
Status:
Solved
For:
grub Edit question
Assignee:
No assignee Edit question
Solved by:
bp
Solved:
Last query:
Last reply:
Revision history for this message
bp (badpazzword) said :
#1

This is how I solved it.

1. Grab your Ubuntu live CD (pretty much any live CD with grub on it) and boot from it.
2. Once it's done booting, press Alt-F2 or Ctrl-Alt-F2 so that you get to a console. Log in if needed
3. Enter the grub console.
4. Look for the partition containing your grub info:

grub> find /boot/grub/stage1

You should get a reply like:

 (hd0,1)

...which means "first hard disk, second partition".

5. If you get more than one hit for your search, use the geometry command to see which one is your hard drive with Ubuntu on; e.g.:

grub> geometry (hd0)

6. Let's say your grub folder is indeed on (hd0,1). Tell that to grub:

grub> root (hd0,1)

7. Finally, set up your hard drive (not your partition! "setup (hd0,1)" won't work) to run grub:

grub> setup (hd0)

[You should get here some progress information.]

Reboot. Cross your fingers, and grub should launch.

Revision history for this message
robin (banglarrobin) said :
#2