Mini-Howto: Restore Windows MBR/Bootloader with Linux
August 26, 2009
I’m often, at least more than I care, asked how to restore a Windows MBR/bootloader without having a windows install cd or a dos boot disk at hand. It’s quite easy you need just a Linux live cd like (the Ubuntu live cd or Knoppix) or an installed Linux you want get rid of. I really don’t know why you want to do the second, but anyway here are the 2 solutions I know of.
Boot Linux and make sure you’ve a working Internet connection and type following on the terminal/konsole.
1. Solution
sudo apt-get install syslinux
if the package got installed use following to write the MBR.
sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda
2. Solution
sudo apt-get install mbr
if the package got installed use following to write the MBR.
sudo install-mbr -i n -p D -t 0 /dev/sda
Common for both
Replace sda if you want to install the MBR to a different drive. Take a look at your hard disks with sudo fdisk -l if you’re unsure. Finally reboot and your windows should boot.
29 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress
Entries and comments feeds.
Valid XHTML and CSS.
17 queries. 0.095 seconds.
Thank you, thank you , thank you! I tried Ubuntu, could not get anything to start w/o the live CD, couldn’t get to Windows. Tried the beginner forum, got some input that didn’t work, but somewhere in there was the link to your page. It worked like a charm. I am done experimenting.
Comment by Dave — December 9, 2009 #
thanks so much for sharing. it’s so difficult nowadays to find in the great amount of resources emerging every day smth that is worth my attention. you helped me a lot:)
Comment by Mike Hunter — March 2, 2010 #
It worked like a charm. I am done experimenting.
Comment by labatterie — April 27, 2010 #
It’s THAT SIMPLE????
[tries it]
THANK YOU! THANK YOU! THANK YOU! THANK YOU!
WINDOWS BOOTS AGAIN!!!!!
THANK YOU! THANK YOU! THANK YOU! THANK YOU!
[prints out the instructions and adds it to the “Important Computer Stuff” folder.
Comment by Fred Doolie — June 27, 2010 #
I OTOH am not done experimenting at all!. Now that I know how to re-windowize my system from a total Linux install I’m free to play around a lot more. The restore CDs that came with the system don’t restore the MBR; only the OS. In other words Grub is still in the MBR. I even tried using gparted to totally wipe the drive as if it was a new clean HDD. Windows partitioned the drive and installed but kept rebooting since there was no MBR info. Your little trick added that and now it”s all good!
Comment by Fred Doolie — June 27, 2010 #
Now that I know how to re-windowize my system from a total Linux install I’m free to play around a lot more.
Comment by batterie — June 29, 2010 #
It friggin worked, thanks dude!!!!
Comment by Wim — September 8, 2010 #
Yes! This solution was just what I needed. Thank you!
Comment by Grady — September 25, 2010 #
did not work…ALAS!
Comment by kaykav — November 18, 2010 #
[...] det om du kun har én.Start maskinen på nytt.Vips! Verre var det faktisk ikke, utrolig nok.(Kilde: Robert Penz blog)Skrevet av Alexander Karlstad 6. januar 2011 klokken 00.30Postet i Linux,Tips og triksStikkord: [...]
Pingback by EDBloggen » Fikse boot-laster/MBR for Windows i Linux — January 6, 2011 #
Did you rewrite the MBR and then immediately reboot successfully?
Or did you need to rewrite the partition table and/or recopy the data on the disk after that?
Comment by Nate — April 4, 2011 #
ubuntu should be user frendly, messing up a disk like this so u cant even boot or INSTALL windows anymore isnt very user frendly is it.. and i never had a chooise in this… wasted hours in this crap, iam totaly done with ubuntu, only had problems with it,
3d accel didnt work (even crashed had to reinstall) cant use my daily progs (like cs4/cs5, it did work in virtualbox but that way is crap)
something went terrible wrong with .crypt had files over 5g and after removing those bang everything gone…, and when i removed ubuntu, icouldnot boot or install windows, real user frendly yes…, next time i will use opsuse or something in vmware or an isolated disk, neve ubuntu again bah
Comment by whitewidow01 — April 12, 2011 #
@Nate: just reboot nothing more to do
Comment by robert — May 5, 2011 #
So I tried what you have written, but maybe I’ve typed something wrong, and now all the computer ever does is show a screen that says “MBR 1F”
Doesn’t even boot off the CD, Is there a way to fix this?
Comment by Tom — May 23, 2011 #
@Tom: you need to choose the boot media in the bios. Often a text like “Press F12 for boot menu” is shown. this would be the key to press for you.
Comment by robert — May 29, 2011 #
if I could second comment #4. Thank you so much! I had almost given up hope with all of the mindnumbing alternatives
Comment by Tom — June 9, 2011 #
Thank you!!!
Comment by Sam — June 23, 2011 #
Hi, after trying solution 2 (sda = sda1) at reboot grub2 was still there and windows vista did not start anymore. I have kubuntu 11.04 and window vista installed.
Could you pls help me?
Comment by sempreelo — August 9, 2011 #
Thank you, it is veeeery easy solution. I was reading this page few minutes ago in a browser loaded from Linux live USB, and now I’m writing from WinXP with repaired mbr as a result of following your instructions.
Comment by Sasha — August 9, 2011 #
@sempreelo: Than you most likely used the wrong device name. sda would be the mbr and sda1 the boot loader of the first partition and if the first partition is your windows partition you overwrote the wrong sectors.
Comment by robert — August 15, 2011 #
Awesome, thanks dude.
Comment by matt — September 21, 2011 #
Thanks a lot for this article.. very useful. Used solution#1 w/ ubuntu live cd..
Comment by Trilok — September 22, 2011 #
Will this remove the Grub from the MBR?? that is now only windows will come as a option to boot??
Comment by Arjun — October 5, 2011 #
It will remove Grub from the MBR and will install a MBR which boots the “active” partition. You can set the active partition in almost any partition manager, if Windows is not on the active one.
Comment by robert — October 6, 2011 #
Should probably put a warning and a better description to NOT overwrite your Windows boot drive.
It destroys your install of windows rather than helps it.
Find out what your drive is called (sda1) via GNOME
aka GPartition (its on Ubuntu Live already) – and do NOT, DO NOT write to it. It destroys your windows and you have to do a full reinstall again.
Thanks for the post and that, but should have more
clarity tbf.
Comment by Peter — October 29, 2011 #
If you use a partition device file instead of a whole hard disk file you’ll write the master boot record into the partition … thats not good!! you will need to repair the file system after that, in most cases this should also work as only 512 bytes are over written (as the mbr is not bigger). But in this case you should really know what you do and than it would not happen in the first place …..
Comment by robert — October 31, 2011 #
Worked like a charm. I need to get my linux parttion back, though. Thank You, anyways!!
Comment by anuz — November 9, 2011 #
Didnt work on ubuntu 11.10. i had an internet connection but this is what i got.
cannot locate package when i did sudo apt-get mbr.
Comment by Taz — December 28, 2011 #
did you an apt-get update before?
The package is available:
http://packages.ubuntu.com/oneiric/mbr
Comment by robert — December 28, 2011 #