Create a directory and cd into it, I usually choose
/usr/local/src/xen-source
mkdir build && cd build
wget http://bits.xensource.com/oss-xen/release/3.3.1/xen-3.3.1.tar.gz
tar xzf xen-3.3.1.tar.gz
Staying in the same directory you will need to pull the kernel with mercurial:
hg clone http://xenbits.xensource.com/linux-2.6.18-xen.hg
(if you don’t have hg installed try this guide)
The final directory layout should look like this:
./build/xen-3.3.1/
./build/linux-2.6.18-xen/
Start!
cd ./build/xen-3.3.1
make prep-kernels
With make prep kernels you will be prompted with new settings of the kernel, just hit enter to keep the default values.
This should be the directory layout (in bold the link to the kernel that was downloaded)
drwxrwsr-x 2 1000 1000 4096 Jan 5 12:26 buildconfigs
drwxr-sr-x 6 root 1000 4096 Jan 9 16:53 build-linux-2.6.18-xen_x86_64
drwxrwsr-x 2 1000 1000 4096 Jan 5 12:26 config
-rw-rw-r-- 1 1000 1000 3191 Jan 5 12:40 Config.mk
-rw-rw-r-- 1 1000 1000 19399 Jan 5 12:26 COPYING
drwxrwsr-x 7 1000 1000 4096 Jan 5 12:26 docs
drwxrwsr-x 3 1000 1000 4096 Jan 5 12:26 extras
-rwxrwxr-x 1 1000 1000 1161 Jan 5 12:26 install.sh
lrwxrwxrwx 1 root 1000 22 Jan 9 16:52 linux-2.6.18-xen.hg -> ../linux-2.6.18-xen.hg
-rw-rw-r-- 1 1000 1000 8177 Jan 5 12:26 Makefile
-rw-rw-r-- 1 1000 1000 8962 Jan 5 12:26 README
drwxrwsr-x 6 1000 1000 4096 Jan 5 12:26 stubdom
drwxrwsr-x 33 1000 1000 4096 Jan 5 12:32 tools
drwxrwsr-x 3 1000 1000 4096 Jan 5 12:27 unmodified_drivers
drwxrwsr-x 8 1000 1000 4096 Jan 5 12:27 xen
You can configure the Xen kernel in two ways:
starting from the distro xen .config
yum install kernel-xen-devel
cp /usr/src/kernels/2.6.xx.yy-xen-x86_64/.config ./build-linux-2.6.18-xen_x86_64
creating your own .config from default values
make linux-2.6-xen-config CONFIGMODE=menuconfig
if you get an error about lxdialog not compiling just do yum install ncurses-devel
among all the kernel configuration you will want to change don’t forget to choose the proper CPU architecture and type of machine, in my case:
Preemption Model (No Forced Preemption (Server))
Processor family (AMD-Opteron/Athlon64)
Compile the kernel
make dist KERNELS="linux-2.6-xen linux-2.6-xenU"
this will take time, you can accelerate the building process by adding the
-jX
parameter, where X is the number of jobs to run simultaneously.
To install the kernel files in the /boot directory:
make install KERNELS="linux-2.6-xen linux-2.6-xenU"
…time to make the initrd (adding appropriate –with=aacraid –with=sd_mod etc.)
depmod 2.6.18.8-xen
mkinitrd -v -f /boot/initrd-2.6.18.8-xen.img 2.6.18.8-xen
this is what /boot looks like if everything went good:
-rw-r--r-- 1 root root 62459 Jan 13 11:40 config-2.6.18.8-xen
-rw-r--r-- 1 root root 17497 Jan 13 11:40 config-2.6.18.8-xenU
-rw-r--r-- 1 root root 62400 Dec 16 18:18 config-2.6.18-92.1.22.el5
-rw-r--r-- 1 root root 62395 Jun 11 2008 config-2.6.18-92.el5
drwxr-xr-x 2 root root 1024 Jan 13 10:53 grub
-rw------- 1 root root 3255724 Jan 13 11:41 initrd-2.6.18.8-xen.img
-rw------- 1 root root 3239377 Jan 13 10:25 initrd-2.6.18-92.1.22.el5.img
-rw------- 1 root root 3216199 Jan 13 10:05 initrd-2.6.18-92.el5.img
drwx------ 2 root root 12288 Jan 13 11:01 lost+found
-rw-r--r-- 1 root root 80032 Nov 23 2007 message
-rw-r--r-- 1 root root 92793 Dec 16 18:18 symvers-2.6.18-92.1.22.el5.gz
-rw-r--r-- 1 root root 92749 Jun 11 2008 symvers-2.6.18-92.el5.gz
-rw-r--r-- 1 root root 961829 Jan 13 11:40 System.map-2.6.18.8-xen
-rw-r--r-- 1 root root 655437 Jan 13 11:40 System.map-2.6.18.8-xenU
-rw-r--r-- 1 root root 1163830 Dec 16 18:18 System.map-2.6.18-92.1.22.el5
-rw-r--r-- 1 root root 1162656 Jun 11 2008 System.map-2.6.18-92.el5
-rw-r--r-- 1 root root 1499619 Jan 13 11:40 vmlinuz-2.6.18.8-xen
-rw-r--r-- 1 root root 1355488 Jan 13 11:40 vmlinuz-2.6.18.8-xenU
-rw-r--r-- 1 root root 1861692 Dec 16 18:18 vmlinuz-2.6.18-92.1.22.el5
-rw-r--r-- 1 root root 1859484 Jun 11 2008 vmlinuz-2.6.18-92.el5
-rw-r--r-- 1 root root 458902 Jan 13 11:40 xen-3.3.1.gz
lrwxrwxrwx 1 root root 12 Jan 13 11:40 xen-3.3.gz -> xen-3.3.1.gz
lrwxrwxrwx 1 root root 12 Jan 13 11:40 xen-3.gz -> xen-3.3.1.gz
lrwxrwxrwx 1 root root 12 Jan 13 11:40 xen.gz -> xen-3.3.1.gz
-rw-r--r-- 1 root root 7506786 Jan 13 11:39 xen-syms-3.3.1
now it is the time to add our new kernel to grub:
title Xen 3.3.1 / XenLinux 2.6.18
root (hd0,0)
kernel /xen-3.3.1.gz
module /vmlinuz-2.6.18.8-xen ro root=/dev/VolGroup00/LogVol00
module /initrd-2.6.18.8-xen.img
if you get an error like "No modules available for kernel "2.6.18.8-xenU" after the install just ignore it.
Reboot the machine, if you are working remotely you might want to try something to login again, even if the kernel didn’t work.
if the kernel doesn’t work or you want to try other options just
make uninstall
it will remove all xen kernel files from /boot and also all the settings from /etc (use with caution)
After the reboot you will have to start the xen daemon
/etc/init.d/xend start
and if you want it to start automatically at every boot just:
cd /etc/init.d/
chkconfig --add xend
additional info
if you get "modules not found" error during xenU boot just
mkdir -p /lib/modules/2.6.18.8-xenU
inside the domain
requirements:
Compiling a linux kernel in general and mostly a xen kernel requires several packages, most of them can be installed with the groupinstall yum option:
yum groupinstall development-tools
and
yum groupinstall "X Software Development"
OpenSSL and other devel packages may also be required, just google any error you might get and you should find the correct package to install:
yum install openssl-devel
yum install glibc-devel
references:
Xen compilation:
http://www.xen.org/download/docs/linux-2.6.18.README.txt
http://lists.xensource.com/archives/html/xen-users/2008-01/msg00699.html
http://www.nikhef.nl/pub/projects/grid/gridwiki/index.php/Xen_on_CentOS_5_-_Notes
Testing a kernel remotely with Grub (didn’t work for me):
http://weichong78.blogspot.com/2007/04/grub-test-kernel-once.html
Yum groupinstall
http://hungrycoder.xenexbd.com/node/468
Sysadmin, Xen notes
compilation, kernel, linux, xen