RSS

How to restore Grub to your MBR using the Ubuntu 6.06 live cd

Mon, Oct 23, 2006

ArsGeek, Linux, Ubuntu

Talk about it in our Forums

eww!
I’ve recently installed Vista as the third OS on my laptop. Of course, when I did, it blew away my MBR and my computer forgot all about grub. Then I couldn’t boot into Ubuntu and I was not a happy camper. Although truthfully, I expected this to happen, it being a Windows install.
Fixing this is surprisingly easy. Here’s how to do it:


Boot into the LiveCD.

Open a Terminal Session and become root by typing this:

sudo su -

Now let’s launch grub.

grub

We’re going to find out where Grub should boot from.

find /boot/grub/stage1

Your output should look something like this (it’s what I get) (hd0,2). That’s your hard drive/partition. Once we’ve got that info, we can tell grub where your root directory is, and where the MBR should be.

root (hd0,2)

setup (hd0)

Now all that’s left is to quit grub and restart

quit

shutdown -h now

Once your machine restarts, you should see the grub menu again and you can go on your merry way.

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

17 Comments For This Post

  1. Pavel Says:

    Hello!

    I’ve tried exactly the above (also got (hd0,2) ), and the grub indeed came back.
    Windows loads great, but loading kubuntu fails with the following error:

    root (hd0,1)
    Filesystem type is fat, partition type is 0xC
    kernel /boot/vmli…. root=/dev/hda2 ro quiet splash
    Error 15: File not found

    Can you please help?

    Thanx!

  2. arsgeek Says:

    Hey Pavel,

    Sounds like Grub may be pointing to either the incorrect file system, or to a file system that no longer exists.

    Did you happen to install Kubuntu on a FAT partition? Perhaps grub got a little confused. What’s your output from fdisk -l look like?

  3. Curtis Says:

    This even worked using a dapper install cd on an edgy install. I didn’t know about the ‘find’ command before, and now I am a happy camper!

    Thanks!!

  4. Gerard Says:

    What a great article. This is just what I needed after reinstalling WinXP on my dual-boot system.

    Just one thing: you should point out that the hd0 in the root command is not the same as in the setup command. e.g. on my machine Ubuntu is on sd1 and Windows on sd0. I blindly used “setup (sd1)” before realising it should always be “setup (sd0)”.

    Regards,
    Gerard.

  5. Franklin Says:

    Make sure you’re root before you type “grub”

    So its..

    # sudo -i
    # grub
    grub> find /boot/grub/stage1
    grub> root (what ever it printed out)
    grub> setup (hd0)
    grub> quit

  6. hans57sauc Says:

    works perfectly. took 5 minutes:
    boot live cd
    open terminal
    type `sudo grub’
    type `find /boot/grub/stage1′
    (hd0,2)
    type `root (hd0,2)
    type `setup (hd0)
    type `quit’
    type `exit’
    reboot and presto!

  7. Ahmed Says:

    Hallo,

    I followed the following steps;

    boot live cd
    open terminal
    type `sudo grub’
    type `find /boot/grub/stage1?

    After this step I got;

    Error 15 : File not found

    I tried to reinstall the Kubuntu or even Ubuntu system again but I am getting the same error, SQUASHFS error, I am even not able to access the WindowsXP :-(.

    Can anyone help, please.

    Thanks in advance.

    Ahmed.

  8. trfsdf Says:

    @Ahmed

    It appears this trick no longer works with Feisty. We’ll have to look for a work-around.

  9. Michael Says:

    I just want to ask… why in the world would you install vista in the first place?

  10. meka4996 Says:

    Super Grub Disk rocks! Multi Linux!!
    repair restore recover [reinstall] linux GRUB bootloader/menu,
    or multi OS/distro multi disks/partitions MBR!
    It works on my ubuntu 7.04 in 1 minute!
    see their wiki for
    “SGD Quick Menu”
    “Multi Distribution Boot Howto”
    “Boot Problems”
    “Howto Fix Grub”

  11. paul Says:

    Thanks a lot! You saved my life ;-)

  12. mufn8r Says:

    It worked flawlessly!

    Thank you to the OP, ArsGeek.

  13. ikecomp Says:

    @hans57sauc, thank you so much for posting those steps. I had scoured the internet for hours trying to correct this issue and your steps worked perfectly. I also want to thank the original poster as well for making this information available

    Thanks again

  14. Alberto Riomao Says:

    God bless you! This “find /boot/grub/stage1″ command saved my neck.

    Thank you!

  15. mohammed Says:

    cool thanx very much ,that was helpful

  16. Methos Says:

    I also have WinXP and Ubuntu. I haven’t blown away my MBR, but we all now Win needs to re-install from scracth from time to time when it starts to get slower.

    Great post. Thanks a lot.

  17. thegoutap Says:

    yup its great……

    but many have the prob with stage1 not being found

    i.e $find /boot/grub/stage1
    gives an error of not found or so..

    in this case we need to mount the boot
    here’s it is ..coz i faced the same prob

    then type the following using a live cd of ubuntu or any..and in terminal

    use sudo whereever needed
    mkdir /mnt/orange/
    mount /dev/XXX? /mnt/orange (XXX i.e.sda1..)
    chroot /mnt/orange /bin/bash
    grub-install /dev/XXX (XXX i.e . hd0)

10 Trackbacks For This Post

  1. ArsGeek - Free your inner geek » How I triple booted my x60 with Ubuntu, XP and Vista and got to repair my MBR too! Says:

    [...] How to restore Grub to your MBR using the Ubuntu 6.06 live cd [...]

  2. 100 Ubuntu Help Links and Guides « Ubuntu OS Says:

    [...] - graphical setup tool for Alternatives Configuration in Ubuntu- Triple boot XP, Vista, and Ubuntu- Restoring GRUB with the Ubuntu Live CD- Edgy Common problems with Solutions- Configure GRUB and usplash- Flash Player 9 Beta on Ubuntu [...]

  3. Como restaurar seu MBR com o Grub e o live cd do Ubuntu 6.06 « Crab Log Says:

    [...] Reinicie o computador. Fonte: How to restore Grub to your MBR using the Ubuntu 6.06 live cd [...]

  4. Switching: Windows to Ubuntu Says:

    [...] way is to boot from a live CD of Ubuntu and reinstall GRUB. It’s easy. Various instructions are here, there and everywhere. 10. Official Update Supplied Shiny, Brand New Graphics Problem: An official [...]

  5. Ubuntu - My experience Says:

    [...] way is to boot from a live CD of Ubuntu and reinstall GRUB. It’s easy. Various instructions are here, there and [...]

  6. Recuperar un arranque dual Ubuntu - Windows con GRUB « las tribulaciones técnicas de santib90 Says:

    [...] La información original la encontré aquí. [...]

  7. Unix Mouth » How to restore Grub to your MBR using the Ubuntu 6.06 live cd Says:

    [...] read more | digg story [...]

  8. ubuntu.linux-hardcore.com » 100 Ubuntu Links Says:

    [...] - graphical setup tool for Alternatives Configuration in Ubuntu- Triple boot XP, Vista, and Ubuntu- Restoring GRUB with the Ubuntu Live CD- Edgy Common problems with Solutions- Configure GRUB and usplash- Flash Player 9 Beta on Ubuntu [...]

  9. ubuntu.linux-hardcore.com » 100 Ubuntu Help Links and Guides Says:

    [...] graphical setup tool for Alternatives Configuration in Ubuntu - Triple boot XP, Vista, and Ubuntu - Restoring GRUB with the Ubuntu Live CD - Edgy Common problems with Solutions - Configure GRUB and usplash - Flash Player 9 Beta on Ubuntu [...]

  10. Here be dragons » Blog Archive » Windows Wiped My MBR! Says:

    [...] No worries, because fixing it really is this easy. [...]

Leave a Reply