The
This guide will talk you through the configuration steps necessary to get Xen up
and running on Gentoo Linux. We will not discuss Xen itself (the Xen project has
A drastic change that might be necessary is to rebuild the entire Gentoo
installation with a different
~# nano -w /etc/make.conf(Add -mno-tls-direct-seg-refs) CFLAGS="-O2 -march=pentium4 -pipe -mno-tls-direct-seg-refs" ~# emerge -e world
If you boot your system using an initial ramdisk (initrd) you need to rebuild the initrd as well (which is best done by running all steps you would do when you rebuild your kernel).
Xen actually contains many components, so you'll need to install a couple of
packages. Because it is still
~# nano -w /etc/portage/package.keywords app-emulation/xen app-emulation/xen-tools sys-kernel/xen-sources ~# emerge xen xen-tools xen-sources
Next we'll build the Linux kernel with Xen support. This kernel, whose sources
are available at
Of course, don't forget to select
A nice hint is to have the kernel make process store its intermediate object files elsewhere so that you can reuse the same kernel tree to build different configurations:
~# mkdir -p ~/build/dom0 ~/build/domU ~# make O=~/build/dom0 menuconfig(Configure the kernel) ~# make O=~/build/dom0 && make O=~/build/dom0 modules_install
Once the kernel is built you'll find the kernel image immediately in the
build directory (not inside
title Xen 3.0 / Gentoo Linux 2.6.x.y root (hd0,0) kernel /boot/xen.gz module /boot/kernel-2.6.x.y-xen0 root=/dev/hda3
Now reboot your system into Xen. Once you are booted, you need to load the Xen daemon:
~# /etc/init.d/xend start
Now check if you can do whatever you normally do on your system. If this is the case, you can edit your bootloader configuration to always boot into Xen and add the Xen deamon to the default runlevel so that it is started automatically next time you boot.
Go to the Xen-powered Linux kernel source and update the configuration. It is
wise to keep as many topics as possible similar to the main kernel except the
~# make O=~/build/domU ~# cp ~/build/vmlinuz /mnt/data/xen/kernel/kernel-2.6.x.y-xen
It is also possible to create a single kernel image for both the administrative domain and the unpriviledged domain. More information about this can be found in the Xen user manual.
For best performance, it is best to dedicate a partition (or logical volume) to a domain rather than a file based filesystem. However, if you are going to use Xen primarily for tests using a file based filesystem does have its advantages (especially regarding maintenance).
You can create a file based filesystem using
~# dd if=/dev/zero of=/mnt/data/xen/disks/ext3root.img bs=1M count=2048 ~# mke2fs -j /mnt/data/xen/disks/ext3root.img
Next we create a Xen configuration file for a domain. You can store these
configuration files where you want, for instance at
~# nano -w /mnt/data/xen/configs/gentoo kernel = "/mnt/data/xen/kernel/kernel-2.6.x.y-xen" memory = 512 name = "gentoo"(Map the disk image to the virtual /dev/sda1) disk = ['file:/mnt/data/xen/disks/ext3root.img,sda1,w'] root = "/dev/sda1 ro"
You can find example configuration files in
Now we're all set and we can launch the new domain. If the disk image contained
an operating system, we could just create and attach the domain using the
~# xm create /mnt/data/xen/configs/gentoo -c
The domain would be booted inside the terminal in which you executed the command. However, in our case, the disk image is empty so the domain wouldn't be able to do much. To fix this, you can loop-mount the image and install Gentoo as you're used to.
If you want to disconnect from the domain, press
Xen supports at least two ways of configuring your (virtual) network:
When selecting the
When selecting the
Before you set up the interface on your unpriviledged domain, make sure that
Xen's
~# nano -w /mnt/data/xen/configs/gentoo(Add the vif instruction) vif = [ 'ip=192.168.1.101, vifname=veth1' ]
In the above example, the interface will be created for the unpriviledged domain
(in which it will be called
This doesn't mean that the virtual
Now edit
~# nano -w /etc/xen/xend-config.xsp(Comment out the following lines) #(network-script network-bridge) #(vif-script vif-bridge)(Enable the following lines) (network-script network-route) (vif-script vif-route)