Edited Thursday, 12th April 2012
This web-page is part of a larger website giving examples of how to install Windows+Ubuntu Linux operating systems 'dual boot' in a computer. Illustrated Dual Boot HomePage.
If you are about to uninstall Ubuntu No! Wait!
If you are about to install Ubuntu
It's just common sense to want to take a look and see how to undo what it is you are considering doing before you go ahead with things. You should read this page first so you will know how to 'uninstall' Ubuntu just in case you might ever want to for some reason. That's unlikely, and Ubuntu is quite easy to uninstall as you will see.
If you haven't installed yet and you are the cautious type, you could consider making a backup of your MBR just to be sure. A Linux 'dd command' will make a perfect copy of the IPL part of your MBR for later restoring if you ever need to. Now is a good time to do it, and it's quite easy. You can do it with any Live CD, MBR Backup and Restore.
If you are about to uninstall Ubuntu,
Even if you don't use Ubuntu, you should still keep it unless you really need the extra hard disk space. Ubuntu is very secure, and you can use it as a secret partition for storing back-ups and important data on. You can easily use Grub Customizer or manually edit /etc/default/grub to 'hide' the GRUB menu. That way no-one will see it when the computer is starting up unless you press the 'Esc' key at the right moment.
Ubuntu is a good emergency operating system to keep around. When your other operating system lets you down and fails at a critical time, you can just boot into Ubuntu and get your urgent work done until you have time to get the other operating system repaired. At the same time, you'll know if it's a software problem and not a hardware problem if your equipment suddenly works properly under Ubuntu. Look at this link: Why Dual Boot - rayslinks.com
Okay, enough talk, for those who really insist on uninstalling, here it is:
Uninstalling Ubuntu is a two step process which most people should be able to do very easily. Read how below ...
STEP ONE, PREPARE THE MBR
First, let me explain the main thing you'll need to understand. Remember back when you installed Ubuntu? I don't know about you, but I always choose to install the 'IPL' for the GRUB bootloader to MBR on my hard disk during the install. The MBR is in the first sector of our hard disks. One sector of a hard disk is 512 bytes in size.
The MBR contains three important parts. One is the hard disk's 64 byte partition table, and another is the 2 byte 55aa signature to indicate to the BIOS that it is a bootable device.
That only leaves 446 bytes of room for the bootloader. No bootloader can actually fit into such a small space. When we say we are installing a bootloader to our Master Boot Record, we don't really mean that exactly. The bootloader only puts a small code there just enough to point the BIOS somewhere else on the disk where there is more room. The part that fits in the MBR is called the 'IPL' or 'stage one' of the bootloader. That's the only thing that gets changed, and it's the only thing that needs to be changed again now.
Normally the simplest place to put 'stage2', the main (functional) part of a bootloader is in an operating system partition. Your Windows NTLDR second stage lives in your Windows partition and Grub stage2 lives in your Ubuntu partition.
The main part of the bootloader, be it Grub, LiLo or NTLDR, is the part that actually does the real work of booting the operating system's kernel.
When we are dual or multi-booting, Stage2 also gives us a Menu which allows us to choose which operating system you want during boot-up. When you were using Grub, if you choose Windows, GRUB redirects the BIOS back to Windows boot sector and the NTLDR bootloader, to 'chainload' Windows. It works like a relay system.
The problem is when you delete the Ubuntu partition, that second, vital part of Grub will suddenly be gone. When you try to boot up, your MBR will still be pointing to GRUB's core.img, but GRUB's core.img will just be pointing to an empty space. There will be nothing there to offer you a menu to choose Windows anymore either. You'll just have a GRUB Rescue prompt with a blinking cursor.
You can avoid that situation by moving GRUB out of Ubuntu and installing it in it's own partition, Keep GRUB and Make a Dedicated GRUB Partition
Or you can prepare your MBR for deleting GRUB. This can be easily done by overwriting the 446 bytes of bootloader code in the MBR with code for another bootloader before you delete the Ubuntu partition, and GRUB along with it.
Well, don't worry if you have deleted Ubuntu already, you can still overwrite your Master Boot Record's IPL code later at any time.
You can replace Grub's MBR code with the equivalent code for NTLDR and make the MBR point directly to Windows like it used to by simply using the same software you used when Windows was installed in the first place. This will overwrite GRUB's version of the 'IPL' in your MBR (or 'boot sector'), and replace it with the Windows version again.
The way to do that is very simple, exactly the same way you did it the first time. (Remember?)
You just re-install Windows....Well, that is one way to do it, but it will take you a while. There are lots of faster ways...
|Keep GRUB and Make a Dedicated GRUB Partition
GRUB is more than just a boot loader, GRUB is also a boot manager and it's even almost a small operating system in it's own right.
GRUB doesn't need to be inside a Linux operating system for any reason, GRUB can stand on it's own two feet! GRUB only needs a small partition and can live on its own.
Actually, it is FAR BETTER to use GRUB as your 'third party boot manager' if you are setting up a Windows-Windows dual boot than to let Windows do it the Windows default way, read this website to find out why, Understanding MultiBooting and Booting Windows from an Extended Partition.
So if you have read all that you'll understand why you should keep GRUB, even if you are giving up on Linux.
All you need to do is delete all the other directories and files from your Ubuntu operating system except for the /boot directory. Just leave that there and your computer will continue to boot with GRUB as normal. You can use any partition editor, such as GParted -- LiveCD to resize the partition as small as possible. GRUB doesn't require very much hard disk space at all.
You will be able to edit the /boot/grub/menu.lst file from a Linux Live CD and modify it in any way you please. This might be the simplest and easiest solution of all.
|Windows XP 'Recovery Console'
Just put in your Windows XP install CD, and boot into the Windows XP Recovery Console and use the so-called 'FIXMBR' command.
|Replace GRUB in MBR with ms-sys
UPDATE: This won't work with the latest versions of Ubuntu.
I am told that ms-sys is no longer in the repositories but it has been replaced with mbr instead.
Thanks to audiomick for letting me know.
If you have an older version of Ubuntu this is an quick and easy solution. Thanks to meierfra for letting me know about this one, here is a link to meierfra's post in Ubuntu Web Forums about it, #326.
Before you run ms-sys, you will probably want to check first and see which hard disk is which, so you can work on the right MBR, run 'sudo fdisk -lu' for that,
Here are some links for more information on ms-sys,
ms-sys - sourceforge.
ms-sys - Freshmeat.
ms-sys Linux man page (die.net).
Windows 98 Floppy Disk Method
I have used this method to restore the bootsector on both my Windows XP Home Edition computer and also my Windows 98SE computer.
Your computer may have come with a Windows XP 'Recovery Disk' instead of an 'Install' disk, or maybe you lost your Windows XP CD or have Windows 98 or some other version.
You can download a self extracting file to make your own Windows 98 boot floppy disk from Bootdisk.com. The one I use is called 98SE OEM.
To make the boot disk, once the boot98se WinImage Self Extractor file is downloaded, place a formatted floppy in the floppy drive and then just double-click on the file. I it will make a boot floppy automatically.
A Windows 98 boot floppy will work just as well as an install CD to restore your 'boot sector'.
You must first of course have your computer's BIOS set to boot from the floppy disk drive before the hard disk in the BIOS boot sequence. See this website's BIOS Page.
Just pop the floppy in the drive and boot your computer. You will soon see a black background in your monitor and will be given three choices.
After a few minutes, you will see a prompt that looks like this,
After the A:\_ prompt and type the command fdisk /mbr and wait for the command to work.
Your 'boot sector' will be pointing to Windows again.
Vista and Windows 7 Recovery CD Method
If you have Windows Vista but you don't have any Windows Vista Installation disc you can go download a 'Vista Recovery CD'.
See lswest's and bodhi.zazen's thread, HOW-TO restoring XP and Vista Bootloader & Restoring GRUB
lswest links you to a site where you can download your very own Windows Vista Recovery CD if you don't have one, (if your Windows system is genuine and validated), and give you the commands for setting your hard disk's MBR to boot Windows and restore the Windows boot sector too, for Vista and XP.
lswest also tells you how to restore GRUB.
bodhi.zazen chimes in and tells us how to restore Windows boot loaders from Linux, (without the need for a large download).
Restore your MBR from a backup
If you planned ahead enough to have already made a back-up copy of your previous MBR, you can just restore it if you like. You can use any LiveCD to make a backup of your bootloader's IPL from your MBR and restore it again later, this is explained in step-by-step detail in another page, Back up and Restore your MBR.
Vista and Windows 7 users especially should make a backup of the first 466 bytes of their MBR, as that includes the unique 'Disk Identifier' that the BCD boot loader depends on.
|Super Grub Disk has a feature that installs Windows bootloader code to MBR faster and easier than any other way I have tried yet. (No knowledge or skill necessary). Super Grub Disk Page|
MbrFix.exe is a useful tool for professionals or serious hobbyists, it works for Windows XP and Vista. It can do a whole list of other neat operations as well.
From a working Windows System:
1) Download a small utility called MbrFix.exe here, http://www.sysint.no/en/Download.aspx
Read all about MbrFix.exe here, http://www.sysint.no/nedlasting/mbrfix.htm
2) Paste the file to the root of drive C:
If you don't know what I mean by 'the root of drive C, just open in 'My Computer, Click on Local Disk (C:), open it, and paste MbrFix.exe.there.
3) Click 'Start'->'Run', type CMD (for a Command Prompt).
The command prompt will at first be something like,
Change it to just a C: prompt by typing: cd \ , then press 'Enter'.
After that you should just have a plain C:\>_ prompt.
Type this command after the C:\> prompt: MbrFix /drive 0 fixmbr /yes
Nothing much will appear to happen, your monitor may blink slightly, that's all. You will see the plain C:\>_ prompt again. Type 'exit'.
4) That's it! Reboot to see if it worked.
EXTRA: Emergency procedure
If all else fails and you are really stuck and Windows won't boot in the first place in order for you to even use MbrFix.exe, download MbrFix.exe in Linux and just paste it into the root of Windows partition. A Birds's eye view of Windows XP. (showing the bootloader files).
If you have the FAT32 file system in Windows it is safe to do that from any Linux.
If you have the Ubuntu Gutsy Gibbon or later it is safe to write to an NTFS file system.
It is not recommended to write to NTFS from Feisty or earlier versions of Ubuntu unless you have special software installed for that in Linux.
Windows NTFS Partitions Read/write support made easy in Ubuntu Feisty - UbuntuGeek
Then go to this page and download a boot disk with NTLDR, NTDetect.com and boot.ini on it, http://tinyempire.com/notes/ntldr that will boot Windows for you almost no matter what!
When Windows has booted you can run MbrFix.exe as shown above.
|GAG Boot Manager
Rather than put simply put plain old Windows IPL back in your 'boot sector', another thing you should consider is whether to upgrade and install GAG Boot Manager to your MBR instead. GAG Boot Manager will boot Windows and do lots more as well. You could easily install GAG to MBR to overwrite GRUB. GAG Boot Manager can boot up to nine operating systems and it installs to the first track of your hard drive and overwrites any viruses that might be lurking there. It's a good idea to have that normally vacant space filled.
STEP TWO, DELETE THE LINUX PARTITION
Deleting the Linux partition is the easy part. Just delete the partition.
You should be able to use any partitioning software for that. My favorite partitioning software is GParted LiveCD, in case you don't already have something.
You should always make a backup of all your important data before using any disk partitioning software.
You can then do whatever you like with the resulting 'free space'. You might want to use the partitioning software to resize your Windows partition back to the original size, or create a new partition there for data storage. You might want to leave the free space alone and partition it later when you install some new operating system maybe.
Well normally deletion of the Linux partition is the easy part, (for most of us, most of the time), but ...
One person that I'm aware of has reported a serious problem after deleting her Ubuntu partition in this Ubuntu Web Forums thread, Issues Uninstalling Ubuntu. Djinn Effer used Windows XP Disc Manager and suffered a corrupted partition table and had to use run Active Partition Recovery 3.0 to recover her files.
If you experience a problem like that it might help other Windows users if you could add a post to the bottom of that thread. Please describe the problem you had uninstalling Ubuntu and mention what software you used to delete the partition.
I imagine this would be a 'one in a million' fluke. I would like to know if anything like that happens again, if so how likely is it?, and what to tell people so they can avoid any problems like that.
UPDATE: It seems that the Windows XP 'Disc Manager' produces more than it's fair share of corrupted partition tables. I don't recommend the use of Windows XP's 'Disc Manager'.
It is my belief that it is probably best to stick with a GNU libparted based partitioner.
I use and recommend the 'Parted family of disc partitioners, such as Parted, Partman, GParted, QTParted or Gnome Partition Editor.
If you use some other brand, then it could be safer to stick with the brand you are used to. Keep in mind that Linux partitioners are designed to be Windows friendly.
Software designed only for Windows might not necessarily be Linux friendly.
If you ever really do get a corrupted partition table or mistakenly delete the wrong partition, I recommend TestDisk for recovering from that type of situation. TestDisk is in the GParted LiveCD. In case you don't know how to use TestDisk, (most people wouldn't, this isn't the type of software most people would need to use every day), I have an illustrated example page I made with a test computer. It shows a demonstration of how I used TestDisk to recover a deleted NTFS partition and recover all files. TestDisk Page