How to install KVM on Ubuntu 14.04

KVM (Kernel-based Virtual Machine) is a virtualization extension for the Linux Kernel. KVM requires a processor with hardware virtualization support which we will check later in this tutorial. There are many Operating systems that are supported by KVM, which include Linux, BSD, Solaris, Windows and others. It also supports Android 2.2, GNU/Hurd (Debian K16), Minix 3.1.2a, all of these work just with some limitations.

This tutorial explains the installation of KVM on an Ubuntu Desktop 14.04 and how to create a Ubuntu guest VM.

KVM Tools Installation

Before you proceed with the installation you must confirm that your system supports KVM. As mentioned earlier, it requires hardware virtualization support in the CPU. Type in the following command to check the compatibility:

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

If the output is 0, then KVM won't work as the system does not support VMX nor SVM hardware virtualization. If the output is 1 or greater than 1 it means your system is all set and ready to go for KVM installation.

Run the following commands to install KVM:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

The above command includes installation of 4 packages kvm, libvirt-bin, ubuntu-vm-builder and bridge-utils. You are done with the installation for now. Just make sure your Ubuntu username is addded to the group libvirtd by typing:

sudo adduser `id -un` libvirtd

In the next step, I will install a GUI tool for ubuntu which makes the process of setting up a VM easier.

Installing a graphical user interface for KVM

Install the virt-manager application with apt..

sudo apt-get install virt-manager

Creating a KVM guest machine

From here on, we will be using the GUI to work with as the setup of a VM with the terminal is quite difficult and takes too long for the setup.

After you have installed virt-manager just go ahead and start it by typing:

virt-manager

This should start the virtual manager application for you.



Then start with creating a new virtual machine by hitting the new button.



Enter the name of your virtual machine. Select your installation media type and click forward. After that, select the ISO image file that contains the operating system to be installed in the VM or select the CD/DVD-ROM to start the installation.



After the above step, you will have to set the amount RAM and CPU's that will be available to that virtual machine.



Finally, you will get a confirmation screen that shows the details of your virtual machine where you can select the advanced network options. I will use a NAT network here.

 



There you go you are done with your Virtual machine with KVM.

Share this page:

8 Comment(s)

Add comment

Comments

From: vcha

Wow, logged in to see if you have a HOWTO for KVM on Ubuntu 14.04 and you posted one today!

What I could really use, though, is instructions on managment from CLI. I rent a dedicated server that I would like to use it with

 

From: Spam

A few tips:

* ALWAYS manually create a bridge and use that instead of the built-in bridge created by libvirt

* virt-manager can be installed on any Linux workstation on the network. It can manage a VM-host from anywhere in the world, provided ssh access is working.

* Some of the defaults for new machines aren't clear - for most Linux distros, use virtio drivers for networking and disk controllers for the best performance and lower resource use.  TinyCore doesn't know virtio drivers, so treat it like Windows and go with SATA and E1000 drivers.

* If using file local storage for the VM "virtual disks", disable buffering. Also, manually creating empty qcow2 storage before creating the VM provides efficient storage use and very fast performance. qemu-img create -f qcow2 is the start of the command for this.

From: ronH

do you have any instructions of bridging the network.  

From: Gral Permon de la Fukka

* WHY always manually create a bridge? Please ALWAYS explain things with a reason, helps to understand if people do not want to simply obey, but want to understand.

Thanks!

From: vcha

@Spam. Thanks for this tips!

 

Also, I was getting some permission errors and KVM failed to initalized error. To fix this:

edit /etc/libvirt/qemu.conf change #group = "root" to group = "kvm"

From: Aaron

Thanks for posting this! Really appreciate it.

From: Michael Cooper

Hello, Nice artical, However where did you install virt-manager? On a Desktop client or the server?

 

Thanks,

Michael

From: Michael A Cooper

Here ya go Ron, I am sure you already got your answer but i have done this so many times it's in my memory now.

nano -c /etc/network/interfaces

You should see something like the following:

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.0.100 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1 dns-nameservers 8.8.8.8 8.8.4.4Change it to the following: # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 192.168.0.100 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 dns-nameservers 8.8.8.8 8.8.4.4 bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp offThen reboot and your system should be ready to go.I hope this helps.