How to install Xen on RHEL6, Scientific Linux 6, CentOS 6

As any user of an EL6 distro would know, the basis of the EL6 packages are RHEL6. Sadly, Redhat dropped support for Xen in v6 – preferring KVM as their corporate solution. Personally, I don’t think this was the correct decision. This mini-howto will give the basics of setting up the Xen Dom0. From there, any Xen tutorial will cover the basics (and some more advanced) functionality of Xen guests (both Windows and Linux).

Support?
I run a mailing list on lists.wireless.org.au which is available for peer support and suggestions. I will also post announcements to this list on new builds and testing as new developments emerge.

NOTE: Due to the number of support requests I get sent, I am unable to give individual responses to any issues. I suggest using the mailing list for support. I will make an effort to monitor and assist people using the list.

Step 1
Download and install your base OS. I personally use Scientific Linux 6. After downloading and burning the DVD, perform a minimal install adding packages you require.

Step 2
Install the bridge-utils package.
# yum install bridge-utils

Step 3
Enable my Xen Repo for x86_64:
# yum install http://au1.mirror.crc.id.au/repo/el6/x86_64/kernel-xen-release-6-4.noarch.rpm

Step 4
Install the Xen hypervisor and Dom0 Kernel:
# yum install kernel-xen xen

Step 5
Modify your /etc/grub.conf to firstly load the Xen hypervisor, then boot your OS. A correctly modified grub.conf should look something like the following:
title Scientific Linux (2.6.32-4.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
module /vmlinuz-2.6.32-4.el6xen.x86_64 ro root=/dev/mapper/RAID1-xenhost rd_LVM_LV=RAID1/xenhost rd_MD_UUID=afb92c19:b9b1e3ae:07af315d:738e38be rd_NO_LUKS rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto
module /initramfs-2.6.32-4.el6xen.x86_64.img

Step 6
Disable SELinux. While selinux is a great idea, it really screws with Xen. If there is anyone out there who wants to wade through what should be set for selinux to be enabled and still have Xen working, please email me! In the mean time, disable it by editing the following file:
/etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

Step 7
Reboot into your new Xen kernel and test:
# xm info
host : xenhost.lan.crc.id.au
release : 2.6.32-4.el6xen.x86_64
version : #1 SMP Fri Jul 8 01:19:26 EST 2011
machine : x86_64
nr_cpus : 4
nr_nodes : 1
cores_per_socket : 2
threads_per_core : 2
cpu_mhz : 3325
hw_caps : bfebfbff:28100800:00000000:00003f40:0298e3bf:00000000:00000001:00000000
virt_caps : hvm
total_memory : 7989
free_memory : 2113
free_cpus : 0
xen_major : 4
xen_minor : 1
xen_extra : .1
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
cc_compiler : gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)
cc_compile_by : root
cc_compile_domain : (none)
cc_compile_date : Thu Jun 30 18:11:34 EST 2011
xend_config_format : 4