Installing Windows XP As A KVM Guest On Ubuntu 8.10 Desktop

Version 1.0
Author: Falko Timme
Last edited 02/06/2009

There's a bug in virt-install and virt-manager on Ubuntu 8.10 that does not let you run Windows XP as a guest under KVM. During the Windows installation, the guest needs to be rebooted, and then you get the following error, and Windows XP refuses to boot: "A disk read error occured. Press Ctrl+Alt+Del to restart". This guide shows how you can solve the problem and install Windows XP as a KVM guest on Ubuntu 8.10.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

The procedure described here works only if you have virt-manager installed on the KVM host, not on a remote system. virt-manager doesn't support remote installations yet. This means you cannot use this procedure on a headless Ubuntu 8.10 KVM host.

The resulting Windows XP guest will use an image file for storage - with this procedure you cannot use hard drive partitions/LVM partitions for the storage of the guest.

I'm using the username administrator here - replace it with your own username.

I'm assuming that KVM is already installed (e.g. as shown here: Virtualization With KVM On Ubuntu 8.10).


2 Installing Virt-Manager/Virt-Viewer

Open a terminal and install virt-manager and virt-viewer:

sudo apt-get install virt-manager virt-viewer


3 Creating An ISO From The Windows XP CD

Insert the Windows XP CD into your CD drive. Then run the following command to create an ISO file (/home/winxp.iso) from it:

sudo dd if=/dev/cdrom of=/home/winxp.iso


4 Creating A Storage Image File For The Guest

Next we create an image file that will be used to store the guest. I will name the guest vm8, so the image file I create is /home/administrator/vm8.img, and it will be 12GB of size:

dd if=/dev/zero of=/home/administrator/vm8.img bs=1024k count=12000


5 Running KVM To Create The Guest

What we do next is we run the kvm command (instead of virt-manager) to create the Windows XP guest and abort the installation right after the Windows installer has formatted the hard drive. Afterwards, we can use virt-manager to complete the installation.

kvm -m 512 -cdrom /home/winxp.iso -boot d /home/administrator/vm8.img

A QEMU window will pop up with the Windows XP installer:

Select the hard drive to be used for the installation (that's the image file we've just created):

Then select Format the partition using the NTFS file system:

The partition is now being formatted. Right after the formatting has finished, close the QEMU window to stop the installation:

Share this page:

5 Comment(s)

Add comment


From: at: 2009-02-13 17:30:09

Is there a specific reason why you close the QEMU window after the formatting is complete?

From: Anonymous at: 2009-11-06 03:30:50

Contrary to the note in section 1, you CAN run virt-manager on a headless server.

On my Mac, I ran "xhost +my.server.ip".  Then "ssh -X my.server.ip".  Once there, "sudo apt-get install virt-manager".  This will install a bunch of stuff, including GTK libs and some supporting X apps, but it DOESNT actually require X, a Window Manager, or all the other X bloat you don't need if you aren't using the local monitor. 

Then make sure the DISPLAY variable is set: "echo $DISPLAY".  If not, set it: "export DISPLAY='my.mac.ip:0' ".  Then by just typing "sudo virt-manager" on the server (via the ssh session), virt-manager will RUN on the headless server, but DISPLAY on your Mac.

 This assumes you have X11 installed on the Mac.  If not, install it from the Leopard DVD.

 This should also work equally well on a PC, just use something like Putty and XMing to provide the SSH connection and an X Window (display) server on your PC.

Hope that tip helps someone out--managing KVM via command line was driving me nuts! 

From: Esa Häkkinen at: 2009-03-27 11:59:52

It's quite short window of time to close QEMU window after 1st formatting, just when You see that format bar filled 100% and when it disappears, click X on that exact moment!

 For me, it was inside about 1 second before "Setup is checking..." appears and install was doomed.

 I'm using LVM block devices & "<features><acpi/></features>" in domain xml config.

 This behavior is only seen in 32bit WinXP, not in Win2000 nor 64bit, at least not for me.

From: Anonymous at: 2010-02-25 20:07:44

I kept getting formatting errors when installing XP.  I ended up using:

anon@Whitney:/home/vm1$ qemu-img create -f qcow2 winxp.qcow2.img 9G 

to create a 9G disk image that was in the qcow2 format.

XP+KVM seemed to like this much better, and the added benefit is that it only uses the space it needs on the Linux filesystem.

(ls done after the install)

anon@Whitney:/home/vm1$ ls -alh
total 269M

-rw-r--r-- 1 anon anon 2.3G 2010-02-25 06:53 winxp.qcow2.img

Then I used the

anon@Whitney:/home/vm1$ qemu -localtime -no-acpi -cdrom /home/anon/Windows_XP_pro.iso  -m 512 -boot d /home/vm1/winxp.qcow2.img

To boot the VM with the image file, and my XP.iso (and use 512 MB of mem).


From: Nathan Kidd at: 2009-03-06 21:42:57

1. Reason to use

dd if=/dev/zero ...

is because it lets you easily compress the image later if wanted.

2. kvm won't boot a qcow2 image (but you should be able to convert afterward with

qemu-img convert ...