Virtual machines software are rapidly gaining in popularity. Xen, VMwareand VirtualBox are all interesting solutions. However there is one that often gets overlooked : QEMU.

Mandriva 2007 and Knoppix 5.1.1 both running in Debian Etch

While QEMU is an impressive piece of software, it can still benefit from the use of tools like KVM or Kqemu, which will further enhance its performances. As much as the above mentioned tools are considered optional components of the QEMU virtual machine, they do enhance QEMU emulation speed to a near native level.

  • Preparation

KVM, as it relies on true hardware virtualization, is certainly the one that provides better added value. The only downside is that it requires a CPU with virtual capabilities.

To verify if you possess such a processor, check out the output of :

cat /proc/cpuinfo | grep flag
And look for either vmx or svm. If they show, then you can use KVM. Otherwise, Kqemu is your best option.

  • Starting with QEMU

For starter you will need QEMU :

sudo apt-get install qemu

And a few tools :

sudo apt-get install module-assistant build-essential

Plus the proverbial kernel-headers (or linux-headers starting with Debian Etch) :

sudo apt-get install linux-headers-$(uname -r)

Next, we take on the installation of KVM, so those who will rely on Kqemu can skip to the Kqemu accelerator section directly.

  • Hardware virtualization with KVM

For those about to use KVM, you must first install the userspace component (part of Debian’s Sid repository). Download the require package :


Then simply install it like that :

sudo dpkg -i kvm_12-1_i386.deb
Linux Kernel 2.6.20

The module component of KVM is also required. You can either compile it as an external module, or use the latest Linux kernel, 2.6.20, which includes KVM. If you wish to compile a kernel, simply take a look at this tutorial.

Linux Kernel 2.6.19.x and below

Those using a Linux kernel version 2.6.19.x (or below) will have to build the KVM as an external module. The procedure is rather straight forward.

kvm-source, which is part of the Debian Sid official repository, is the required package.

Download it :


Then install it :

sudo dpkg -i kvm-source_12-1_all.deb

At this point we can effectively compile the module (with module-assistant) :

cd /usr/src
sudo m-a prepare
sudo m-a a-i kvm

We now have everything needed to use KVM, just make sure you have the necessary rights to use it :

sudo adduser your_username kvm

You must of course use your own username instead of your_username. Then you’ll need to log out and log back in so the (permission) changes take effects.

Now that KVM is appropriately set up, you can proceed with installing an OS in QEMU.

First you must load the right module (either kvm-intel or kvm-amd depending on your CPU). For example, installing Debian Etch is done like that :

sudo modprobe kvm-intel

Then create an image for Etch to install (sort of a virtual hard drive) :

qemu-img create etch_qemu.qcow 4G

Now that we have a 4G “disk”, we can proceed with the actual installation. First download Etch netinstaller :


Then launch it :

kvm -hda etch_qemu.qcow -cdrom debian-testing-i386-netinst.iso -boot d -m 256

Once this virtual Etch is installed, you can run it like that :

kvm -hda etch_qemu.qcow -m 256
  • Kqemu accelerator

While Kqemu’s speed is not on par with KVM’s one, it certainly constitutes a worthwhile alternative. Fortunately, installing Kqemu is rather simple with the help of module-assistant :

sudo apt-get install kqemu-source
cd /usr/src
sudo m-a prepare
sudo m-a a-i kqemu

Kqemu is now installed. Before using QEMU, Kqemu needs to be set up (this process must be redone after a reboot) :

sudo modprobe kqemu
sudo mknod /dev/kqemu c 250 0
sudo chmod 666 /dev/kqemu

The rest works exactly like when using KVM, except using the qemucommand instead. Again let’s take Debian Etch as an example on how to install and run an OS :

qemu-img create etch_qemu.qcow 4G
qemu -hda etch_qemu.qcow -cdrom debian-testing-i386-netinst.iso -boot d -m 256
  • Tips about Virtual Computing

Unfortunately QEMU doesn’t take care of loading the required modules associated with either Kqemu or KVM. So make sure you do load the appropriate module (kqemu, kvm-intel or kvm-amd) before starting QEMU.

Instead of launching QEMU from the shell, you can also use qemu-launcher, as it will take care of everything :

sudo apt-get install qemu-launcher

Additionnaly, QEMU can run pre-built VMWARE images, of which you can find a great selection on VMWARE community site.

Some Linux distributions won’t work very well with KVM. For example, Ubuntu Edgy installer doesn’t support KVM, so you simply launch the installer with QEMU (without KVM) :

qemu -hda ubuntu_qemu.qcow -cdrom ubuntu-6.10-desktop.iso -boot d -m 256

Once you have it installed, Ubuntu can be run with KVM :

kvm -hda ubuntu_qemu.qcow -m 256