You get a bonus - 1 coin for daily activity. Now you have 1 coin

Installing Xen 4 on Debian Squeeze

Practice



Debian 6 (Squeeze) has, as one of its features, built-in support for Xen 4 (at the time this article was published - 17.03.2011 - Xen 4.0.1-2). That's great - at the time Squeeze was released, this was the latest Xen version.

Whereas we used to have to build Xen ourselves for Debian 5 Lenny, in Squeeze you can get it done with less effort (both in number of keystrokes and in time) by installing the hypervisor from the repos (repositories).

So, let's get started (I'm using a 64-bit OS as the host system):

# aptitude install xen-hypervisor-4.0-amd64 xen-qemu-dm-4.0 libxenstore3.0 xen-docs-4.0 xen-tools xen-utils-4.0 xen-utils-common xenstore-utils xenwatch linux-headers-2.6.32-5-xen-amd64 linux-image-2.6.32-5-xen-amd64

This installs Xen, the kernel for Xen, and the utilities.

Grub (version 2, by the way) will configure itself, but Xen won't be selected as the default bootloader entry. But we need Xen to boot by default.

So, let's edit the grub config. Go to the /etc/grub.d directory and rename the file 20_linux_xen to 09_linux_xen, telling the configurator that we want the "Xen" menu entry to come first.

# cd /etc/grub.d
# mv 20_linux_xen 09_linux_xen

Now we need to rebuild the grub.cfg config (by the way, I strongly recommend against editing it directly - the very first bootloader-related update procedure will wipe out all your changes to grub.cfg).

# grub-mkconfig --output=/boot/grub/grub.cfg

Great, now after a reboot Xen will automatically load first, and only then domain 0.

Now let's edit Xen's system configs. You can find them at:

/etc/xen/xend-config.sxp

In particular, you need to specify the network model (I use a bridge, so I uncomment the line "(network-script network-bridge)") and, if you're going to use HVM machines (and you most likely are, even if you plan to convert those machines to paravirtualized later) - uncomment the line "(vnc-listen '127.0.0.1')" and change 127.0.0.1 to 0.0.0.0 so that Xen's VNC server can accept connections from any computer.

You can read more about Xen, its settings, etc. on the internet or on this site.

Let's reboot.


The TAP problem.

Everything would be fine — Xen is built into Squeeze, everyone's happy... except the creators of Squeeze made one teeny-tiny mistake: they forgot to include one file with Xen, without which our beloved TAP interface (tap:aio:) won't work. When you start the (guest) machine, Xen will hang, and after a few minutes it will throw an error along the lines of "I can't attach the tap interface via hot-plug." To fix this, you need to create a file called hotplugpath.sh in the /etc/xen/scripts directory with the following contents:

SBINDIR="/usr/sbin"
BINDIR="/usr/bin"
LIBEXEC="/usr/lib/xen/bin"
LIBDIR="/usr/lib64"
SHAREDIR="/usr/share"
PRIVATE_BINDIR="/usr/lib64/xen/bin"
XENFIRMWAREDIR="/usr/lib/xen/boot"
XEN_CONFIG_DIR="/etc/xen"
XEN_SCRIPT_DIR="/etc/xen/scripts"

It's a small file, but without it TAP won't work. You also need to give this file execute permissions:

$ chmod +x hotplugpath.sh

Next, you need to add a couple of lines to the /etc/modules file:

# /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
loop
blktap
xen-evtchn

The last two lines were added separately.

Let's reboot. Now the TAP interface will work, which is nice.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "LINUX operating system"

Terms: LINUX operating system