This article assumes you have a clean install of CentOS and have root level access to the server. Note this was performed on a minimal install with no desktop.

Prereqs

To be able to perform a successful kernel build, you will need to install the following packages:

yum groupinstall “Development tools” “Compatibility libraries”

yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel openssl-devel python-twisted python python-devel ncurses-devel

We also need the 32 bit version of glibc-devel.i686

yum install glibc-devel.i686

XEN Compile and install

Now lets get the XEN tarball and make XEN

cd /usr/src

wget http://bits.xensource.com/oss-xen/release/4.1.2/xen-4.1.2.tar.gz 

tar xvf xen-4.1.2.tar.gz

 cd xen-4.1.2

make xen

make tools

make stubdom

cd dist/install

cp -R * /

vi /etc/sysconfig/xendomains and comment out #XENDOMAINS_SAVE=/var/lib/xen/save

These tweeks should make XEN start at system startup and also create the bridge we need for the DomUs.

ln -s /etc/init.d/xendomains /etc/rc0.d/S10xendomains

ln -s /etc/init.d/xendomains /etc/rc6.d/S10xendomains

ln -s /etc/init.d/xencommons /etc/rc3.d/S98xencommons

ln -s /etc/init.d/xendomains /etc/rc3.d/S98xendomains

ln -s /root/xendom0caps /etc/rc3.d/S98xendom0caps

ln -s /root/iptables-enable /etc/rc3.d/S99iptables-enable (not required)

vi /root/xendom0caps (add xl sched-credit -d Domain-0 -w 512)

chmod +x /root/xendom0caps

vi /etc/rc.local (add /usr/bin/setterm -powersave off -blank 0

vi /etc/xen/xend-config.sxp

find line (network-script network-bridge) and comment out

#network-script network-bridge

Interfaces

As newer versions of XEN can use the system bridge rather than its own script we need to edit the network configuration to invoke our new bridge. Firstly create our new bridge interface.  Replace the IP values with your settings.

vi ifcfg-xenbr0

DEVICE=”xenbr0″
NM_CONTROLLED=”yes”
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
IPADDR=172.20.1.73
PREFIX=16
GATEWAY=172.20.0.76
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System xenbr0″

Now we need to edit ifcfg-eth0 and comment out the IP address and add the bridge in.

vi ifcfg-eth0

DEVICE=”eth0″
BOOTPROTO=”none”
NM_CONTROLLED=”yes”
ONBOOT=”yes”
#IPADDR=172.20.1.73
#GATEWAY=172.20.0.76
#NETMASK=255.255.0.0
TYPE=”Ethernet”
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
BRIDGE=xenbr0

Once both files are done reboot to ensure they both apply successfully.

Kernel Compile

Now XEN is complete we need to get our kernel for Dom0.  Replace the kernel number with the version you want to use.

cd /usr/src

wget ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.4.5.tar.gz

tar xvf linux-3.4.5.tar.gz

make menuconfig

Go into Processor type and features

Statically enable all XEN features

Go back to the  main menu and enter Device Drivers menu, then enter block devices menu

Statically enable the 2 XEN options

Go back to the Device Drivers menu and go down to XEN driver suppport

Statically enable all features

Go back to Device Drivers, go into Network device support and statically enable the 2 XEN options at the bottom

Exit out and save.

Note to make sure all options are selected run

cat /usr/src/linux-3.4.5/.config | grep XEN

You should see the same as

CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
CONFIG_XEN_PRIVCMD=y
CONFIG_XEN_ACPI_PROCESSOR=y

If it looks good then continue otherwise please correct before hand.

make bzImage

make modules

make modules_install

cp -a arch/x86/boot/bzImage /boot/vmlinuz-3.4.5

cp -a System.map /boot/System.map-3.4.5

cp -a .config /boot/config-3.4.5

depmod –a

mkinitrd /boot/initrd.img-3.4.5 3.4.5

Modify GRUB to boot in XEN mode

vi /boot/grub/grub.conf

scroll down to the current setting and add the following above your current boot config, you will need to edit the lines to match your root and paths to the files.

title Xen 4.1.2 / Debian GNU/Linux, kernel 3.4.5
root (hd0,0)
kernel /xen.gz
module /vmlinuz-3.4.5 root=root=UUID=03f9e700-ba18-41a1-bbe7-65a372716c73 ro console=tty0
module /initrd.img-3.4.5

save and reboot.

If your system fails to boot then you can boot back into the normal kernel and correct any issues.

Once the system is booted run this as a simple test to make sure XEN is running

xl list