Using Kernel-based Virtualization

Recently I stumbled upon KVM (for Kernel-based Virtual Machine) which allows you to leverage the virtualization features built into modern processors.

This blog entry got me started. I am running Ubuntu Gutsy Gibbon 7.10 on an AMD Athlon(tm) 64 X2 Dual Core Processor so I installed qemu and kvm, loaded the kernel module and created a disk image for my virtual machine:

sudo apt-get install qemu kvm
sudo modprobe kvm-amd
qemu-img create node1.img -f qcow2 6G

Next I added myself to the kvm group to access /dev/kvm. As an alternative you can temporarily loosen the permissions (sudo chmod 666 /dev/kvm) but don’t forget to fix that later on.
I grabbed the iso image of the server edition of Ubuntu 7.10 and was ready to boot the vm and start the installation:

kvm -m 750 -cdrom ubuntu-7.10-server-amd64.iso -boot d -std-vga node1.img

Wow! That was easy:

I installed Ubuntu just like on every other computer. Once the installation was done the automatic reboot failed as expected and I closed the qemu window and started it again (this time with only 500MB of RAM which is still plenty):

kvm -no-acpi -m 500 node1.img

I booted a fully running Ubuntu system – even networking automagically worked.

This looks like a great alternative to the bloated VMware server especially as it is extremly easy to just copy or move the virtual machines if you want to play with clustering for example.

Read more here and here (yes, you can also run Windows this way). Cool stuff!