Install and use Debian Wheezy as Xen virtualization host

Earlier, I explained how to setup CentOS or RHEL as a KVM virtualization host. You can find that  explanation here. It also contains some basic terminology about virtualization which is also applicable for Xen. When talking about KVM, somehow, I immediately associate it with the Red Hat family just as when you talk about Xen, I associate it to Debian derivatives. So for this post, I’ll use Debian to install a host that will run Xen-VM’s by using paravirtualization.

Xen is a little different than KVM since it’s also offering paravirtualization. This is a variant on normal virtualization which requires a modified guest OS but doesn’t require the special virtualization extensions as with “normal” virtualization. When using paravirtualization, the hardware is not emulated to the guest OS and communication with the hardware is passing through the host. Performance for paravirtualization is usually higher since you can omit the emulated hardware layer.

In case you want to run an operating system on top of a Xen-host that is not modified for paravirtualization, you loose the benefits of paravirtualization and you do need the special extensions and hardware emulation. Xen is capable of doing both.

In Xen, terminology is similar to KVM. The only concept that’s new is that of domains. A VM or guest is called a domain. dom0 is the first domain and has control of the hardware so it can be considered as the “host” (although technically not 100% correct). domU is considered a domain without special hardware access (unprivileged).

The examples in this post were executed on a standard Debian Wheezy netinstall with only the SSH server and standard system utilities installed.

Storage consideration for your Xen domains

Xen supports saving the data of it’s domains on the dom0-filesystem. This means that the image of the guest is a regular file on the host. Another option is to use LVM and store the data of the guests on free space of a volume group. This means that we eliminate one intermediate file system and gain performance. Tests show that the performance difference can be huge.

For my test-setup, I create a boot, swap and LVM parition on the system and added the LVM parition to a volume group called vg_sys. On the VG, I made one logical volume: lv_root which contains the complete /-file system.

First we’ll check if we have free space in our volume group:

In case you don’t have LVM on your machine or you don’t have any free extends in your volume group, you can either add a physical volume or save the guest’s data as files on the file system of dom0.

Install domain0

The first thing to do is installing the packages that are necessary for Xen:

After the installation, we need to make sure that Xen is loading before we’re loading the Linux kernel in order to be able to use it. For that, we will move Xen higher than the kernel in the list that GRUB uses to construct it’s entries.

After renaming XX_linux_xen to a lower number than our kernel, we need to update GRUB, to generate a new menu, and reboot our machine.

During the boot, you will see that GRUB first loads Xen:


After the reboot, you can check if Xen was installed and executed successfull by executing the xm info command:

If something’s wrong and Xen is not loaded:

When everything is installed and running as it should:

Network preparation of dom0

Running guests without networking isn’t very useful so we need to prepare our host-system to provide some kind of networking to it’s virtual machines. Xen supports various methods (bridging, nat or routing). The most popular is bridging so we’ll prepare the system and setup a bridge to use with Xen. The standard name for the bridge used by Xen is xenbr0.

To configure the bridge, we need to change /etc/network/interfaces and move the IP information from our physical interface to the bridge (as with KVM). But first we need to install the package bridge-utils:

Now it’s time to change the network configuration.This is how my original /etc/network/interfaces looked like:

This is how the configuration looks like after adding the bridge:

As you can see, I changed eth0 from type static to manual and removed all it’s parameters. Those parameters plus the link between the bridge and the real physical interfaces were moved to the bridge.

After chaning the configuration, we need to load it and we can check if the bridge is now the owner of our IP-address:

Xen is using bridge xenbr0 by default so we don’t need to define that in the configuration. We do need to define which physical interface that bridge is using to avoind the following warning:

We can do that by adding it to /etc/xen/xend-config.sxp as mentioned in the warning.

/etc/xen/xend-config.sxp before the change:

/etc/xen/xend-config.sxp after the change:

After the change, we need to load the changed configuration by restarting xend:

Adding domU virtual machines

Now that our host or domain0 is completely ready to run virtual machines, we can start by installing the xen-tools package to be able to deploy or create domU’s:

Once the necessary packages are installed, we can create a new domain with the following command and arguments. In case you don’t want to use LVM to store the data of the guests, you should specify –dir=<location> to specify a location for the images and remove the –lvm=vg_sys parameter.

Once the creation is finished, you should see that there are two logical volumes added to the specified volume group. One for swap and a second for the file system:

Besides the logical volume, the command also created the config file for the domain in /etc/xen:

Start using the newly deployed virtual machine

Now that we prepared our domU (xenguest1), we can start using it by starting it. This is called creating the domain in Xen terminology:

To check which domains are active, we can list them:

Now that our newly created domain is started, we can just connect to it with SSH:

In case you want to stop a domain, you can issue shutdown to do a clean shutdown or destroy to kill the domain:

As you can see, getting up and running with Xen doesn’t take much effort. Offcourse Xen is a lot more that this minimal example. It’s for example possible to connect to the console of a running domain with VNC or to install a unmodified OS like WIndows. Maybe later, with more time, I’ll add those instructions here.

One thought on “Install and use Debian Wheezy as Xen virtualization host

Leave a Reply to Kitara Lagony Cancel reply

Your email address will not be published. Required fields are marked *