Up and Running with KVM, Ubuntu Style: Part One

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.

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.

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.

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.

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

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.

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.

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62