Restore corrupted (grub) MBR using a live UBUNTU CD

I have both ubuntu and windows XP installed in my thinkpad X61. The mbr on my laptop was erased after executing the System Update under windows XP this afternoon. 😦 The grub menu was gone with only four letters – GRUB – appeared on screen after rebooting. The mbr might also be destroyed when you reinstall windows XP. This article will help you to resotre your original mbr using ubuntu live CD.

Here is a way to restore the grub mbr if you have grub previously installed.

  1. Get a ubuntu installation CD. Boot your computer from the live CD. Select the “graphic safe mode”(don’t remember the exact label) which is right below the install ubuntu selection. It’s going to take a while for Ubuntu live CD to boot.
  2. After entering the desktop, open a terminal. The Ubuntu live CD does not mount the drives so you have to do it yourself. Let’s mount the disk, which Ubuntu was installed, to /media (or whatever place you prefer) first.
    sudo mount -t ext2 /dev/sda# /media/
    # is the drive number Ubuntu installed to. In my case, it’s /dev/sda3.
  3. Then you have to mount proc and dev to /media as well. This will allow your devices to be detectable after we apply chroot in step 5.
    sudo mount -t proc none /media/proc
    sudo mount -o bind dev /media/dev
  4. cd to the directory /media/boot/grub/ and make sure the file stage1 is there. It should be there if you have grub previously installed. If the file is not there, sorry you will have to google a solution to fix your problem. 😦
  5. Change current system root to /media/ which is the root of your previous installed ubuntu!
    sudo chroot /media
  6. Now you are in the chroot environment.
    sudo grub
    This will lead you to the grub shell with a grub> prompt.
  7. In the grub shel, enter
    find /boot/grub/stage1
    It will return parameter in the format of (hdX,Y). that is used in next step.
  8. Enter
    root  (hdX,Y)
    put a space between root  and (hdX,Y)
  9. Then enter
    setup (hd0)

  10. Enter quit to leave grub and then reboot.
  11. The GRUB menu should appear on the next boot up.

2 Responses to Restore corrupted (grub) MBR using a live UBUNTU CD

  1. this is helpful, thanks!

    depending on what shell you have in your export you may need to change it before doing chroot…

    another side note: most installations are using grub2 which doesent have a “stage1” but rather has a bunch of confusing junk… if you cant find your stage1 you probably have grub2

  2. هيئة المهندسين التجمعيين – corps des ingenieurs du parti du RNI

    corps des ingenieurs du parti du RNI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: