The Perfect Xen 3.0.3 Setup For Debian Sarge - Page 2

4 Installing From The Sources

Run the following commands:

apt-get remove exim4 exim4-base lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig
apt-get install iproute bridge-utils python-twisted gcc-3.3 binutils make zlib1g-dev python-dev transfig bzip2 screen ssh debootstrap libcurl3-dev libncurses5-dev x-dev

 

4.1 Install Xen

Now we download xen-3.0.3_0-src.tgz from http://www.xensource.com/xen/downloads/dl_303tarballs.html and unpack it:

cd /usr/src
wget http://bits.xensource.com/oss-xen/release/3.0.3-0/src.tgz/xen-3.0.3_0-src.tgz
tar -xvzf xen-3.0.3_0-src.tgz

Then we compile Xen. This will create one Xen kernel (2.6.16.29-xen). We have to do this before we can create individual kernels for dom0 and domU. This can take a long time so be patient:

cd xen-3.0.3_0-src/
make world
make install
mv /lib/tls /lib/tls.disabled

Now Xen is installed. In order to start the Xen services at boot time, do the following:

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20

We need a ramdisk for our new Xen kernel, therefore we do the following:

depmod 2.6.16.29-xen

apt-get install libhtml-template-perl libparse-recdescent-perl

wget http://downloads.howtoforge.com/files/yaird_0.0.12-8bpo1_i386.deb
dpkg -i yaird_0.0.12-8bpo1_i386.deb

(The original yaird package was located in http://backports.org/debian/pool/main/y/yaird/, but was removed in the meantime, so I've made the package available under http://downloads.howtoforge.com/files/yaird_0.0.12-8bpo1_i386.deb.)

mkinitrd.yaird -o /boot/initrd.img-2.6.16.29-xen 2.6.16.29-xen

The last command creates the ramdisk /boot/initrd.img-2.6.16.29-xen.

Next we add our new kernel to Grub, our bootloader. Edit /boot/grub/menu.lst, and before the line ### BEGIN AUTOMAGIC KERNELS LIST add the following stanza:

vi /boot/grub/menu.lst

[...]
	  
title Xen 3.0.3 / XenLinux 2.6
root (hd0,0)
kernel /xen.gz  dom0_mem=64000
module /vmlinuz-2.6-xen root=/dev/hda6 ro max_loop=255
module /initrd.img-2.6.16.29-xen

[...]

Make sure that /dev/hda6 is your / partition. Keep in mind what I said about Grub and partitioning in chapter 1! I added max_loop=255 to the module line to make sure that enough loop devices are available because or virtual machines will be mounted as loop devices.

Now reboot the system:

shutdown -r now

At the boot prompt, Grub should now list Xen 3.0.3 / XenLinux 2.6 as the first kernel and boot it automatically. If your system comes up without problems, then everything is fine!

 

4.2 Compile A dom0 Kernel

Now we compile a dom0 kernel:

cd /usr/src/xen-3.0.3_0-src/
make linux-2.6-xen0-config CONFIGMODE=menuconfig KERNELS="linux-2.6-xen0"

In the kernel comfiguration menu that shows up we enable quota, iptables and the dummy network driver as modules. This is where you enable these modules:

File systems --> [*] Quota support
<M> Old quota format support
<M> Quota format v2 support

Device Drivers ---> Network device support ---> <M> Dummy net driver support

Networking ---> Networking options ---> [*] Network packet filtering (replaces ipchains) ---> Core Netfilter Configuration ---> <M> Netfilter Xtables support (required for ip_tables)

Networking ---> Networking options ---> [*] Network packet filtering (replaces ipchains) ---> IP: Netfilter Configuration ---> <M> IP tables support (required for filtering/masq/NAT)

[*] means: build into the kernel statically.
<M> means: build as a kernel module.

Next we build and install the dom0 kernel:

make linux-2.6-xen0-build
make linux-2.6-xen0-install
depmod 2.6.16.29-xen0

Next we add our new kernel to Grub, our bootloader. Edit /boot/grub/menu.lst, and before the line ### BEGIN AUTOMAGIC KERNELS LIST add the following stanza (please delete or comment out the stanza you added in chapter 4.1!):

vi /boot/grub/menu.lst

[...]
	  
title Xen 3.0.3 / XenLinux 2.6
root (hd0,0)
kernel /xen.gz  dom0_mem=64000
module /vmlinuz-2.6-xen0 root=/dev/hda6 ro max_loop=255

[...]

Make sure that /dev/hda6 is your / partition. Keep in mind what I said about Grub and partitioning in chapter 1!

Now reboot the system:

shutdown -r now

At the boot prompt, Grub should now list Xen 3.0.3 / XenLinux 2.6 as the first kernel and boot it automatically. If your system comes up without problems, then everything is fine!

 

4.3 Compile A domU Kernel

Afterwards we compile a kernel for domU (the virtual machines):

cd /usr/src/xen-3.0.3_0-src/
make linux-2.6-xenU-config CONFIGMODE=menuconfig KERNELS="linux-2.6-xenU"

In the kernel comfiguration menu that shows up we have to enable quota and iptables as modules (it is important that they are modules. I could not get iptables to work in a virtual machine when I compiled it into the kernel statically!). This is where you enable these modules:

File systems --> [*] Quota support
<M> Old quota format support
<M> Quota format v2 support

Networking ---> Networking options ---> [*] Network packet filtering (replaces ipchains) ---> Core Netfilter Configuration ---> <M> Netfilter Xtables support (required for ip_tables)

Networking ---> Networking options ---> [*] Network packet filtering (replaces ipchains) ---> IP: Netfilter Configuration ---> <M> IP tables support (required for filtering/masq/NAT)

[*] means: build into the kernel statically.
<M> means: build as a kernel module.

After you have left the kernel configuration menu, do the following to build and install the domU kernel:

make linux-2.6-xenU-build
make linux-2.6-xenU-install
depmod 2.6.16.29-xenU

Share this page:

5 Comment(s)

Add comment

Comments

From: decep

Compiling separate dom0 and domU kernels is considered to be the "old way" of doing things.  Ever since Xen 3 was released, a single kernel can be used for both dom0 and domU.

From:

I just wanted to add a precision about the command :

mv /lib/tls /lib/tls.disabled 

Xen team advise users to disable TLS (Thread Local Storage) because of performance issues. It's not absolutly needed.

See the Xen team explanation.

From:

If you're trying to compile Xen under a minimal Sarge net installation, 2 additional packages need to be installed prior to running "make world" : xlibs-dev libncurses5-dev Without these packages, the compile will fail near the end (very frustrating 30 minutes into the process). Adding build-essential to the apt-get install statement at the top of the page couldn't hurt either for completeness. Other than this, an excellent howto.

From:

In my case it was mandatory that I install the build-essential package for "make world" to succeed. Thanks

 Additionally, I was getting kernel panics when the mem statement was present in the grub menu config. Removing it eliminated the kernel panic.

From:

gcc-3.3 installed but did not leave a link to gcc. 

ln -s /usr/bin/gcc-3.3 /usr/bin/gcc

ln -s /usr/bin/gccbug-3.3 /usr/bin/gccbug

 Fixed this and I could start step 4.1.