To build a Xen kernel (whether for the host or for the guest systems), use these instructions:
Getting Xen from a repository
Please note that it is recommended to install Xen from the sources if you are to use it with dtc-xen; there are a few manual changes needed if you install from the packages, as the file locations have shifted. The following is useful for an IA32 (32-bit Intel) architecture -- x86_64 (AMD 64-bit) will differ a bit in package names:
apt-get install linux-image-xen-686 libc6-xen xen-hypervisor-3.0.3-1-i386 xen-linux-system-2.6.18-4-xen-686
// You'll have to make a symlink to the python lib, as the Debian xen kernel doesn't provide it. A bug has been sent to the maintainer of the package, but he doesn't seem to care, unfortunately. Again, WE DO NOT RECOMMEND to do this, as we had bad experiences with Xen 3.0.3 (eg: instability). A version 3.0.4-1, or even 3.2.0 is much better.
Building Xen yourself
Downloading and unpacking the kernel and Xen
Go to an empty folder and download the latest stable sources. Example:
wget http://bits.xensource.com/oss-xen/release/3.2.0/xen-3.2.0.tar.gz
Now clone the latest Linux 2.6.18 from the Xen Mercurial repository:
hg clone http://xenbits.xensource.com/linux-2.6.18-xen.hg
The hg command is in the mercurial package. This downloaded kernel is NOT the standard 2.6.18, it includes MANY patches not only for Xen, like support for the ICH8 SATA controler and others (like security patches). But unfortunately, this does NOT include enough security patch -- I was able to add about 95 bugfix patches from the Debian 2.6.18 kernel patch set. Here is an archive that I did, taking the bugfix folder from the package linux-patch-debian-2.6.18, and removing the patches that failed. This include the famous vmsplice patch. You're going to get those now:
wget http://dtcsupport.gplhost.com/xen-patches-2008-03-05.tar.gz
Unpack it, then cd to linux-2.6.18-xen.hg and type:
../xen-patches/patch-xen-hg
Xen will then compile using this rather more secure kernel. In the future, you HAVE to watch carefully the debian-security mailing list to watch for future patches and apply them again.
Unpack all the tarballs you downloaded.
Preparing the system to compile the Xen kernel
It's time for you to get all the things you need to compile. Here's my one time apt-get command:
apt-get install make gcc libc6-dev zlib1g-dev python python-dev python-twisted bridge-utils iproute libcurl3 libcurl3-dev bzip2 module-init-tools transfig tgif libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev bcc bin86 gawk pciutils-dev
This will download as well the things needed to compile Xen with HVM support (VMX), the hardware assisted emulation that can run Windows (for example). Now, just type:
Now, change into the Xen directory and run the following command:
cd xen-3.2.0
make world KERNELS="linux-2.6-xen0 linux-2.6-xenU"
and this will compile everything for you (a domU and a dom0 kernel). If you need to configure your kernel first, follow the next section:
Customizing the kernel
The way to configure your dom0 kernel is easy:
make linux-2.6-xen0-config CONFIGMODE=menuconfig
You can do the same for domU:
make linux-2.6-xenU-config CONFIGMODE=menuconfig
Add all the hardware drivers that you need as usual, and don't forget to check for the support of RAID1 and LVM2 (which is called device mapper in the kernel).
As per default, many things has to be changed. Namely, you need to have support for iptables, but also physdev match (if you want to use the anti-spoof facility of Xen), QoS (all the options), pf_key and other routing facilities. Note that you might need to compile all the modules needed by the Xen domU in your dom0, I have noticed once that a domU kernel module didn't work if it was not compiled in the dom0 as well, which shouldn't be the case, but this is what I could experience. If you want to satisfy all of your customers, best is to compile all the network options you can, and if you want to be able to access to the file systems of guest OS, it can be nice to have support for things like NetBSD fs, NTFS and others. The dom0 is the most important kernel to configure, as there is always the possibility to customize the domU kernel later, when your box is ready and in the data center (no need for a hardware reset for your domU kernel).
This section should be enlarged upon to explain exactly which things should be changed from defaults. It is reasonable to assume that most readers of this article will not be experienced in kernel tweaking
Once you are happy with the configuration, you can build the kernel:
make dist KERNELS="linux-2.6-xen0 linux-2.6-xenU"
And install with
make install KERNELS="linux-2.6-xen0 linux-2.6-xenU"
Once you are satisfied, go on the toplevel folder of the xen sources, and type make install
Don't forget you can always do this later on:
make linux-2.6-xenU-config CONFIGMODE=menuconfig
make linux-2.6-xenU-build
make linux-2.6-xenU-install
or also:
make linux-2.6-xen0-config CONFIGMODE=menuconfig
make linux-2.6-xen0-build
make linux-2.6-xen0-install
GRUB
Edit /boot/grub/menu.lst -- and set the first option to be something like this:
title Xen 3.0 / XenLinux 2.6
kernel /boot/xen-3.2.0.gz dom0_mem=393216
module /boot/vmlinuz-2.6.18.8-xen0 root=/dev/md0 ro console=tty0 max_cpus=1
## ## End Default Options ##
title Debian GNU/Linux, kernel 2.6.8-2-386
root (hd1,0)
kernel /boot/vmlinuz-2.6.8-2-386 root=/dev/md0 ro
initrd /boot/initrd.img-2.6.8-2-386
boot
As you see, you should set the xen kernel BEFORE the ## ## End Default Options ##. This way, the debian system wont overwrite it. Note that my experience showed that something lower than 192MB for the dom0 is to avoid, and 384MB seems to be a quite good value when running with dtc-xen.
Double, and even tripple check that your kernel version number correspond to what you have just compiled (and that should be now located in your /boot).
If not done before, you can install grub on both disks:
grub --no-floppy
root (hd0,0)
setup (hd0)
root (hd1,0)
setup (hd1)
Now you can reboot. After you have reboot in your new xen kernel, you have to:
update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20
and start xend:
/etc/init.d/xend start
That's it, you are done with the basic OS setup.