How to restore Windows 7 MBR without a CD
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.
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
/dev/sdawith the name of your drive.
What parameters do (from man page):
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
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).
This specifies the default boot sector to load. Valid values of
- 1, 2, 3, 4 The specified partition number.
FThe first floppy disk.
DThe partition marked with the bootable flag in the partition table.
--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.
mbrnot on repo you can download the Deb package from here.
sudo apt-get install syslinux sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda
Instead of using the whole Ubuntu LiveCD, one may use more easily the boot repair disk that is mentioned in a different answer and just boot in that one.
The second method worked for me, I didn't know what was the name of my drive so I just want with /dev/sda which work for me. But now I don't have a dual boot (windows 7/ubuntu) anymore only windows 7 ( but at least I didn't loose anything). Thanks Pawel!
i would appreciate if someone explained how linux commands/files like mbr or mbr.bin end up restoring/repairing a Windows MBR boot sector.. - i mean - these are two different OSes and many people mention bootsec.exe and only being able to repair windows MBR via Windows Rescue CD etc. - how come linux commands that vaguely look like copying (dd) linux MBR - do magic to a windows partition? i'm sorry for that level of incompetence, and thank you for understanding
You may download the Boot-repair Disk iso images and burn it to a USB stick. Then, boot the stick and repair the MBR on the defected hard disk as you like. Both 32-bit and 64-bit versions are available.
It really works, I use it to repair a Win7 disk which MBR was accidentally over written by GRUB during the installation of Debian.
Consider Super Grub Disc as a solution. You can put it on your pendrive with Unetbootin and boot to your pendrive. Select
Fix boot of Windowsto restore your Widows MBR(no Ubuntu access with this potion) or
GNU/Linuxfollowed by the Fix Boot option(If you want both Ubuntu and Windows). You may then reboot and get access to your OS's(depending on your choice, you may only get the Windows MBR). Note that although Super Grub Disk is outdated, Super Grub Disk 2 does not work, and so you should use Super Grub Disk.