The Xen virtual machine monitor allows multiple operating systems to be run on shared hardware. (For slightly more helpful information, see their web page.)
To set up a working copy of Xen, four things are needed: the Xen kernel itself, various tools, a XenLinux kernel to run as the "domain 0" operating system, and usually at least one unprivileged kernel to run the virtual machines.
It may first be necessary to unmask a couple of packages before emerge will install them: add the following lines to /etc/portage/package.keywords:
sys-apps/xen ~x86 sys-kernel/xen-sources ~x86 dev-python/twisted ~x86
Then simply run
USE="doc" emerge xen(omitting USE="doc" if you don't care about the documentation).
To download the 2.6.9 kernel source with Xen patches, run:
emerge xen-sources
If you want to use these sources to compile an unprivileged kernel (which you probably do, unless you're planning to use Xen Linux/BSD kernels from elsewhere), it's best to make a copy of the kernel source:
cp -R /usr/src/linux-2.6.9-xen0 /usr/src/linux-2.6.9-xenU cd /usr/src/linux-2.6.9-xenU sed -i s/-xen0/-xenU/ Makefile cp arch/xen/configs/xenU_defconfig arch/xen/defconfig
When this has finished, configure and compile the kernel as normal (see the Gentoo Handbook):
cd /usr/src/linux-2.6.9-xen0 make xconfig make && make modules_install mount /boot cp vmlinux /boot/vmlinux-syms-2.6.9-xen0 cp vmlinuz /boot/vmlinuz-2.6.9-xen0 cp System.map /boot/System.map-2.6.9-xen0 cp .config /boot/config-2.6.9-xen0and update your GRUB config file (/boot/grub/grub.conf) to add something like
title Xen 2.0 / XenLinux 2.6.9 root (hd0,0) kernel (hd0,0)/boot/xen.gz dom0_mem=131072 module (hd0,0)/boot/vmlinuz-2.6.9-xen0 root=/dev/sda4 ro console=tty0(Make sure you give yourself the option to boot into your normal kernel, in case Xen fails to boot.)
It should then be possible to reboot into XenLinux and use the system as normal. Follow the procedures in the standard Xen documentation to play with virtual machines, using kernel = "/usr/src/linux-2.6.9-xenU/vmlinuz" in the config file if you compiled the xenU kernel earlier.