How to run Windows XP on Linux using KVM
The purpose of this HowTo is to provide a quick guide to installing Windows XP as a virtualized guest operating system on Linux using KVM. It is assumed that the appropriate KVM packages are installed on your Linux system. Steps to achieve vary between Linux distributions so refer to the documentation for your platform for details on how to do this.
For the purposes of this tutorial you will need a copy of the Windows XP installation DVD and associated license key.
Once you have the Windows XP installation media the next task is create a disk image to contain the guest operating system. This can be created using the qemu-img tool. The following qemu-img command creates a 6Gb disk image called winxp.img:
qemu-img create winxp.img 6G Formating 'winxp.img', fmt=raw, size=6291456 kB
With the disk image complete the next task is to boot up a KVM virtual machine instance. A number of options need to be defined when invoking the qemu-kvm command to start the guest system. Firstly, the amount of memory to be assigned to the guest system must be defined using the -m flag. The following example allocated 512Mb of RAM. Feel free to increase this amount if you have sufficient memory on the host system. Secondly we need to specify the location of the CDROM drive containing the Windows XP installation media. In the example below the device is /dev/sr1. Once again the device name varies between Linux distributions so find the device name for your system and use it in place of /dev/sr1 below. Next the boot device needs to be defined using -boot. In the example below d is specified to indicate the CDROM drive. Finally, the disk image file created previously is specified:
qemu-kvm -usb -m 512 -cdrom /dev/sr1 -boot d /home/kvm/winxp.img
When executed, the above command line will launch the virtual machine, display a graphical console and begin the installation process:
Once installation is completed, Windows XP will start up automatically. To restart the system on future occasions run the following command:
qemu-kvm -m 512 winxp.img