To reformat (both) drives is not an answer; of course to remove Ubuntu (partitions) the way to go is to format the drive which has Ubuntu, but that would leave the user with an unusable bootloader (GRUB would not work after removing /boot), preventing the loading of XP.
The correct way:
1) restore XP bootloader. Either use Windows XP setup disc to boot into the XP startup menu, or if you have Recovery Console installed on your harddrive (in some cases it is), just press F8 right after you select to boot XP from Grub. Either way you should end up with having the Windows boot list on screen. Choose the option to enter the "recovery mode" or whatever it is; it's not "safe boot" but the other option, which enables you to jump into the XP Recovery Console. If you're unsure on how to get there, refer to XP documentation in the web of in manuals. If RC is installed on harddrive, you can enter it from the boot menu directly; if it's not, you'll need to get to the menu by booting from XP setup disc. Also if you have multiple harddrives/partitions, when asked during entering RC, choose the one which has your WinXP installed -- it is important to select the correct harddisk
. Just in case, it's a good idea to have a bootdisk for XP or XP setup cd available before continuing.
2) Once in Recovery Console, type the command fixmbr
to tell Windows to 'reset' the MBR (Main Boot Record; the first sector of your harddisk). In some cases you might have to run fixboot
too (there's documentation at microsoft.com about this); it does make a difference in which order you run these if you need to run both, but I'd start with 'fixmbr' only. NOTE
: if this fails, you need to have either XP setup disc or a regular boot disk to be able to boot your machine after this, and re-enter the Recovery Console. I'm not sure what causes it to fail sometimes (and force you to use 'fixboot' too, at least); I've succeeded in doing this with only running 'fixmbr' multiple times on a pc, and then suddenly failing with the same pc. Nevertheless it's a good idea to have a bootdisk before continuing. No data is lost if this won't work the first time, so don't worry; it's just that your bootloader is erased, and you are unable to boot without a boot diskette -- to get into XP recovery console you need an XP bootdisk, to get in Linux you need a Linux bootdisk (or a live-cd).
3) Once you've run fixmbr
and RC tells you it has successfully rewrote MBR, type exit
to get out and reboot your machine. If everything went well, your XP should boot the usual way, without GRUB showing up. After this simply format your 2nd harddrive; this can be done, for example, using XP's system tools (My Computer -> Manage) or PartitionMagick or something else. Simply choose to remove all partitions from the other harddisk (where Ubuntu is) and format the whole disk; create new partitions as you like, if you need to.
4) This is only if you failed to run 'fixmbr', the command didn't do what it was supposed to and you ended up with either unusable GRUB, no bootloader at all or generally a message after boot saying 'unable to load OS'. First: don't panic
. Your data is safe, this problem is just the fact that you don't have a bootloader that could load your operating system(s). There are two ways to fix it: 1) having XP bootdisk of some kind, re-try running fixboot
, reboot and see if it helps. Also refer to Microsoft's website documentation about fixing 'broken MBR' or whatever it's called. I'll explain another method later below. 2) To get things running for a moment, you could simply run a Linux live-cd or an installer and install GRUB again; this lets you boot your XP, along with Linux, and you can access your Windows until you've figured another way out.
Another method to get MBR back to Windows: the MBR is the first sector of your harddisk (512 bytes). It's just data as anything else, so it can be copied from a harddisk and copied to a harddisk. The 512 bytes consists of 446 bytes (which is Windows bootloader, in this case) and the rest from 446 to 512 which is your partition information. You could, if you had a backup of your MBR, copy it back to the disk and have it fixed that way (actually I think this is what 'fixmbr' should do). Of course you now thing you don't have the backup
but..one way is to try and copy it off your buddy's XP-only-machine, and copy it on your own harddisk. In this case you shouldn't copy the whole 512 bytes as your buddy's partition information might not match yours
. Note that I've never tried this on my own machine, but it's easily tried, and if it doesn't work..well, you can continue with the Recovery Console: the MBR isn't any more or less fixed than it was before you copied data onto it, as long as you only deal with MBR. So, you could use a Linux live-cd to copy the 446 bytes from your buddy's harddisk's beginning using dd
, then move the file to an usb disc, use the live-cd at your own pc and then with dd
put the bytes to your own machine's MBR. Like this (here I assume the primary partition is the one with XP; use Linux live-cd to get access to dd without installing Linux; MBR_backup is the file which we need to move to your machine, with USB stick for example):
dd if=/dev/hda of=/MBR_backup bs=446 count=1
now move MBR_backup to an USB stick for example, or a cd (use rw to not consume full cd for a file less than half a kilobyte). Then boot a live Linux on your machine, and (again, if first harddisk hda is the one with your Windows aboard; if it's something else, change accordingly; also change the if= path to point to the full path of the file) copy the file back:
dd if=/MBR_backup of=/dev/hda bs=446 count=1
After this you might need to make sure XP's partition information is all right, so you could boot into the XP Recovery Console and run 'fixboot' which should deal with it. The partition information should also have a duplicate on the harddisk, just in case, so if either one of the two is inaccurate, XP should know to use the working one (but I'm not sure if it does). So, after this you try rebooting your machine and see if it works; if not, refer to Microsoft documentation (again).
Though I've written a lot in this post and it might sound complicated, I must say that I've put XP's bootloader back many times and have only failed once (and got it working after that); usually it's just as easy as getting into Recovery Console, running 'fixmbr' and rebooting. So don't worry.