Install KVM on Ubuntu

Written by
Date: 2013-02-02 12:30:35 00:00

Kernel-based Virtual Machine (KVM) is a virtualization infrastructure for the Linux kernel. KVM requires a processor with hardware virtualization extension.

I am installing it on my home PC, because there are some services I prefer not to install in my main installation. Like apt-cacher, LAMP, squid, and other servers I like to play with. But I do not want them messing my Desktop PC configuration. I prefer to have them on one or more virtual machines.

Check your system for compatibility

First thing, is to be sure your hardware supports KVM. We will do that with kvm-ok command.

sudo apt-get install cpu-checker

And the run:

sudo kvm-ok

You should get something like this:

INFO: /dev/kvm exists
KVM acceleration can be used

You may also want to run:

egrep -c '(vmx|svm)' /proc/cpuinfo

If it returns 0, it means, your hardware does not support hardware virtualization. Any other number might be OK

It is probable that you will have to enable hardware virtualization from BIOS.

Install KVM

Once the hardware is ready it is as simple as:

sudo apt-get install qemu-kvm virt-manager ubuntu-virt-server

Then run:

sudo adduser `id -un` libvirtd

sudo adduser `id -un` kvm

Reboot your computer, and you are ready to start using KVM, and creating your first virtual machine