Up and Running with KVM, Ubuntu Style: Part One

KVM, Red Hat's darling enterprise virtualization solution runs on Ubuntu. Let's not tell Red Hat.

You probably know that Red Hat purchased the company Qumranet (they developed KVM), that the Linux kernel contains KVM virtualization components and that KVM is open source software. But, did you know that KVM runs perfectly on non-Red Hat Linux? It does. This article series shows you how to successfully setup and run KVM on Ubuntu Server 8.04 LTS. Ubuntu has an excellent software packaging and delivery system (APT) and delivers performance that is a superb substrate on which to run virtual machines. Combining Ubuntu with KVM is a match made in Data Center heaven.

The term KVM might leave you a little confused, since its acronym stands for Kernel-based Virtual Machine. It is not a container or zone-type virtualization technology as the name would imply. KVM is a full virtualization solution for Linux. Full virtualization means that you can run a Windows guest operating system on your Linux host. In fact, you can run a variety of operating systems on it–not just Linux. KVM runs on 64-bit hardware and requires QEMU for virtual machine visualization. In other words, QEMU provides the familiar console interface with which you work with virtual machines (VMs).

The Basics

Before you launch into an apt-get frenzy, KVM has some prerequisites that you will want to understand. First, your CPU must be 64-bit and have the required virtualization extensions (AMD-V or Intel VT). Second, you have to enable the extensions using the system’s BIOS interface. Finally, you must have enough space for a few VMs in the form of local or network-attached storage.

Check your system with one of the following commands:

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

If you receive a 0, your system won’t support KVM but any other number means that it will.

If your system meets those basic requirements, you’re ready to start. For purposes of this demonstration, Ubuntu’s Long Term Support (LTS) server version 8.04 is used as the host operating system. Ubuntu 8.04 is a good choice because it is time-tested, stable and well supported by Canonical. You, of course, may use your favorite Ubuntu version with some variation in the packages and process.

Now, you’re ready to grab the packages and install your new KVM host system.

$ sudo aptitude install kvm libvirt-bin virt-viewer ubuntu-vm-builder bridge-utils

This string will download and install all of the KVM bits and dependencies you’ll need to use KVM. Depending on the Ubuntu version you chose, these package names might have changed. Additionally, you might have to download and install other packages to support KVM.

If you receive an error that QEMU can’t start, try the following kernel module unloads one-at-a-time until QEMU launches.

$ sudo modprobe -r vboxdrv

$ sudo modprobe -r kvm-intel

$ sudo modprobe -r kvm-amd

Virtual Machine Management

It’s easy to manage your KVM guests from a command line but you’ll still have to have a remote system running X to which you can export your display so that you can see and use the QEMU console. The graphical console is necessary for initial installation but beyond that you can connect to the guests remotely just as you would with any other virtualization solution.

To begin working your first virtual machine (VM), you’ll need to create a VM repository or location. For example, create /VM and place all of your VMs in that directory or filesystem. For each VM that you want to create, you’ll want to place it in a directory container. Your first VM is Ubuntu 10.04. Make a directory under /VM named, Ubuntu_10.04. This VM separation by directory helps you maintain a more organized VM environment. You have to make the VM’s container directory prior to creating the VM.

$ sudo mkdir /VM

$ sudo mkdir /VM/Ubuntu_10.04

Connect to your KVM host system.

$ ssh -X kvm_server

Login and use the simple command line to setup your first VM and send the QEMU console to your remote system. You might have to change some of the parameters to fit your system’s configuration.

$ sudo virt-install --name Ubuntu_10.04 --ram 512 --file=/VM/Ubuntu_10.04/DISK1.img --file-size=8 --network=bridge:vnet0 --vnc --os-type=linux --cdrom=/dev/hda

Starting install...
Creating domain...

A QEMU console appears on your remote system ready to install Ubuntu 10.04 from the hosts CD/DVD drive. See Figure 1. Note that the option, –cdrom= can point to an ISO image.

Figure 1: The QEMU Console Ready to Install an Ubuntu VM
Figure 1: The QEMU Console Ready to Install an Ubuntu VM

You can now install the system into the VM that you’ve created. To interact with your new system, use the QEMU console that you used for installation. If you disconnect from the VM console, you can reconnect to it via VNC or virt-viewer.

$ sudo virt-viewer Ubuntu_10.04

Or, using VNC, you have to know the VNC display number.

virsh vncdisplay Ubuntu_10.04

Connection to uri: qemu:///session

vncviewer &

KVM is a powerful virtualization technology and one that you’ll find useful for a variety of projects and applications. If you need help, Red Hat and Canonical offer commercial support but you can also find free information in the user communities on each site. KVM compares well in performance, support and flexibility with such better known full virtualization solutions such as VMware and Xen. Next time, in Part Two of this KVM series, you’ll take a deeper dive into VM management using virsh and other tools.

Comments on "Up and Running with KVM, Ubuntu Style: Part One"


Typo in 1st paragraph says the article is about ubuntu 8.04 LTS instead of 10.4 – can you change it? I almost skipped the article because of that.


I skipped down to the comments to see if anyone else said anything about the 8.04LTS thing… 8.04 is fairly old and honestly I wouldn’t see it used on any current projects… :/

If it is a tpyo, then fine… it needs changing…


kvm is NOT RHEV-H… Red Hat eventually promises to move the functionality of the Qumranet stuff into stock libvirt, but I don’t know what release it is planned for. IMHO it will be 3.x or beyond.

So… kvm is part of Linux now… it’s NOT just a Red Hat thing.

RHEV-H and the required .Net frontend called RHEV-M ARE ONLY Red Hat offerings (and they cost extra… different subscription pricing).


It is indeed Ubuntu 8.04 that I used. It is an LTS version. Remember, for production systems, you have to use something that is,
a) Stable
b) Supported

It’s nice to use the latest releases for your own dabbling but when it comes to prod, you’d better have a compelling reason for doing so or have a good resume ready. You’d be shocked at the number of enterprises that still use RHEL 3 and 4. Stability is key.


I know that KVM isn’t just Red Hat but Red Hat owns KVM via Qumranet. Only the kernel module bits are part of Linux now. I can’t speculate on the future of what Red Hat will do. Well, I guess I could but I would draw even more ire for that.


You don’t consider 10.04 LTS to be stable & supported?


O.K. IMHO, I didn’t hear khess describing any later version of Ubuntu — even any earlier version — of being inferior to 8.04. He just merely stated that 8.04 was stable, supported, and the version he intended to use for this example. The use of the libvirt doesn’t change in any way that dates his article for use on exclusively 8.04.
It doesn’t do much good to think it is going to fail on a later version of Ubuntu. If the installation does fail, post the differences you see, not just a basic, open-ended post identifying your lack of confidence.


@davdunc – Thanks, I should have said it so well.


So 32-bit systems are not supported by KVM? Even if both

egrep -c ‘(vmx|svm)’ /proc/cpuinfo
egrep -c ‘ lm ‘ /proc/cpuinfo

give non-zero values, I cannot install KVM on my 32-bit system?


@magda it is not about 32 bit or 64 bit.
It is just about presence of vmx or svm instruction set support by your processor and if you don’t have it that will not work.


@khess – Thanks for the great introduction.


I appreciate you sharing this blog post.Thanks Again. Really Cool.


I have not checked in here for a while because I thought it was getting boring, but the last few posts are great quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend :)


Definitely believe that which you said. Your favorite justification seemed to be on the net the simplest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just do not know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side effect , people could take a signal. Will probably be back to get more. Thanks


Gs6eGd Im grateful for the blog post.Really looking forward to read more. Keep writing.


Very couple of web-sites that occur to be detailed below, from our point of view are undoubtedly effectively worth checking out.


Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>