Monday, August 13, 2012

Setting up Ubuntu on Ubuntu under KVM

This an initial installment on setting up and running multiple virtualised operating systems under Ubuntu on my home AMD based desktop machine.
Why do I want to do this?
  • I've used VMWare and Solaris 10 Zones (and some storage virtualisation on NetApp arrays) over the years but wanted to try out the state of the art in virtualisation in the x86 space
  • I have a project in mind that will likely be deployed into a multi-tier environment and I'd like an easy way to emulate this without buying more  hardware.
  • There are other things that can be tried out in a virtualised multi-host environment, including automated deployment in distributed environments and other fun activities.
  • Testing on multiple platforms/distributions should also be possible if the right guest operating systems are created
  • To get experience in managing virtualised environments - ie creating golden images, managing clones and overlays, starting up and shutting down groups of virtual hosts comprising an integrated system.
  • To determine how to perform configuration management of virtual OS images.
  • I wonder whether there is general value in running the majority of my computing out of a virtualised environment? If I blow something up, or something blows my system up, it's always nice to be able to revert to a previous snapshot of your environment without the time and hassle of going through a full reinstall. Since you can migrate running virtualised systems between hosts, it makes sense that you get a portable set of host(s) to put on a USB stick and take with you wherever you go. What would the limitations be, if any?
Presumably I'll get to some, all or more than the above points in separate posts.

Also, there are a number of different technologies to investigate (Amazon EC2, VMware, Xen, Parallels, LXC, VirtualBox, KVM and others) but I won't get through all of them, but rather focus on those that are non-commercial/FOSS, will probably be of most relevance to my project and available on my home hardware and OSes. So I'll start with KVM.


There are some official instructions for KVM here, but I've sourced information from a range of pages on the 'net.

To determine hardware support we need to see if the CPU on the machine supports the required instructions via:


egrep "flags.*:.*(svm|vmx)" /proc/cpuinfo

If anything prints from this command then the CPU provides the necessary support - but this doesn't imply you have set your BIOS to enable it. Check this now (probably under "Advanced CMOS Settings" or similar), or you will see strange results creating and starting images in the steps that follow.


There are also some software pre-requisites. KVM is already in the Linux kernel mainline from 2.6.25+. My desktop machine is on 3.2.x so should be fine for the kernel mode support.

We also need the user space components. You can get these via the Ubuntu Software Centre or:

sudo apt-get install qemu-kvm

This installs a number of packages, and gives you access to a number of command line tools:

kvm, kvm_stat, qemu-ga, qemu-i386, qemu-io, qemu-system-i386, qemu-system-x86_64, qemu-x86_64


From this point there are two ways to create the image:
  1. Build one from scratch (using ubuntu-vm-builder); or
  2. Build one from an ISO


No comments:

Post a Comment