How to run Windows Server 2008 on Linux using KVM

From Virtuatopia
Revision as of 19:55, 4 September 2008 by Neil (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The purpose of this HowTo is to provide a quick guide to installing Windows Server 2008 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 this 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 Server 2008 installation DVD. If you do not already have the installation DVD you can download an evaluation ISO image from the Microsoft website.

Once you have the Windows Server 2008 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. Windows Server 2008 requires a minimum of 10Gb of disk space to install. Greater amounts of space are recommended to allow for installation of applications and data. The following qemu-img command creates a 17Gb disk image called win2008.img:

qemu-img create win2008.img 17G
Formating 'win2008.img', fmt=raw, size=17825792 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. Microsoft recommend a minimum of 1Gb of RAM for Windows Server 2008. In practice the operating system will function with less. The following example allocated 850Mb 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 Server 2008 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 850 -cdrom /dev/sr1 -boot d /home/nas/win2008.img

When executed, the above command line will launch the virtual machine, display a graphical console and begin the installation process:

The Windows Server 2008 setup process running under KVM

Once installation is completed, Windows Server 2008 will start up automatically. To restart the system on future occasions run the following command:

qemu-kvm -m 850 win2008.img