Crash course: Virtualization with KVM on Ubuntu Server

Learn how to get KVM running on Ubuntu Server, install multiple guests, manage storage, and migrate guests to new hosts

KVM, the Linux kernel hypervisor, is the up-and-coming enterprise virtualization contender. It's lean, mean, fast, and runs unmodified guest operating systems with ease. In this crash course we'll quickly get KVM up and running on Ubuntu Server, install multiple guests, manage storage, and migrate guests to new hosts.

KVM and Ubuntu Server

KVM, which stands for "kernel-based virtual machine", was first developed by Qumranet. Red Hat bought Qumranet in 2008 and made KVM the core of Red Hat Enterprise Virtualization for Servers. KVM is licensed under the GPL and is part of the mainline kernel, so any Linux distribution can support it. KVM is a Type 2 hypervisor, which means it runs inside an operating system. Some popular Type 2 hypervisors are Xen and VirtualBox. Type 1 hypervisors, such as IBM's z/VM and VMWare ESXi, run on the bare metal and don't need operating systems. KVM supports pretty much any guest operating systems: Linux, Mac OS X, Unix, Windows, and whatever else you have lying around.

Ubuntu Server, like KVM, is growing into an enterprise powerhouse. Ubuntu supports KVM on x86 and x86_64. Unlike Red Hat and Novell, the big two enterprise Linux vendors, you can download and test Ubuntu without having to register or wade through sales pitches. If you want training, commercial support, or online services like the Landscape systems manager or Ubuntu cloud services, they're there when you want them.

System requirements

For this crash course you'll need an Ubuntu computer with an Intel VT or AMD-V CPU, because these include special extensions for native support of virtual machines.(See KVM's CPU support page for more information.) I'm using 11.04, Natty Narwhal 64-bit for this article. I recommend using Ubuntu Server for your production KVM server, but for testing, any Ubuntu will do. Use this command to see if your x86 CPU has virtualization extensions:

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

This example shows a dual-core Intel CPU with virtualization support. You'll probably have to enable the virtualization extensions in your system BIOS. Make sure this is enabled or KVM will not work.

You can run 32- or 64-bit guests on a 64-bit system, but you can run only 32-bit guests on a 32-bit system. Lots of memory is good, and so are multi-core CPUs. Ubuntu Server is frugal of system resources, which leaves more for your virtual guests. The minimum Ubuntu Server system requirements are a 300 MHz processor, 128 MB RAM, and 1 GB hard drive space. That is very minimal. For testing KVM, I recommend a minimum 2 GHz CPU, 2 GB RAM, and enough disk space for your guest operating systems plus data storage. Provisioning a production server is a bit imprecise. If you just add up the system requirements of all your guests, you'll have an over-provisioned machine, unless your guests run at full-speed all the time. One of the benefits of virtual machines is using hardware more efficiently, because when one guest is idle another one is busy. If you under-provision and your server becomes overloaded, then you can move guests to different hosts. So you have a lot of wiggle room, and don't need to make it perfect from the start.

1 2 3 4 Page 1
ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon