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

Installing Xen 4 on Debian Lenny

Practice



Xen is a virtual machine hypervisor. It's one of the most promising ones, combining low performance overhead with zero cost of use.

I use Xen on servers based on Debian Lenny (Debian 5), since Squeeze is currently (as of February 2011) still in the sid stage, and I don't want to risk putting it into production.

In this article I'll describe how to install Xen version 4.0.1 (the latest at the time of publication) from scratch on a clean Debian machine. Actually, with a few minor tweaks, you can also upgrade from Xen 3.2-1, available via the Debian repositories, without losing functionality.

So, we have a freshly installed Lenny (Debian 5). I'll be working with the 64-bit version (amd64) netinst distribution. Actually this doesn't matter much — when using a 32-bit domain 0, the kernel names will simply change from amd64 to 686. The hypervisor itself doesn't care what kernel domain 0 runs under, so you can perfectly well use either 32-bit or 64-bit Debian.

You can read more about Xen on this same site (how-it.ru), in the articles under the Virtualization/Xen section. Here only the installation steps will be described.

1) Allow the apt system to work with backports.

Open the file /etc/apt/sources.list and bring it to the form shown below. Note the commented-out cdrom repository line and the uncommented source repository lines, as well as the last line — it's the one that allows Debian to use backports.

#
# deb cdrom:[Debian GNU/Linux 5.0.5 _Lenny_ - Official amd64 NETINST Binary-1 20100627-10:37]/ lenny main
#deb cdrom:[Debian GNU/Linux 5.0.5 _Lenny_ - Official amd64 NETINST Binary-1 20100627-10:37]/ lenny main

# Line commented out by installer because it failed to verify:
deb http://ftp.us.debian.org/debian/ lenny main
deb-src http://ftp.us.debian.org/debian/ lenny main

# Line commented out by installer because it failed to verify:
deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main

# Line commented out by installer because it failed to verify:
deb http://volatile.debian.org/debian-volatile lenny/volatile main
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main

deb http://backports.debian.org/debian-backports lenny-backports main

Add the file /etc/apt/preferences

# APT PINNING PREFERENCES
Package: *
Pin: release a=lenny-backports
Pin-Priority: 200

This file allows the operating system to update packages installed from backports, including kernels (otherwise their versions would be frozen).

2) Update the repositories

# aptitude update
# aptitude install debian-backports-keyring
# aptitude update

3) Install the software needed for comfortable work. This is up to you, but I prefer to install the following:

# aptitude install dnsutils mc less openssh-server

4) We'll be building Xen from source, so let's install everything needed for that ourselves.

# aptitude install bcc bin86 gawk bridge-utils iproute libcurl3 \
libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo \
texlive-latex-base texlive-latex-recommended texlive-fonts-extra \
texlive-fonts-recommended pciutils-dev mercurial build-essential \
make gcc libc6-dev zlib1g-dev python python-dev python-twisted \
libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev \
iasl libbz2-dev e2fslibs-dev git-core uuid-dev gcc-multilib

5) Download the Xen source code from the official site

# mkdir ~/xen
# cd xen
# wget http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
# tar -xzf xen-4.0.1.tar.gz

6) Build Xen

# cd xen-4.0.1
# make xen
# make tools

7) After compiling, we'll need to make a few changes to a couple of files

# cd dist/install/etc
# mv sysconfig default
# cd init.d
# nano xend
// (replace the string sysconfig with default everywhere)
# nano xendomains
// (replace sysconfig with default)

I used the built-in nano editor, but you can do this with any other editor, for example mcedit from the midnight commander (mc) package.

8) Run the installation procedure. It will copy the necessary files to the right places.

It's very important to do this before installing the 2.6.32 kernel (step 9), since otherwise you'll have to manually add a block to the grub-loader stating that we have a Xen bootloader.

# cd ~/xen/xen-4.0.1
# ./install.sh

9) Install the 2.6.32-bpo kernel from backports (currently bpo.5)

# aptitude install linux-headers-2.6.32-bpo.5-xen-amd64 module-assistant
# aptitude install linux-image-2.6.32-bpo.5-amd64 linux-image-2.6.32-bpo.5-xen-amd64

As I already mentioned above, I use a 64-bit kernel for domain 0. If you have a 32-bit Debian, then specify 686 instead of amd64.

10) Make changes to a couple of files so that xend can work with the hypervisor.

# nano /etc/fstab
// (add: none /proc/xen xenfs defaults 0 0 )
# nano /etc/modules
// (add 2 lines:)
blktab
xen-evtchn

11) So that the xend daemon and the xendomains utility start automatically - add them to the system's rc.d

# update-rc.d xend defaults 20
# update-rc.d xendomains defaults 22

12) Edit the xend config file, bringing it to the shape we need

# nano /etc/xen/xend-config.sxp

In my example - I allowed VNC to work from any IP (vnc-lister '0.0.0.0') and enabled the network card to work in bridge mode.

13) Reboot.

Let's reboot. If everything was done correctly - you'll first see the grub-loader, which will select the Xen 4.0.1 line by default, then the Xen hypervisor's messages, and finally - the Domain 0 kernel already booting.

To check that Xen is working - run the command

# xen list
Name ID Mem VCPUs State Time(s)
Domain-0 0 249 4 r----- 9525.4

If the domains are visible as in the example above - Xen is working and domain 0 can manage the hypervisor.

Configuration tips, as well as sample configs, are provided on this same site in the virtualization/Xen section.

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