Sunday, 25 December 2011 19:36

Create custom templates


  • XCP/Xenserver


Creating a template

The following is how to create new custom templates based on existing templates in Xen Cloud Platform. 

1. Get the template UUID that we want to use as our base. As usual just copy and paste the line in yellow into a root terminal on your XCP host.

xe template-list | grep -B1 name-label | awk -F: '{print $2}'

The output should look like this..



 Red Hat Enterprise Linux 6 (32-bit)



Windows Server 2003 (64-bit)



Scroll through the list and find the template you want to clone then copy and past it's UUID number ie.  688c625b-93b8-8e66-62e5-4542eca1e597. Choose a new name for your custom template and enter the following line with the UUID of the template you want to clone and the name you want it to have.


xe vm-clone uuid=<UUID> new-name-label="<NAME>"
xe template-param-set uuid=<UUID> other-config:install-methods=http,ftp,nfs other-config:default_template=true

Now you should have a new template of your own that you can customize. More after the jump.

Published in XCP Howtos
Tuesday, 20 December 2011 16:00

Fix the XCP expired license issue

If you're running virtually any version of Xen Cloud Platform you may have run into this error message.

Your license has expired.  Please contact your support representative.

It's not really possible to have an expired license on Xen Cloud Platform (XCP) since it's FREE. It's just a regressive bug that has been very stubborn. However, until they fix it for real in XCP 1.5 you'll need follow the steps below.  

Open a root terminal on the XCP host and copy and paste the commands below.


service xapi stop;sleep 5
NEXTMONTH=`date --date="next Month" '+%Y%m%d'`
sed -i "s/\(expiry.\{3\}\)[0-9]\{8\}/\1$NEXTMONTH/g" /var/xapi/state.db
service xapi start
echo done


The last line is only to get all the important lines to run automatically. If you don't hit enter it doesn't hurt anything.  You could also copy and paste these lines into a script and have it run as a cronjob. Because XCP doesn't like you bumping it's "evaluation license" out more than 30 days you might want to run the cronjob once a week to make sure your license doesn't lapse while you're waiting for the cronjob to run

Published in XCP Howtos
Thursday, 24 September 2009 10:00

Getting Started with Xen

I'm using a Xen Virtual Server to provide my Linux students with their own machines with admin rights. This has prompted interest in Xen from a lot of people just starting out in Virtualization. Following is a quick explaination of Xen and how to get a Virtual Machine up and running as fast as possible.


Xen is a hypervisor meaning that it runs above the hardware but below any OS. Traditionally when you "virtualized" an OS you'd have a computer that you logged into which you installed virtualization software on such as VMWare workstation or VirtualBox. With this software you'd start the Virtual Machine from it's GUI and install the Guest OS via CDROM. In this case you have a Host Machine (the real physical machine) and a Guest Machine (the virtualized OS). With a hypervisor ALL operating systems are virtualized. This might seem a bit strange or impossible but is very powerful and extremely effecient. The side effect is that Xen can be very complex to set up. Let me explain the Xen boot process.

Xen Boot Process

  1. Machine runs code in Master Boot Record
  2. Bootloader loads the OS kernel
  3. Xen lodges itself in memory and loads the rest of the kernel in a Virtual Machine
  4. The user logs into the first Virtual Machine and starts, stops and restarts the other Virtual Machines from there

The name for the first Virtual Machine is Dom0 - it's the privileged Domain so it has direct access to the physical hardware. All subsequent Virtual Machines that are started are called DomU - unprivileged Domains. To manage a Xen Virtual Server you log into the Privileged Domain (Dom0) and use various commands to administer the Unprivileged Domains (DomUs).

Two modes of Virtualization

Virtualizers work in one of two modes - paravirtualization or hardware (full) virtualization. The difference being that a paravirtualized DomU OS knows it's being virtualized and has extensions to allow and assist in this. Paravirtualized Operating Systems are very fast and effecient. However there are times when you won't be virtualizing an OS that has these extensions such as Windows. In this case you need to use a CPU that has hardware vitualization support and run Xen in HVM (Hardware Virtualization Mode).


  • Runs on a lot of hardware - x86, x86-64, Itanium and PowerPC 970 with or without hardware Virtualization support
  • DomUs can be Linux, NetBSD and Solaris
  • Very fast

Full Virtualization:

  • Requires Intel or AMD cpus with Virtualization Support built in
  • DomUs can be most any unmodified OS including Windows
  • Not so fast

To get around the speed issues with Full Virtualization there are paravirtualized drivers that have been written for many Operating Systems including Windows for disk access and network cards. This allows Full Virtualization to reach the speeds of paravirtualization in these two areas without requiring further modification to the Operating System. The Linux KVM Hypervisor runsin Full Virtualization mode all the time and thus needs paravirtualized drivers.



Published in Xen Howtos
Saturday, 26 January 2013 11:02

Install git on XCP host

To develop the Xenapi Admin Tools for the Xenapi Admin Project I install git on the XCP host so I can write tools and keep the github project up to date as well. Following is how to get git working on XCP 1.6.  To develop tools I just mount my XCP hosts / partitoin on my development machine via sshfs so I can edit tools remotely. When I'm satisfied with the tools I commit them using git commit -a  followed by git push to send the changes to the xenapi-admin-tools github repository.


 Add the EPEL repo, install git then disable the repo

We add the EPEL repo (which is necessary), install git and then disable the repo immediately to keep other system specific packages from updating.

rpm -ivh
yum install git
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo


Configuring git

To use git to clone our Xenapi Admin Tools repository you'll need to set a few configuration items. Change "Your User Name" to your actual username you want to authenticate with. Change "Your Email Address" to your own email address.

git config --global "Your User Name"
git config --global "Your Email Address" git config --global credential.helper cache git config --global credential.helper 'cache --timeout 3600'


Clone the xenapi-admin-tools github and add it to your PATH (OPTIONAL)

Cloning the github repo is pretty easy. Below we clone the Xenapi Admin Projects tools repo which  will create a /root/xenapi-admin-tools directory. The tools are in xenapi-admin-tools/releases/<version number> but to use them we'll need to add that directory to our system $PATH variable.

cd /root
git clone
echo 'PATH="$PATH:/root/xenapi-admin-tools/releases/4.1"' >> ~/.bashrc 




Published in XCP Howtos
Monday, 03 December 2012 00:28

Install XCP/Xenserver from a USB thumbdrive


  • A Linux or Windows PC
  • USB Thumbdrive



If you're using Windows you need to download Unetbootin. Most Linux distributions include it in their repositories so you can install it using the standard Linux package managers (yum, apt-get, zypper,synaptic etc.). You will also need to download the Xen Cloud Platform installation CD or the Xenserver 6.2 installation CD and save it somewhere.


Setting up the USB thumb drive

The USB thumbdrive has to have a partition on it and it has to be formatted FAT32. Unetbootin will let you use other Thumbdrives but they just won't work and they won't really tell you why. Just make it FAT32 and you shouldn't have any problems.


  1. Make yourself root using su or sudo.
  2. fdisk <device>
  3. Create a new partition and change the partition type to vfat
  4. Save the partition
  5. Format it using mkfs -t vfat <device>















Installing XCP on the thumbdrive

  1. Mount the partition with the mount command or just remove the thumb drive and reinsert it (usually works)
  2. Start unetbootin
  3. Select Diskimage and then your XCP 1.6 ISO image that you downloaded
  4. Select USB Drive under Type
  5. Select your thumb drive device
  6. Press OK


















Fixing the thumbdrive so it will boot properly

The isolinux is used to boot ISO9660 disks like cdroms. We need to change the config so it uses syslinux which is used to boot hard disks.

cd into your mounted thumbdrive and copy/paste the following commands

mv boot/isolinux/isolinux.cfg boot/isolinux/syslinux.cfg
mv boot/isolinux boot/syslinux
mv syslinux.cfg syslinux.cfg.bak









You're done. Insert the thumbdrive into your future XCP host and reboot. You may need to go into the BIOS to change the boot order so it will boot from a USB device.


  1. Although I mentioned you can do this from Windows I won't be providing any support for it because I don't use Windows
  2. The thumbdrive needs to be formatted as FAT32 only
  3. Unetbootin has a tendency to just add files to the thumbdrive so make sure you format the thumbdrive between uses
  4. Not renaming the syslinux/isolinux files will get you an Unfound kernel error on boot


A common error is getting the dreaded mboot.c32: not a COM32R image  message. This seems to be because on some versions of the XCP install media the mboot.c32 file is not quite right. The last time I had to fix this I created a Xenserver 6.2 USB thumbdrive (which worked) and copied the /boot/syslinux/mboot.c32 file from there into my XCP 1.1 USB thumbdrive (which got the error listed above). Copy the good mboot.c32 file to the USB thumbdrive's /boot/syslinux folder. This solved the problem for me and so far I've only had it with XCP 1.1.

Published in XCP Howtos
Monday, 13 January 2014 18:19

Install xe on CentOS6

Sometimes you want to control your XCP/Xenserver pool from another host. In my case it's my firewall/iSCSI SAN box which is CentOS 6.5 X86_64. I could just remote execute xe using SSH but this doesn't allow me to set $XE_EXTRA_ARGS. Setting $XE_EXTRA_ARGS allows me to run xe commands remotely without having to specify the server, username, password or port number every time I run xe.


export XE_EXTRA_ARGS="server=${POOL},port=${PORT},username=${USER},password=${PASSWORD}"


A better choice is to install xe on the CentOS 6.5 host. 

Install pre-reqs

Install stunnel

yum install stunnel


 Install xapi-xe rpm from Xenserver CD

Because the Control Domain in Xenserver is 32 bit the xe command included is also 32 bit. If you have 64 bit CentOS you will need to install 32 bit glibc. The best way is to just let yum worry about it as apposed to using rpm.

If you already have a XenServer CD available you can copy the xapi-xe rpm to your CentOS host directly. If not follow the directions below.

mkdir xsiso
mount -o loop XenServer-6.2.0-install-cd.iso xsio
yum install xsio/packages.main/xapi-xe-0.2-5669.i686.rpm


 Control remote poolmaster using xe

 Because the poolmaster is remote you'll need to include the server, port, username and password in your commandline. 

xe -s <poolmaster> -p 443 -u root -pw <root password> vm-list

You can set these items in the XE_EXTRA_ARGS variable to make using xe easier.

export XE_EXTRA_ARGS="server=${POOL},port=${PORT},username=${USER},password=${PASSWORD}"
xe vm-list
Published in XCP Howtos
Wednesday, 23 September 2009 10:00

Install Xen 3.4 on CentOS 5 (32 bit) the easy way


1. First we need to add the YUM repository holding the updated Xen. You will need to be logged in as root to carry out these instructions


wget -O /etc/yum.repos.d/CentOS-GITCO.repo

2. Uninstall and reinstall the Virtualization group

yum groupremove Virtualization
yum update
yum clean all
yum groupinstall -y Virtualization
Published in Xen Howtos

1. First we need to download the YUM repository file for the updated Xen. Then uninstall the old Virtualization group and reinstall it. This will upgrade the packages.

wget -O /etc/yum.repos.d/gitco.repo
yum groupremove Virtualization
yum groupinstall -y Virtualization

Yum will probably want to upgrade some other files along with the ones we've chosen.

Warning! If you get an error message from grubby this is bad!

Installing: kernel-xen                   ####################### [ 9/13]
grubby fatal error: unable to find a suitable template

This means that your grub.conf file couldn't be written to for whaterver reason so you won't be able to successfully reboot. If you get this message you need to edit your /boot/grub/grub.conf file and make the kernel lines match the kernel you installed.

Get your installed kernel version:

[ root@vs / ] rpm -q kernel-xen


Now edit your /boot/grub/grub.conf to match this

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/vgsys/lvroot
#          initrd /initrd-version.img
title CentOS (2.6.18-128.4.1.el5xen)
root (hd0,0)
kernel /xen.gz-3.4.0
module /vmlinuz-2.6.18-128.4.1.el5xen ro root=/dev/vgsys/lvroot rhgb quiet
module /initrd-2.6.18-128.4.1.el5xen.img

4. Reboot - no really I mean it.

5. Try it out by using the xm dmesg command

\ \/ /___ _ __   |___ / |___ / / _ \
\  // _ \ '_ \    |_ \   |_ \| | | |
/  \  __/ | | |  ___) | ___) | |_| |
/_/\_\___|_| |_| |____(_)____(_)___/

(XEN) Xen version 3.3.0 ( This email address is being protected from spambots. You need JavaScript enabled to view it. ) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) Tue Sep  9 20:18:14 CEST 2008
(XEN) Latest ChangeSet: unavailable
(XEN) Command line:
(XEN) Video information:
(XEN)  VGA is text mode 80x25, font 8x16
(XEN)  VBE/DDC methods: V2; EDID transfer time: 2 seconds
(XEN) Disc information:
(XEN)  Found 1 MBR signatures
(XEN)  Found 1 EDD information structures
(XEN) Xen-e820 RAM map:

That's about all. If you have any questions drop a comment here.

Published in Xen Howtos
Friday, 28 November 2008 22:19

Install xen-tools on CentOS 5.x


Download xen-tools, install rpmstrap and install xen-tools. If there's a newever version of xen-tools available substitute that filename

yum install -y rpmstrap 
tar -xzvpf xen-tools-3.9.tar.gz
cd xen-tools-3.9/
make install

I've not using xen-tools that much but I wanted to put together a tutorial anyway. Let me know how it goes.

Published in Xen Howtos
Wednesday, 23 January 2013 22:54

Install Xenapi Admin Tools from github

The Xenapi Admin Tools are starting to  become so useful that I don't like having XCP hosts without them. Currently you can go to and download the archive onto your host, extract it and then copy the tools to your PATH. This however, is a lot of work since they get updated often. In the coming weeks (months?) I'll be finishing the Yum repo for Xenapi Admin Tools so the XCP package manager can keep them up to date. Until I get that accomplished however it may be easier to just install git and clone the github repository. Every time you want to get updates you'd just cd into the xenapi-admin-tools directory and run git pull.


With that in mind we have to add the EPEL repository where git is housed in order to use Yum to install it.


Install the EPEL repo

rpm -ivh


Install git

yum install git


Disable EPEL repo

The EPEL repository is enabled by default so we didn't have to do anything special to install git. However, you may not want it enabled all the time because packages that EPEL hosts may replace XCP specific packages and mess up your system

sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo


Configuring git

To use git to clone our Xenapi Admin Tools repository you'll need to set a few configuration items.

git config --global "Your User Name"
git config --global "Your Email Address" git config --global credential.helper cache git config --global credential.helper 'cache --timeout 3600'


Now that git is configured you'll want to clone the repository.

cd /root
git clone


This will create a xenapi-admin-tools directory in /root. The tools are in xenapi-admin-tools/releases/<version number> so you'll probably want to copy them to somewhere in the system PATH (or make a symbolic link). I personally use a /root/bin directory to hold them.



Published in XCP Howtos
Page 4 of 7