May 21

Windows Server 2008, on Xen 4, on Debian 6

There’s not a lot of information on the net about this particular configuration so I thought I’d put a post together that gathers what information there is, what worked for me and what didn’t.

So the setup I used was:

  • A Core i7 based server
  • Debian 6.0.1 AMD64 (Squeeze)
  • Xen 4.0.1 (Debian packaged version)
  • Windows 2008r2 Standard Edition
  • GPLPV paravirtualized drivers for Vista/Win7/2008

I’m going to start at the beginning since that’s what I did.


Before you begin you’ll need to check that your processor supports virtualization extensions, and that these are enabled in your motherboards BIOS. If you have Linux on the machine (or can boot a Linux live cd) you can check for virtualization extensions in the following way:

cat /proc/cpuinfo

You are looking for vmx (for Intel processors) or svm (for AMD processors). One caveat is that if you;ve installed the Xen hypervisor already you may not see vmx or svm listed in /proc/cpuinfo. In this case you can run:

xm dmesg

Check for a line that looks something like

(XEN) HVM: VMX enabled

Okay, so assuming you’ve got virtualization extension support on your processor the rest of the hardware is pretty much up to you (and what the kernel will support).

Debian and Xen

This is fairly straightforward if you’ve installed any Linux distribution before. I had to do it the hard way, doing a bootstrap from Centos (as the server is in a datacentre somewhere and came with Centos as the only OS choice). The install should be as minimal as possible, you don’t really want much running on the host (dom0) system. The only notable thing about my setup was the partitioning:

/boot 256MB
/ 10GB
swap 8GB
LVM Volumegroup ManyGB

LVM makes managing guest disks quite straightforward and flexible.

Note: Debian 6 uses GRUB2 as its boot manager, the easiest way to ensure the OS you want to run is booted by default is to modify /etc/default/grub and modify the GRUB_DEFAULT line to the name (with quotes) of whatever entry you want to boot by default, then to run grub-update. You can check the names of the current GRUB entries in the file /boot/grub/grub.cfg

So once you’ve done your base Debian install, you’ll want to install Xen. The following should install most of what you need:

apt-get install xen-linux-system-2.6-xen-amd64 lvm2 bridge-utils genisoimage xen-qemu-dm

GRUB2 installed with Debian 6 knows about Xen and when you do the apt-get above your /boot/grub/grub.cfg should get updated automatically with new entries for your Xen hypervisor and appropriate kernel, if you want to make sure the update has happened just do a grub-update.

Okay so now you should be able to reboot and boot into your “Debian GNU/Linux, with Linux 2.6.32-5-xen-amd64 and XEN 4.0-amd64” or similar.

Once booted you should be able to do and see the following:

root@vmhost:~# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  6928     8     r-----    697.8

In my configuration I have a number of public IPs assigned to the machine which I can assign to the virtual machines. To enable this we need to tell Xen to use bridged networking. To do this you need to edit the file /etc/xen/xend-config.sxp and make sure to uncomment the line:

(network-script network-bridge)

Once you’ve done this you’ll need to restart xend (service xend restart) or restart the machine to bring the bridge up.

Windows VM, disks and DVDs

First you need some installation “media”. I wanted to install Windows 2008 from an MSDN dvd iso image. The first problem, how do I get the dvd image from the MSDN site with only text based browsers that don’t support Javascript? I started by logging into MSDN and going to the downloads section in my desktop browser (I used Chrome but you should be able to use any browser that allows you to see what requests are being made to the server). Open the Chrome developer pane (the easiest way to do this is just right mouse anywhere on the site and do “Inspect element”) and then go to the Network tab. Click the download link and you should see requests to a couple of URLs on the MSDN servers. The first is to a “default.aspx” click on this and you should see more information about the request. Copy the URL parameter, you should be able to use this with wget on your Xen host to fetch the dvd iso image.

Okay, so now we have the DVD image, we need a “disk” to install to. I partitioned my disk so that most of the disk was free for LVM. If you haven’t used LVM before it’s worth having a read about it now, the simplest set of commands to get LVM up and running are below (replace /dev/sdx4 with whatever device(s) you want to use for storing the virtual machine images on):

pvcreate /dev/sdx4
vgcreate vm-volgroup /dev/sdx4

Assuming you use the lines above you have an LVM volume group called vm-volgroup on which you can create logical volumes with a command something like:

lvcreate -L 60G -n windowstest-disk vm-volgroup

So the above will create a new 60GB logical volume called windowstest-disk on the vm-volgroup. A block device will be created for this volume and symbolic links made so you can easily access it. For example using the commands above you will end up with a link at /dev/vm-volgroup/windowstest-disk, which you can use in your configuration files to refer to the disk.

We also need one more block device, this is going to be a CD to install the PV drivers from. Grab the PV drivers installer from http://www.meadowcourt.org/downloads/ I used gplpv_Vista2008x64_0.11.0.238.msi

To create a cd image with the file on it, stick that file in folder on its own, then do the following:

genisoimage -o /opt/isos/win2k8drivers.iso drivers/

Xen VM Configuration

So we’ve now got all the block devices sorted out we need a configuration file for the machine. Here’s what I used:

name = 'windowstest'
kernel = '/usr/lib/xen-4.0/boot/hvmloader'
builder = 'hvm'
device_model = '/usr/lib/xen-4.0/bin/qemu-dm'
memory = 2048
shadow_memory = 8

# Choose a better mac address
vif = [ 'bridge=eth0, mac=00:11:22:33:44:55' ]

## The VM has the following block devices
#  - A boot disk with a single partition for the OS, swap, and programs
#  - The installation DVD
#  - The PV drivers CD
disk = [ 'phy:/dev/vm-vol/wintest-disk,hda,w',

# Boot from the DVD first


## Use VNC for the console.
vnclisten = ''


ne2000 = "0"

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Note: Do not use a maxmem definition in the configuration file. THIS WILL CAUSE YOUR DOM0 TO CRASH.

Okay, we should now be good to go.

Connecting to your Windows VM

So you’ll see in the configuration file above, the VNC server that is displaying the windowstest VM’s screen is bound to You can specify the Xen host’s external IP, however if it’s world viewable on the internet that may not be a good idea. Running it on localhost means that you have to use ssh to forward a port on your desktop machine to the local port on the Xen host. You can use putty to do this:

Port 5902 as we are using VNC screen 2

Putty Tunnel Added to the configuration for this ssh host

Connect and log into to the host, and the tunnel should be established.

Connecting to the ssh forwarded VNC port

Windows Installation and Paravirtualized Drivers

Once you are connected via VNC you can go through the Windows install as normal. Once this is done we want to install the GPLPV drivers. The drivers are test signed, this means that Windows will not boot with them unless we explicitly tell it to boot without signed drivers (which requires setting on every boot) or by enabling test mode. Test signing mode can be enabled permanently by opening a command line on the windows machine and typing the following:

bcdedit.exe /set TESTSIGNING ON

You will need to reboot the VM to enable test mode.

When the VM has rebooted and you’ve reconnected with VNC you can install the GPLPV drivers from the CD. The default install options should be fine. Rebooting the VM again after the drivers are installed should enable the PV drivers. Congratulations you’re done!

UPDATE: Signed PV drivers are now available take a look here: http://wiki.univention.de/index.php?title=Installing-signed-GPLPV-drivers


Skip to comment form

  1. cocoa117

    nice article. Thanx

    Why the vncviewer = 0?

  2. alm

    My VM host is headless so it doesn’t make much sense to try and start a vncviewer on it. However that’s the default so I didn’t really need it in the config.

    From the Xen docs:

    vncviewer: Connect to the VNC display after the domain is created
    vncviewer (default = 0)

  3. backtogeek

    How about creating a xen pv image instead of hvm based…. possible?

  4. Thatcher P

    Great help. It is the only modern config I could find.

    One problem I ran into was a missing xen-qemu-dm. Causing an error:

    Error: ‘NoneType’ object has no attribute ‘rfind’

    -> fixed by apt-get install xen-qemu-dm-4.0.


  5. nitmd

    I ran into an issue with the genisoimage command. When I put the drivers into a folder and run:
    genisoimage -o /opt/isos/win2k8drivers.iso drivers/
    I get an error:
    No such file or directory. Invalid node 'drivers/'
    I’ve read the man page for genisoimage, but I still have no idea what this error is trying to tell me. /opt/isos exists.

    Also wondering what the “hda” and “w” signify in the disk line, I’m not finding an answer. Are these always this way, or do they need to be adjusted?

    I’ve tried a couple setup methods for Server 2008, and while I can get a guest Debian install with no problem, every time I try to start windows it crashes the machine, and often for some reason deletes the cfg file. This is a newer opteron, so hardware isn’t AFAIK an issue.

  6. alm

    Hi, does the folder “drivers” exist and contain the files you want to put on the “cd”?

    hda = use this disk image/block device as the first disk
    w = this device should be writeable
    These options should probably be left as is, unless you need some very specific configuration.

    Hope this helps, sorry for the delayed reply.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>