How to create a Windows 2008 R2 image for Openstack with Virtio support

31 May 2012

I'm doing a project with openstack and the one thing that gave me headaches was trying to build a Windows 2008 R2 image. It seemed I couldn't get Virtio working properly. I suffered from malfunctioning drivers, bugs in kvm and blue screens of death. The biggest problem was KVM refusing to install to my virtio disk because it supposedely was not bootable. So if this sounds familiar, this is a step by step guide on how I got things working.

What we will need

  • A windows 2008 R2 ISO
  • A machine running the KVM Hypervisor
  • Virtio drivers

Building the image

First of all we will need to create an image to install the virtual machine into. Microsoft says 10 GB is the minimum, but I used 15 GB. Remember that this is not the final size of your virtual machine,once it is introduced into Nova Compute. Create a raw image called windows.virtio:

kvm-img create -f raw windows.virtio 15G

Now open virt-manager and create a new virtual machine:

  • Name your machine
  • Use ISO image and select your Windows 2008 R2 image
  • Select windows and windows 2008 in the dropdown menus
  • 2048 MB of memory
  • 2 cpu's
  • Configure network so you have internet
Now boot the machine and just install the image, the disk is set to IDE at the moment, but that's not really a problem.
  • After installing let it restart, after the restart shut it down again
  • Create a temporary image
  • kvm-img create -f raw dirtyhack.virtio 1G
    

  • Add hardware with virt-manager:
    • Disk drivers
      • Storage
      • File disk image (select dirtyhack.virtio)
      • set Device Type to Virtio
      • Mount the ISO with the driver you got from fedora projects in the CDrom station
    • Network card
      • Add a new network card to some interface (doesn't really matter what it connects to)
      • When selecting the card, change the hypervisor default to virtio
    • Boot the server again
    • In windows open the device manager
      • Press start
      • Type device manager
      • In device manager select the iSCSI driver
      • Install driver and browse to the CDrom and go into wlh>amd64
      • Click ok and the driver will be installed
      • Do the same for the network card, I had to use the drivers in the Windows 7 folder since windows couldn't detect the ones from the Wnet folder
    • Shut down the machine
    • Remove all hard drives from the machine in virt-manager
    • Add hardware, storage and add your original windows.virtio, but make sure you set the Device Type to virtio
  • Boot the machine
Congratulations, your machine has now the Virtio drivers. Just add your image to Glance and off you go.