Linuxtipstricks – Just another /linux/blog

October 19, 2008

How to restore GRUB in your MBR if Windows changed it

Filed under: user tipstricks — Antonio Portuesi @ 7:29 pm
Tags: , , , , , , , , , ,

Once upon a time it was a GRUB (GRand Unified Bootloader) menu showing up itself after a normal Bios POST…

Then you said: Why should I do not another Windows release test?

It is over, during the last setup step Windows installer overwrite the MBR (Master Boot Record) and you cannot make a OS choice at boot time anymore.

And now?

Before you start please note that if you are not confident in what you are doing or in repairing or recovering from the above listed process, then do not step to the outlined instructions. Working with MBR is easy in almost all situations, this process does not carry out data loss, but there still exists a (however minimal) risk about that, so you should back up your data before attempting to modify your hard disk settings.

I cannot help you troubleshoot problems you could have following this tutorial.

Follow these steps, get back the control and come back a dual boot user.

First of all clear your mind and do not forget that this method puts GRUB back on the MBR of the hard drive instead of in the root partition. This is good for most of you, but not if you already have an alternative boot manager as Boot Magic or System Commander or Acronis OS Selector.

If you have installed GRUB into the root partition instead of the MBR, the commands are a little different. Here there is the procedure:

Boot from a Live CD, (Ubuntu, OpenSuSE, Mandriva, Gentoo, Fedora and so on)

Open a terminal. Go on as SuperUser (or use sudo command) and enter root password as requested.

user@domain:~$ sudo grub
user@domain:~$ password for user:

Then type:

grub> find /boot/grub/stage1

You will get a system response like “(hd0)” or in my case “(hd0,6)”

grub> find /boot/grub/stage1

Go on typing:

grub> root (hd0,6)


grub> setup (hd0,6)

Pay attention here and stay focused: other troubleshoot instructions suggest you to type “(hd0)”, and that is good if you want to write GRUB to the MBR and not on the root partition. So this is up to you.

The final command let you exit the grub shell:

grub> quit

Now reboot the system and remove the bootable live media.

user@domain:~$ sudo reboot

I hope this guide will help you to gain control of you boot procedure.



  1. What do i do in the case i don’t receive any answeear to grub> find /boot/grub/stage1, instead it says smt like file not found. I’m using the ubuntu 8.10 live cd. I read all sorts of post but none metioned about this issue. I tried mounting the partitions in different folders but nothing worked out. Any help would be appreciated ? Thanx

    Comment by bion — January 30, 2009 @ 6:59 pm | Reply

    • Try to find the stage2 instead, maybe your stage1 has been compromised.

      Comment by Antonio Portuesi — February 1, 2009 @ 1:50 pm | Reply

  2. Worked thanks man

    Comment by Nelson — May 22, 2009 @ 6:26 pm | Reply

  3. In my case using (hd0) worked the second time after trying (hd0,0)…
    Thank you

    Comment by Vibhu — December 20, 2010 @ 6:33 pm | Reply

  4. […] OS? Wich bootloader? Can you get into single-user mode or only grub prompt.…ws-changed-it/…ws-changed-it/ If debian Once you get […]

    Pingback by problem with fstab and read-only filesystem — April 13, 2011 @ 6:26 am | Reply

  5. Worked for me the second time after trying ‘setup (hd0)’ instead of ‘setup (hd0,2)’ . What a relief! Thanks!

    Comment by Matt — October 19, 2011 @ 10:38 pm | Reply

  6. Thank you for some other excellent article.

    Where else could anybody get that type of info in such a perfect way of writing?
    I’ve a presentation next week, and I am at the look for such information.

    Comment by — May 3, 2013 @ 4:19 am | Reply

RSS feed for comments on this post. TrackBack URI

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Create a free website or blog at

%d bloggers like this: