How to Install WinXP after Ubuntu with Gparted
WARNING: Believe it or not, it is actually easier to backup your data after installing Ubuntu, format the hard drive, install Windows, and then install Ubuntu afterwards because it has a hard drive repartitioner and boot manager (grub) included, while Windows does not. I would highly suggest you ignore this post if you don’t feel like dicking around with something that will take you longer to do and likely cause more headaches for you. But if you have all the time in the world, hell… you might even be unemployed… have at it!
Installing Ubuntu along side an already existing installation of Windows is pretty easy, thanks to the auto partitioning tool and the Grub boot manager that is included with the Ubuntu Install CD. But what if you wanted to install Windows on a computer after you’ve installed Ubuntu? Today you’re going to learn how to do that.
What you’ll need:
- A blank CD to burn an ISO file onto.
- A copy of your Ubuntu Live Installation CD.
- Plenty of free time and a sandwich.
Captain Obvious Waring: “Backup your Data before doing this!!”
First, download a copy of the Gparted Live CD ISO and burn it to a CD. The ISO image can be found here (scroll down and select the latest version. The latest version as of this writing is dated December 17, 2007. Here is a directly download link). To burn an ISO file with Ubuntu, simply right click on it and click “Open with CD/DVD creator”, then click Burn. After burning the ISO to a CD, restart your computer with the CD in the drive. If you have your BIOS boot order configured to boot from CD, the CD should load a menu presenting you with many options, as seen below (if not, do some googling to find out how to change your booting device order within your bios or via a hotkey during POST so it will boot from your CD-Rom drive first):

When the CD boots, you’ll be given a menu like the one shown above. You should go ahead and select the default option that is highlighted at the top of the menu. The other options in the list are for use if you have problems with the your video card, and need to use legacy drivers (try to Force VESA first if you have a video driver problem later). After selecting a menu item and pressing enter, Gparted will begin to load. At some point, this screen will appear:

Simply hit the Enter key to select US English default. Another screen will show up:

If you’re speaking English, then hitting the Enter key at this point will select it for you. Otherwise you’ll need to type the corresponding number to your language first, then press enter.
Once it’s finished loading, you’ll either be looking at a GUI (below), or be stuck at a command prompt with a complaint about your video card. If the latter happens, try again by selecting the Force VESA option from the main Gparted boot menu as mentioned earlier.
The GUI looks like this:

You’ll see the main Gparted application already loaded with a hard drive selected (Note: The hard drive it has selected may not be the one you want selected, if your system has more than one hard drive in it. Fortunately, hard drive size is shown in the hard drive selection button in the upper-right corner, and you can use it to tell different hard drives apart if you know which has what on it).
In the above example, the wide blue border box that contains the device name “/dev/sda1″ is the primary Linux ext3 partition, and all partitions present on the drive are graphically represented here. So we can see that we have a primary ext3 partition which contains Ubuntu, along with an extended swap partition that Ubuntu also needs to keep intact (highlighted with a red border). What we want to do is shrink the size of the primary ext3 partition, and then insert a new NTFS partition in place of the newly unallocated space. There will be cake at the end
Start by clicking on the ext3 partition (either the dark-blue box in this example, or from the partitions table listing just below it), and then click the “Resize/Move” button at the top. A new window will appear:

We see the entire ext3 partition here represented as a box, and in the background, you can see just behind the bottom edge of this new window that the partition we’re dealing with is also highlighted in gray. The used portion of this partition is represented by the yellow area in the box, and the available free space is represented by the white. What we want to do is free some of this white space up. Start by clicking on the arrow-looking handle on the right hand side of the box, and drag it toward the center, like this:

You’ll want to leave a little white left for Ubuntu to use, otherwise you may have free hard drive space problems next time you run it and be required to delete files. The gray area that is revealed on the right is going to become un-allocated space, which we’ll use for a new NTFS partition in just a moment. At this point, click the “Resize/Move” button in the lower right corner. You’ll see the changes you’ve made represented immediately, but this is just for visual reference. A “to-do list” will also appear at the bottom, queuing up changes as you go. They will not actually take effect until you click the Apply button at the top, which we don’t want to do just yet…

Next, we’ll click on the unallocated gray space which we created by shrinking our ext3 partition, and then click the “New” button.

This will show us the unallocated space represented in white. What we need to do here is tell Gparted that we want to create an NTFS partition here, and we can do that by clicking on the Filesystem drop-down menu, and selecting “ntfs” from the list (as shown above). Once this is done, you can click the “Add” button….

…and then click the Apply button at the top of the main Gparted window. It will probably take several minutes for the changes to apply and take effect (go eat a sandwich and watch some TV). Once finished, the system will need to be rebooted. Upon reboot, you’ll not see any difference in your startup on your Ubuntu system, other than your free hard drive space being reduced. Grub will load normally, and you’ll boot into your login screen as usual.
Now that we have an NTFS partition on the hard drive, we can begin to install Windows XP as you normally would by inserting the XP install CD and booting from it. (Here is a guide for installing XP, just for quick reference. Read the rest of this first).
At some point during the Windows XP install, you’ll get to a screen that is somewhat similar to this one:

I need to stress that your screen will look a little different (I couldn’t find a good enough screen shot online so I had to Gimp the one above to be somewhat more accurate to what we’re doing here. I’ll replace it with a better one tonight). This screen appears during the Windows XP install when it’s asking you to select a location for Windows XP to install itself. Chances are, you’ll see one partition on your screen that has the letters “NTFS” next to it. THAT partition is the one you just created after resizing one of the others and it’s where we want to install Windows. The ext3 partitions will also be listed here, but likely be listed as “Unknown” because Windows XP is incapable of reading ext3. DO NOT SELECT ANY OTHER PARTITION than the NTFS partition (there should only be one NTFS partition listed anyway).
You will want to select this NTFS partition and press enter. It will then ask you if you want to format it to FAT32 or NTFS, or make no changes to the partition. Select “Leave file system intact (no changes)”. Proceed with the rest of the install as usual.
After the installation is complete, your system will reboot and you’ll notice that your Grub menu is missing. In fact, you’ll notice you can’t access your Ubuntu system at all. “Oh crap!” you might say. Don’t worry. We’re about to repair the Grub menu, and then modify it so it will have an entry for your newly installed Windows partition as well.
Insert your Ubuntu Live CD and them immediately restart your computer (so as to boot from the Ubuntu CD). Once the Ubuntu Live environment is up and loaded, click Applications>Accessories>Terminal. At the prompt type:
- sudo grub
This will take you to a grub prompt that looks like this:
- grub>
At grub>. enter these commands:
- grub> find /boot/grub/stage1
This will return a location output, that will look something like “(hd0,1)”. Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands…also be sure to include the parenthesis).
- grub> root (hd0,1)
- grub> setup (hd0)
- grub> quit
What we’ve basically done here is restored grub. Unfortunately, the grub menu doesn’t have a Windows entry in it. You’ll find that when you reboot your computer, Ubuntu will load normally, but grub will not present you with an option to boot into Windows. We have to add that entry manually.
Now in Ubuntu, open another Terminal window like we did before. Now type:
- sudo fdisk -lu
You’ll get some output that looks like this:
username@username-laptop:~$ sudo fdisk -lu Disk /dev/sda: 60.0 GB, 60011642880 bytes 255 heads, 63 sectors/track, 7296 cylinders, total 117210240 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x994a994a Device Boot Start End Blocks Id System /dev/sda1 63 89048294 44524116 83 Linux /dev/sda2 89048295 92952089 1951897+ 5 Extended /dev/sda3 * 92952090 117210239 12129075 7 HPFS/NTFS /dev/sda5 89048358 92952089 1951866 82 Linux swap / Solaris username@username-laptop:~$
In the above example, the third partition in the list is the one containing our NTFS partition, and thus, Windows XP. We need to add an entry based upon this information to the grub menu so we can select it for booting. Still within Terminal, type the following:
- sudo gedit /boot/grub/menu.lst
This will open up your Grub configuration file. Scroll down to the bottom of it, and paste in the following text:
# This entry was added by username for a non-linux OS
# on /dev/sda3
title Microsoft Windows XP Home Edition
root (hd0,2)
savedefault
makeactive
chainloader +1
In the above text, note the “(hd0,2)“. This statement is based upon the NTFS partition being listed as the third on this hard drive. It says “Hard Drive 0, Partition 2″ which in human speak actually means “First hard drive, third partition.” If the fdisk -lu output had shown the NTFS partition listed as the second partition (for example) the notation would be “(hd0,1)”. If you had installed Windows XP on a separate hard drive, say a slave hard drive on the primary IDE/SATA channel, it would be listed as (hd1,0), which means “Second hard drive, first partition” in human speak. Modify your entry in the additional text above accordingly, paste it to the bottom of your menu.lst file in Gnome Text Editor, and then save the file.
When you reboot, Grub should now have a new entry which will list Windows XP as an option. Note that the text displayed for this option is based upon what you typed in the above text. You can modify it if you need to (for example, if you have the Professional version of XP, instead of the Home edition and you want it to say that).
And that’s it! Now get some sleep, we’ve had a long day.
April 18th, 2008 at 3:48 am
WOW!!!
THIS REALLY REALLY WOORKSS AND IT IS EZY
May 17th, 2008 at 10:35 pm
when I do find /boot/grub/stage1 I get:
Error 15: File not found
… what now?!?
May 17th, 2008 at 11:03 pm
Corvi,
A solution to the problem you’ve encountered can be found here:
http://ubuntuforums.org/showpost.php?p=4587202&postcount=9
May 25th, 2008 at 5:50 pm
It didn’t work for me.
I have a separate drive for XP. It’s a second SATA chained to the master, which is Ubuntu. It boots into Ubuntu fine, and I amended the file once to point to the actual disk with XP on sda1 = (hd0,0)
This didn’t work.
So I looked at the file in more detail and found that Ubuntu is listed as (hd0,0) - so i tried changing the ref to the XP disk to (hd1,0).
This didn’t work either.
Then I thought, well I will change the Ubuntu disk references to (hd1,0) as it’s actually on sdb1,2 and 5.
This gave me a menu of options to choose from (which is what I’m after), unfortunately none of the selections worked.
So I booted from the Live CD and changed the boot back to saying hd0,0 for ubuntu and hd1,0 for xp. I still cant boot into xp (even changing the bios to select that disk doesnt work), but at least ubuntu is working again.
Oh what fun. I have to say after 3 weeks trying to get this … system working properly and reinstate my xp data (stuck in an image file on an external disk - well its on my ubuntu desktop as well), i am beginning to get very bored with the whole thing.
May 28th, 2008 at 2:51 am
Everything worked fine until I got to entering sudo gedit /boot/grub/menu.lst. It says “cannot open display.”
Also, when I tried rebooting I can only get to a command prompt. I tried “startx” and it still will not open to the GUI.
Please help!!
May 29th, 2008 at 2:00 am
Cindy,
If I’m not mistaken, you are attempting to type “sudo gedit /boot/grub/menu.lst” while in a plain text terminal interface. Gedit is a graphical text editor, so if you are not operating within a GUI, it will not run.
You have two options:
1. Boot from an Ubuntu install CD into a Live CD environment, then run the command from there with the GUI up and running.
2. Use a text mode editor like nano, instead of gedit, to edit the file. If you opt for this option, I would recommend you read a little about using nano from this link:
https://help.ubuntu.com/community/Nano
Simply exchange the word “nano” for “gedit” in the above command and your config file should open (sudo nano /boot/grub/menu.lst). To save a file after editing, you can hit CTRL-O (which stands for “write out”). Then CTRL-X to quit nano.
Please let me know if you have further problems.
May 29th, 2008 at 2:01 am
Tiggsy,
I’ve started a thread about your particular problem on Ubuntu Forums. You are not the first to encounter this problem. View this link for some helpful advice:
http://ubuntuforums.org/showthread.php?t=807286
June 28th, 2008 at 8:53 pm
Hello,
Love this tutorial.
Everything works fine, until you use for example mrbooter
to choose a OS.
Is there existing a boot program to handle this?
June 29th, 2008 at 7:29 pm
GRUB, included with Ubuntu, should suit your purposes as it is designed to function as a boot manager. Installing a program such as Mr. Booter would overwrite GRUB, but because Mr. Booter functions not just with DOS and Windows, but also Linux, you should be able to configure it to boot Ubuntu for you, but I cannot instruct you on how to do this.
August 19th, 2008 at 4:06 am
Hi,
Can be able to use that on the Raid 5 Disks as well?
I am getting some strange errors.
raj
August 19th, 2008 at 8:53 am
It’s hard to say. I have very limited exposure to RAID. I would suspect everything would be seamless if you are running %100 hardware-based RAID. But if it’s software based, you will have problems.
August 30th, 2008 at 7:26 pm
I successfully created the NTFS partition, however when I go to install xp, it says “Unknown Disk ”
Any help please?
December 30th, 2008 at 4:32 am
Didnt work for me. I got to the step where I repartioned my HD with a ubuntu hardy livecd. I booted with xp pro sp3 cdrom-iso and
the setup started…but when it was finished oading all the drivers and stuff and should start the setup install I got the blue screen of death where it said that “a problem has been detected and windows has been shut down to prevent damage…STOP 0×0000007B….” I have a SATA-drive with ubuntu hardy installed and it has worked perfectly so I dont think it is something wrong with the hardware. only 2 weeks old computer. Should probably installed XP first, but what can I say…I dont wanna reinstall ubuntu and to be hounest I am not 100 % sure it would help me install XP either…Any suggestions? I have tried this iso on virtualbox on my ubuntu and installed xp there. It worked perfectly, but I want to dual boot. Could it be the achi enabled problem? It is strange cause the driver is on the unattended xp-iso…I dont want to disable achi (cause I cant do it in BIOS, I must download a program and flash the setting…compal notebook), but is there a way to test if it is an achi problem? Like in virtualbox or something? Or wouldnt it work cause Ubuntu takes care of the achi? Please help, cause I am lost here…
December 30th, 2008 at 4:54 am
@MisterMister:
By chance… is your installation of Ubuntu on an encrypted LVM partition? I once had a problem installing Windows on a system that had an encrypted Ubuntu install that I had intended to replace with Windows entirely. But for some reason it would crash the Windows Setup utility very quickly (you made it further than I did though so this might not be the case). I had to use gparted to remove all partitions before Windows setup would load properly. I don’t know why.
Part of me regrets writing this particular blog post because it is a very haphazard task that doesn’t work for everybody and so many different problems can arise. I am sorry for the trouble it has caused you, but on the bright side, your Ubuntu install didn’t crash.
Something you might consider trying is to use gParted (not the one that’s included on the Ubuntu live CD, but the actual gparted stand alone live CD) to size your ext3 root partition down to make space for a new NTFS (or whatever you want really) partition. Then move all the data you need to backup over to that partition…. depending on the hard drive space you have free, you might have to move some data, resize both partitions again (which would take a while), move more data… until you’re done…. but you know what…. this would be a huge waste of time.
To be frank, I wouldn’t waste my time doing this if I were you. You’d be more productive as a McDonalds employee saving money up for a second hard drive to install Windows on to (if HD free space is the issue). I recently upgraded my PC to a new 1 terabyte hard drive for about 80 bucks. Well worth the money.
I would backup my home folder, delete all partitions with gparted, install windows, install Ubuntu after that, then copy the backup of your home folder into your new home folder and work out minor kinks from there. Trust me, you’d spend far less time doing it this way. Less time than that if you were to purchase another hard drive.
Just my opinion.