Qemu And Windows XP

Getting Started

The first thing we need is a virtual hard disk to install Windows XP onto. It’s a good idea to create a dedicated directory for your hard disk images. This can be anywhere – a separate partition is advisable if you have a large number of virtual machines though. This example creates a dedicated directory on the root of the filesystem, the ‘/vm’ directory.

$ sudo mkdir /vm 
$ sudo chown username:group /vm 
$ cd /vm

Creating a disk image

The command below creates a compressed disk image will has a maximum capacity of 8GB. Therefore, if you only have 5GB of data stored in your disk image, then the image will only be 5GB in size.

$ qemu-img create -f cow WinXP.cow 8G

Newer versions of QEMU now support compressed cow images (qcow). These uncompress on the fly as the emulator is running so take up less disk space.

$ qemu-img create -f qcow WinXP.qcow 8G

It is also possible to convert an image created as a non-cow or non-qcow to cow or qcow later using the same tool.

$ qemu-img convert someimage.img -O qcow somenewimage.qcow

The install

To start QEMU 0.7.2 and below for an install of Windows XP use the following to boot off your CD-ROM, once you have put the Windows XP CD in your CD drive of course ;-)

$ qemu -cdrom /dev/cdrom -hda /vm/WinXP.img -boot d -user-net -m 384 -localtime

The same command for QEMU 0.8.0 and above is as follows.

$ qemu -cdrom /dev/cdrom -hda /vm/WinXP.img -boot d -net nic -net user -m 384 -localtime

This boots Qemu from CD, using the hard disk image we created earlier, emulated NE2000 PCI network adpater and networking support, 384MB of RAM and time is synced with the host OS.

Qemu essential parameters

To understand what the command above is doing here is an extract from the Qemu man page for the essential parameters.

-cdrom filename
Use filename as CD-ROM image. You can use the host CD-ROM by using /dev/cdrom as filename.
-hda filename

Use file as hard disk 0, 1, 2 or 3 image

-boot [x]

Boot from floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is the default.

-m megs

Set virtual RAM size to megs megabytes. Default is 128 MB.


(QEMU 0.7.2 and below)

Use the user mode network stack. This is the default if no tun/tap network init script is found.

-net nic -net user

(QEMU 0.8.0 and above)

Use the user mode network stack.


(QEMU 0.7.2 and below)

The SB16 emulation is disabled by default as it may give problems with Windows. You can enable it manually with this option.

-soundhw all

(QEMU 0.8.0 and above)

This enables Soundblaster 16 and ENSONIQ AudioPCI ES1370 audio emulation. Note: This also requires an environment variable ‘QEMU_AUDIO_DRV’ to be set to one of ‘oss/sdl’.

-k en-gb

Sets the keyboard locale.

Booting Windows XP in Qemu

Once the Windows XP installation has finished you can boot QEMU 0.7.2 and below with Windows XP using…

$ qemu /vm/WinXP.img -boot c -user-net -m 384 -localtime

..and the same for QEMU 0.8.0..

$ qemu /vm/WinXP.img -boot c -net nic -net user -m 384 -localtime

All we have done here is change the boot device.

See Also

Leave a Reply