Using libvirt with Xen on Debian Lenny

So it seems that my CentOS 5 Dom0 wasn’t stable. When building new virtual machines, the machine would hang and I’ve have to go back into the machine room to reboot it.

I have suspicions that it was due to the 3ware 8006 RAID controller, but instead of messing around with that, I’ve installed Debian Lenny as the Dom0 (using kernel 2.6.26 as opposed to kernel 2.6.18 with CentOS).

With this machine, I wanted to find the best way to support both Debian and CentOS machine, using a common method of installation. There seem to be two main ways to accomplish this.

You could use the (older) Debian route and use xen-create-image from xen-tools, which does a bootstrap of the OS on the filesystem, or use the newer virt-install from libvirt, to do an actual OS install. Libvirt seems like it’s the preferred method these days, which many of the distro’s now using for managing virtual machines using Xen, KVM or QEMU.

Using xen-create-image for Debian virtual machines has worked for me for a long time, but trying to use it for CentOS failed. The machine built, but I believe there were some packages missing from the install. I really didn’t want to have to mess around with the package lists, so I tried to use both xen-create-image for Debian and virt-install for CentOS. One problem with this is that virt-install doesn’t install the Xen config files into /etc/xen like the other tools do. Instead, it manages its own list, and contacts Xen directly using a Unix socket.

This would make management a pain, because you would have to use xm create <domain>to start a Debian VM, but then use virsh start <domain> for CentOS. I needed something simpler.

Then I discovered that Debian Lenny now has para-virtualisation support built into the Debian Installer.

This means that I could use virt-install to build Debian Lenny virtual machines, using the actual Debian installer.

With a quick install of the libvirt packages in the Debian Lenny’s repository:

apt-get install libvirt-bin virtinst

You’ve got all the libvirt stuff you need. Then, to create a Debian virtual machine using virt-install:

virt-install \
--name=debian-test \
--ram=512 \
--file-size=8 \
--nographics \
--paravirt \
--file=/var/lib/xen/images/debian-test.img \
--location=http://mirrors.uwa.edu.au/debian/dists/lenny/main/installer-i386

The important part is that last line. You can actually just throw a path to the install images of a Debian mirror, and virt-install is smart enough to boot a new VM from that. This then begins a Debian install, identical to what you would use on a standard machine. This also gives you full access to use the nice virt-manager. You can install virt-manager by doing:

apt-get install virt-manager

virt-manager

virt-manager running on a Debian Lenny Dom0

So I just need to remember now that if I want to start a VM, I need to use virsh start <domain>

Although, once started, you can use the standard xm tools.

So finally, I have reached open-source para-virtualisation nirvana. Now if only Debian did Kickstart…

Posted in Personal by Andy Botting at April 2nd, 2009.

4 Responses to “Using libvirt with Xen on Debian Lenny”

  1. Brizzy says:

    wow. Ive studied advanced pathophysiology of the human body, and I thought that was a bitch to understand… I stand corrected!

  2. Enrique Zanardi says:

    You’ve said “Now if only Debian did Kickstart…”. We’ll it has something similar:
    http://wiki.debian.org/DebianInstaller/Preseed

  3. David says:

    Great article! But didn’t you have problems with networking during lenny install on your VM? Mine had problems right after selecting the repository. Do you know how to solve that? Thanks. And Happy New Year!

  4. Andy Botting says:

    Can’t say I had any network problems in the VM. Does it get an IP address with DHCP, or are you specifiying one manually? Proxy maybe?

Leave a Reply


− five = 4