Ubuntu – How to restore Windows 7 MBR without a CD

bootdual-bootgrub2windows 7

I have been playing with Ubuntu for a few weeks now, and I'd like to revert my computer back to it's original – factory – defaults.

On the computer I have a recovery partition (it's a netbook). I went through the process of recovery and everything seemed fine. However, when I restart the computer I'm presented with

grub rescue >

Now, my understanding is that when I installed Ubuntu "side by side" it replaced the MBR or something like it, with GRUB.

I've read on a slew of forums, that I need to use a Windows Recovery Disk.

Here are my issues:

a) I don't have a recovery disk, I have a recovery partition – it's a netbook.
b) I don't have an external cd drive.

What I do have is a USB key that has about 1gb of space on it.

Thanks in advance.

Best Answer

install Ubuntu LiveCD on your pendrive, boot from your pendrive, open terminal and type:

sudo apt-get install mbr
sudo install-mbr -i n -p D -t 0 /dev/sda

Replace /dev/sda with the name of your drive.

What parameters do (from man page):

--interrupt <mode>, -i <mode>

This option sets the list of events which will cause the MBR to display it's prompt. Use -i +<event> to add an event to the list or -i -<event> to remove an event from the list. Values of <event> are:

  • s – A shift or control key is pressed.
  • k – A non shift-like key is pressed
  • a – The prompt is always displayed.
  • n – Never display the prompt (unless an error occurs).

-p <partn>, --partition <partn>

This specifies the default boot sector to load. Valid values of <partn> are:

  • 1, 2, 3, 4 The specified partition number.
  • F The first floppy disk.
  • D The partition marked with the bootable flag in the partition table.

-t <timeout>, --timeout <timeout> This option changes the time which the MBR waits for before booting the default partition to the value specified in 1/18 seconds (approx). The maximum timeout that can be specified is 65534 which is about an hour.

If mbr not on repo you can download the Deb package from here.

Another method:

sudo apt-get install syslinux
sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda