In this how-to I will guide you through installation of the Xen kernel on CentOS 6.3. If you follow this guide properly, you will be running Xen on CentOS 6.3 in no time.
The first thing you want to do is disable SELinux on the system. SELinux and Xen do not play well together so lets just separate the two now.
vi /etc/sysconfig/selinux
Change the line that says:
SELINUX=enforcing
to:
SELINUX=disabled
Now we need to setup your host to allow bridged networking. You can do this by first installing ‘bridge-utils’ and configuring your interface configuration files manually.
yum install bridge-utils
vi /etc/sysconfig/network-scripts/ifcfg-br0
Add the following lines to your ifcfg-br0 file, modifying your IP address, Prefix mask, gateway, and DNS servers accordingly.
DEVICE=br0
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
IPADDR=X.X.X.X
PREFIX=27
GATEWAY=Y.Y.Y.Y
DNS1=Z.Z.Z.Z
DNS2=Z.Z.Z.Z
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME="System br0"
Next you need to edit your primary interface configuration file, in this case /etc/sysconfig/network-scripts/ifcfg-eth0, and comment out the following lines and add the one uncommented line:
#BOOTPROTO=none
#IPADDR=X.X.X.X
#PREFIX=27
#GATEWAY=Y.Y.Y.Y
#DNS1=Z.Z.Z.Z
#DNS2=Z.Z.Z.Z
BRIDGE=br0
When you have finished your configuration changes you should restart your network to make sure everything is working properly. If you configured your files properly your SSH session should reconnect, however if you made an error, you will loose connectivity to your system. I suggest you have some sort of out of band access to your server, like IPKVM or Ilo access, or if your server is close by a keyboard and monitor. To restart your network run the following command.
/etc/init.d/network restart
If everything went well you should be sitting back at a command prompt once the network restarts. Now your system is ready to install the Xen kernel.To install the latest Xen Kernel run the following commands.
yum install wget
yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-3.noarch.rpm
yum install kernel-xen xen
Now you must edit your /boot/grub/menu.lst file to have your system boot the Xen Kernel, and load vmlinuz and your initramfs as a module. You will see something that looks like this:
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.5.4-2.el6xen.x86_64)
root (hd0,0)
kernel /vmlinuz-3.5.4-2.el6xen.x86_64 ro root=UUID=0efe7a1c-756c-4a15-87ab-5c19e584c660 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-3.5.4-2.el6xen.x86_64.img
On the line that starts with ‘kernel /vmlinuz…’ Change the word ‘kernel’ to ‘module’. Do the same on the initrd line by changing the word ‘initrd’ to ‘module’ Now add ‘kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=4 dom0_vcpus_pin’ to your kernel configuration right above the first line you modified. Adjust the ‘dom0_max_vcpus=4’ to however many cores you want Dom0 to have access to. When you are done you will have something like this:
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.5.4-2.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=4 dom0_vcpus_pin
module /vmlinuz-3.5.4-2.el6xen.x86_64 ro root=UUID=0efe7a1c-756c-4a15-87ab-5c19e584c660 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
module /initramfs-3.5.4-2.el6xen.x86_64.img
Now you can reboot into your Xen Kernel
[code]reboot[/code]
Once your system has rebooted, ensure your running the Xen kernel and you can see Dom0 is up and running.
uname -a
Linux your.domain.com 3.5.4-2.el6xen.x86_64 #1 SMP Tue Sep 18 20:06:18 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 4 r----- 50.6
That’s all there is to it. Also I would like to give a big thanks to Steve over at https://www.crc.id.au/ for building and distributing the Xen Kernels for CentOS. While testing this writeup I found that the latest HP smart array module was not in the kernel by default. After a few emails around the world, Steve worked with me to get the kernel updated to include the hpsa module by default. This is the type of community support and development is what the open source movement is all about. I was so thankful for his support I decided to support his efforts by hosting a mirror on ZoomCloud.net. This mirror is on the east coast of the US and I hope it can help serve Steve’s work for years to come. If you would like to reach this mirror its available at xenmirror.zoomcloud.net or us3.mirror.crc.id.au. Please make sure you visit Steve’s blog for even more information related to Xen.
-Joe
Leave a Reply