November 3, 2006

Reinstalling Windows In A Dual Boot System

tux.jpgIf you've ever setup a dual boot system with Windows and Linux before, you know that you have to install Windows first. Then you install Linux, which will include a boot loader that will allow you to boot into either operating system. But what do you do if want to reinstall Windows when you're using a boot loader like lilo or grub?

If you just put in the Windows CD and do a fresh Windows reinstall it will take over the system, and require you to reinstall Linux again, even if there's no need. What happens is Windows writes over the Master Boot Record (MBR), the first 512 bytes of the hard drive. The MBR points to the partition to find the bootable operating system, and Windows points it to itself. To avoid this, you can save the MBR before you install Windows, and write it back after the install to resume using your dual boot system as usual.

I did this in Ubuntu, but it will work in any flavor of linux. On the command line, enter the following:

sudo dd if=/dev/hda of=/path/to/save/mbr.image count=1 bs=512

Substitute the path you want to save the MBR image and the correct device of your hard drive, which is probably hda. You've now saved a copy of your MBR from your dual boot system. At this point you should save MBR image to a USB drive or email it to yourself. Now go ahead and install Windows.

When the Windows installation is complete, you need to write back the original MBR. Boot into Linux with a knoppix disc and find your MRB image. From a terminal run the following:

dd if=/path/to/saved/mbr.image of=/dev/hda

Of course remember to sub in the path to your MBR image and the device name of your hard drive. That's it. Reboot and things should be back to normal.

Posted by stoltenow at November 3, 2006 2:35 AM


This worked great, thanks

Posted by: Anonymous at November 10, 2010 12:25 PM

Is it not possible at all to reinstall windows in its own partition only? I mean without touching the Linux and the Data partitions.

Some file got corrupted and I can't boot into the windows 7, so I wanted to correct the problem without losing my data

Posted by: Conloria at February 15, 2010 4:35 AM

Will this still work if I am am installing XP rather than the previous vista installation?

Posted by: Dweyer at May 26, 2009 1:26 PM

Thanks, this was very useful :)

Posted by: Nanda at May 14, 2009 10:54 AM


much appreciated

Posted by: nigel at April 12, 2009 8:46 AM

Thanks a lot, it works!

Posted by: Someone at January 6, 2009 10:52 AM

thanks a million...

Posted by: aytac at April 7, 2008 6:54 PM

I was thinking along these lines but didn't know the correct command to use.

Posted by: Aaron Jacobs at November 30, 2007 6:37 PM

Post a comment

Remember Me?