Quick VM testing with OpenVZ

I’ve been running OpenVZ now on my T42 for a few weeks now, and its all going well. Certainly no complaints.  Basically the host is Debian Lenny and the two guests are also Debian Lenny; one as my asterisk server and the other is a small subversion server.

Recently I had a problem with a Debian Etch server I maintain for a client. The possible solution to my problem involved downloading and installing a new program. Of course, this new program seemed to want a lot of dependencies met. I started to apt-get these and when apt-get told me it might need to install 100MB+ of related packages, the alarm bells went off and I hit ctrl-c. A better solution would be to try this on a test Etch server … but I didn’t have one.

OpenVZ to the rescue. Basically I downloaded a Debian Etch template for OpenVZ, installed the program and its dependencies and basically worked out the solution to my problem.Sure you can do the same thing with other virtualisation technologies but the key advantages to me were just how quick it was to do everything;

Firstly the setup/install process is quick;

  • The example templates on the OpenVZ site are all relatively small (the Etch one is 112MB). A lot smaller than a CD or DVD install image.
  • To install the image takes a few seconds
  • I already had my notes for the handful of commands to create a VM, so I had the VM running and on an IP address on my LAN in a few minutes
  • Since the debian build is minimal, an apt-get update/upgrade is also very quick.

Another key factor that is not obvious is just how fast you can start and stop and restart a VM. There’s no hardware probing as the kernel boots since each VM has no kernel. The overhead is the startup time of the relevant startup scripts. In my test VMs it’s in the order of a few seconds to startup or shutdown. This is obviously handy when you’re testing something and you need to reboot several times.