bengreen.eu Circle Device

 

Quick Reference

Quick VMs with QEMU

This is a simple article on how to make vms quickly with QEMU. This is what we use at work to host all our VMs. This quick reference shows you how to do this with Windows 7 64bit (and virtio drivers) but you can do the same with other OSs. One note is that I have not had much luck with the Windows XP block virtio drivers... not that I have much use for Windows these days anyway ;-).

Create the VM image

qemu-img create -f qcow2 win764vm.img 500G

Boot the system with the non-virtio block drivers

The following command is actually all on the same line, in bash (and some other shells) the \ means ignore the \n and assume that this is all one line. Don't put anything except a new line after the \ it is an escape caracter, just like in a C or Java string.

qemu-system-x86_64 -enable-kvm -m 2048 -k en-gb \
 -cdrom windows7_64bit.iso -hda win764vm.img \
 -boot d \
 -net nic,model=virtio,macaddr=00:00:D1:C0:54:39 \
 -net tap,ifname=tap5,script=no,downscript=no

I will leave you to install Windows... and even the network device drivers. Available from Fedora, if you have problems with that link look at KVM website. Don't worry about the block drivers, I will cover those in a moment.

Next, create a new drive and set the configuration to the below:

qemu-system-x86_64 -enable-kvm \
        -k en-gb \
        -m 2048 \
        -net nic,model=virtio,macaddr=52:54:00:12:34:56 \
        -net tap,ifname=tap5,script=no,downscript=no \
        -hda win764vm.img \
        -drive file=tempvio.img,if=none,id=drive-virtio0 \
        -device virtio-blk-pci,drive=drive-virtio0,id=virtio-blk-pci0 \
        -boot c \
        -monitor tcp:127.0.0.1:5925,server,nowait \
        -qmp tcp:127.0.0.1:5945,server,nowait \
        -cdrom virtio-win-0.1-30.iso

virtio-win-0.1-30.iso is the driver image you downloaded from Fedora/RedHat.

In windows you should now be able to see SCSI controller and Ethernet Controller in device manager... picture to follow.

More pictres

When you have finished, Shutdown the machine and change your script... again!

qemu-system-x86_64 -enable-kvm \
        -k en-gb \
        -m 2048 \
        -net nic,model=virtio,macaddr=52:54:00:12:34:56 \
        -net tap,ifname=tap5,script=no,downscript=no \
        -drive file=win764vm.img,if=none,id=drive-virtio0 \
        -device virtio-blk-pci,drive=drive-virtio0,id=virtio-blk-pci0 \
        -monitor tcp:127.0.0.1:5925,server,nowait \
        -qmp tcp:127.0.0.1:5945,server,nowait

Needs improving!

Extending a QCOW2 Disk

To extend a qemu qcow2 disk, do this:
qemu-img resize virtualdisc.qcow2 300G

Quick Links: Techie Stuff | General | Personal | Quick Reference