FAST Win7 KVM VirtIO{Disk-Net} Install

Posted by Ahmed Kamal // March 2nd, 2011 // Uncategorized

Everyone who has to use Windows, please let's at least keep it contained inside a virtual machine! In this article I'll demo how to "Install Windows7 over Ubuntu 11.04 Natty, using KVM with System Disk over VirtIO". Quoting the libvirt wiki "Virtio is a Linux standard for network and disk device drivers where just the guest's device driver "knows" it is running in a virtual environment, and cooperates with the hypervisor. This enables guests to get high performance network and disk operations, and gives most of the performance benefits of paravirtualization"

Here's a little convenience script to download virtio Windows drivers and launch virt-install to Install Windows. Copy/Paste this script into an empty folder, chmod +x it, and run it.

#!/bin/sh
WINISO=/path/to/win7.iso #Windows ISO
INSTALLDISK=win7virtio.img #Disk location. Can be LVM LV
VFD=http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-1.1.16.vfd
DRVRISO=http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-1.1.16.iso

[ -e $(basename $VFD) ] || wget $VFD
[ -e $(basename $DRVRISO) ] || wget $DRVRISO
[ -e $INSTALLDISK ] || qemu-img create $INSTALLDISK 30G

sudo virt-install -c qemu:///system --virt-type kvm --name win7virtio --ram 1024 --disk path="$INSTALLDISK",bus=virtio \
--disk $(basename $VFD),device=floppy --os-variant win7 --cdrom $(basename $DRVRISO) --cdrom "$WINISO" --vcpus 2

et voila Windows installer kicks in, we're greeted with the usual

Screenshot-win7virtio - Virt Viewer
Screenshot-win7virtio - Virt Viewer-1
Next the welcome screen, and agree on the license agreement (if you want!)
Screenshot-win7virtio - Virt Viewer-2

In this next screenshot, we see how Windows Installer does not see any "disks". This is because Windows now does not have any drivers for the virtio disk that we attached!
Screenshot-win7virtio - Virt Viewer-3

Let's fix that, clicking "Load Driver" and clicking OK, Windows starts reading the VFD virtual floppy image we attached, and detects the driver
Screenshot-win7virtio - Virt Viewer-3
Screenshot-win7virtio - Virt Viewer-5
Clicking Next, Windows can now see the virtio disk
Screenshot-win7virtio - Virt Viewer-5
Then it's business like usual
Screenshot-win7virtio - Virt Viewer-7
After installation completes, be sure to check the device manager and confirm the disk (and network) are both using optimized virtio drivers
DeviceManager

et voila, Windows in its full glory running over optimized virtio drivers. The only part that sucks is desktop VNC performance, something that I'll probably write about very soon :)

10 Responses to “FAST Win7 KVM VirtIO{Disk-Net} Install”

  1. sante says:

    Hi,

    this is a very interesting article. I did try to do the same on my maverick install.
    I had to stop beacuse of unsigned virtIo storage drivers?
    Am I missing something?

    Thanks

  2. admin says:

    Hi sante,
    The storage drivers are installed from that vfd early in the win7 installation process. I didn’t get unsigned warnings. Are you sure you’re using that vfd =>
    http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-1.1.16.vfd

    What happens if you accept installing it, does it work

  3. roland says:

    I guess the word is “burst of laughing”. Simply on the net somebody who is talking about my most secret ideas? You really manage to operate a fast KVM? HOW? To get back serious:
    – my base is also UBUNTU 11.04
    – via Virtual Box I am placing Content Management Systems and historical OS’s commencing with W but only as isles in a sea of UBU.
    My experience now is cruel slow working of KVM Qemu.
    How could I proceed
    – download kvm…..tar.bz2
    – expand it into htdocs of the existing apache
    – is there something to do with drivers
    – install it using mozi with localhost/kvmdirectory

  4. kim0 says:

    Hi Roland, Not really sure why you’re downloading kvm into apache and “mozi” is ? Care to please supply more detail ?

  5. roland says:

    mozi = mozilla firefox what I am using. I will use the clear expression Firefox.
    On the net I find files with extension …. kvm … tar bz….
    I am used to download eg Joomla with “tar xvfz ..tar.gz into “xampp/…/ htdocs .. This makes me do Joomla.
    The big question: how do I expand the kvm so it will work fast. I Think this could be done in 5 5 lines. I tried also kvm once and I managed to start work with it but but cruel slow. the machine says: kvm ist not loaded.

  6. Ziv says:

    OK, stupid question:
    Once you’ve installed it, how do you fire up that Win7 VM next time you need to use it?
    Don’t have much experience with qemu-kvm…

  7. kim0 says:

    Hi ziv, well it’s quite simple, just launch virt-manager and you should find the vm listed there, click it and click the power-on button that’s it

  8. Ziv says:

    OK, now I understand why I was having troubles…
    Let me give you a constructive critique
    When you wrote this “howto” you assumed one has all the required stuff upfront and didn’t even mention them, so I’d like to point out that prior to using this script you should make sure you have installed the following packages:
    libvirt-bin
    libvirt0
    virtinst
    virt-manager
    qemu-kvm

    this is for people like me, that didn’t think of it before and got in a lot of errors when trying to run the script and ever time had to solve a different dependency issue…
    ;-)

  9. Gary says:

    After I install the drivers, I can not continue because it says “No new Driver can be found, make sure the driver files are correct and located on the driver installation media”. I have been struggling with this issue. any help would be appreciated.

    Thanks!
    Gary

  10. kim0 says:

    Hey Gary, I see the iso has been updated, this is the new one

    http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-mm34.iso

    So update the script with that, hopefully it’ll work