KVM On Ubuntu - KVM Logo

Installing and Running KVM on Ubuntu 14.04 Part 1

I’ve been running my own servers for many years now but recently I’ve started to get the feeling that I could be doing a better job of it. I’ve played with virutalization a little both on the desktop and on real servers (I run a small VMware set up for work) but I’ve never translated that to a home virtualization system. I want to start virtualizing at home because I want to separate my personal servers and software development from my work software development. I could run another physical server but the machine that I have a the moment is quite lightly loaded so there’s really no good reason to run another physical. My virtualization of choice is KVM on Ubuntu and that is what this seven article series is about.

I started off with the (nutty) idea that I would try and run OpenStack. I was all set up to buy a small low power machine to act as the controller and network node and then use my existing machine as a compute node and I actually got as far as writing some install scripts for OpenStack to give me exactly the set up that I wanted. In the end though I came to the conclusion that it was far more complicated than I needed. It would have been cool but OpenStack is a quickly evolving project and I could see that I would be left behind with a difficult to maintain system. So what did I do… I retreated to running just KVM on Ubuntu which, at the end of the day, is really all I need.

This series of articles details how I installed KVM on Ubuntu initially on an old Dell PowerEdge 860 I had lying around gathering dust. The machine has a single, dual core, processor and a 4GB ram fitted, there are two network cards but I’ll only be using one as my real server (awkwardly) only has a single interface. I’m going to assume that you are starting with a fresh install of Ubuntu Server edition, I’m running 14.04.1 but this guide should work for any recent release, and that you have installed no additional packages. The hard drive is 160GB and partitioned as a single disk using LVM.

General Setup to Support KVM on Ubuntu

A lot of the commands I’ll be running at least initially require root privileges and rather than type sudo all the time I normally just “sudo su -” at the start of a session. If you see a command that requires root that doesn’t have sudo at the start that will be why. Generally su’ing to root is not considered good practice the choice is yours though.

First thing to do is install SSH so that you can shell into the machine (I’ll be using Putty as my main machine is a Window box). If you want to use certificate based login have a look at this article.

apt-get install ssh

Now you’ll want to just double check that your machine is actually suitable for virtualization use by running this command:

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

A value of 0 is not good news and means your processor doesn’t support VT-x extensions, values greater than 1 mean it does.

Alternatively you can use the kvm-ok command in the cpu-checker package which will give you a bit more information:

$ kvm-ok
INFO: /dev/kvm does not exist
HINT:   sudo modprobe kvm_intel
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
      and then hard poweroff/poweron your system
KVM acceleration can NOT be used

As you can see it’s a good job that I ran the kvm-ok check as I hadn’t realized VT-x was switched off in the BIOS of my server. I think there’s something wrong with the BIOS power system as I’ve fitted a new battery but it’s still losing settings. A quick re-boot and VT-x is enabled.

Editor Aside…

I’ve recently found myself using the nano editor at lot after years of using Emacs. If you want to use nano for editing configuration files in vrish (which I’ll be doing a lot of later) the easiest way to permanently configure it is by adding the following line to the bottom of your .bashrc file:

export EDITOR=/usr/bin/nano

The alternative is to use the system default which is probably Vi and I can never remember the keyboard commands for that.

In part 2 of installing KVM on Ubuntu I’ll configure the network. 

Resources

Posted in Linux, Virtualization and tagged , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *