• View Communities
    • Citrix Communities
      Visit the Citrix Communities to get and share technical information and best practices about desktop delivery, datacenter, networking and cloud computing solutions.
    • Citrix Blogs
      Learn the latest from the Citrix employees who are building the future of virtual computing.
    • Citrix Developer Network
      The place for unfiltered straight talk on Citrix products. Find related blogs, best practices, code downloads, APIs and more.
    • Citrix Ready Community Verified
      Does it work with Citrix? Application compatibility questions are a thing of the past with the new Citrix Community Verified site.
  •  Sign In
Citrix Developer Network

Configuring CentOS 5.5 Guests on XenServer 5.5 and 5.6

CentOS 5.5 32-bit or 64-bit (this applies to XenServer v5.5 or later)

This article provides details on how to install CentOS5.532-bit or 64-bit but should be repeatable for other Linux distributions based on RHEL such as Oracle Enterprise Linux.  This is based on installation style 1.
Listed below is an outline of the overall process:
-          Create a "CentOS 5.5" template copying the existing "CentOS 5.3" template (or  the provided script for XenServer 5.6)(Download Script)
-          Perform an installation of the CentOSguest OS( in this exampleCentOS5.564-bit)
-          Install XenTools
-          Activate VNC to allow the GUI console to be integrated into XenServer
The ISO file for this distribution media can be obtained from http://www.centos.org.
The CentOS 5.5 distribution already comes with a xen enabled kernel.

Historically, releases of CentOS 5.x did not contain a Xen enabled kernel of sufficient quality that Citrix was able to support. Citrix XenServer therefore supplied an updated version of the RHEL 5 kernel (CentOS is derived from sources provided in opensource by Red Hat) . With the release of CentOS 5.4 and the 2.6.18-164.el5 Red Hat kernel,CentOS has incorporated the required fixes to bring the standard CentOS kernel up to the required level for running as a XenServer VM.
Which allows the standard xen enabled CentOS kernel to be used.

Another item to note is that the CentOS ISOs contain aXenified kernel and ramdiskthat do not have any support for IDE CD-ROMs during installation. For releases prior to CentOS 5.5, XenServer is able to patch this on the fly and therefor still allow complete installations of a fully paravirtualized (xen) setup from the ISO or CD-ROM. This was not possible for CentOS 5.5, due to the release date of CentOS 5.5 and XenServer 5.6 being too close to each other. It is therefore necessary to perform the installation using a network installation pointing to a FTP/HTTP or NFS URL, as outlined in the rest of this article. The intention is to provide a fully support CentOS 5.5 template in a future version of XenServer.
Procedure for CentOS 5.532-bit/64-bit

1. Copy makecentos5_5.sh to Master
Using WinSCP or any SFTP client), copy makecentos5_5.sh to the /root directory on the Pool Master.   2.        

2. Execute makecentos5_5.sh to create the CentOS 5.5 templates.
In XenCenter open the console tab of the Pool Master to get to the bash prompt. Change the working directory to /root by executing "cd ~". Then make the "makecentos5_5.sh" script executable by issuing "chmod +x makecentos5_5.sh". Execute the script by issuing "./makecentos5_5.sh".
!image002.png!Two new templates will now have appeared in the XenCenter Template list for your resource pool, CentOS 5.5 (32-bit) and CentOS 5.5 (64-bit).

3. Create a new VM based from the"CentOS 5.5 (32-bit)".

4. Give the new VM a name.  
5. Select as the source for the CentOS installation media a network URL (FTP/NFS/HTTP), for this example we used a HTTP based source located on a network installation server on our intranet.  

6. Select automatic placement of home server for VM if possible.

 7. Select required CPU and Memory settings for VM, (this example uses 1vCPU and 1GB of memory). Note that they can also be changed later on when needed.
 

8. Add virtual disk storage, ( this example uses the default 8GB settings)

 

9. Select the required virtual network interface, ( this example uses a default single NIC settings plus a Management NIC)  

10. Finish VM creation and ensure VM is set to start automatically.  If you don't start it automatically you can if so required alter certain settings like for instance providing a kickstart file (Under Advanced OS Boot parameters)  
11.  Select  your language from the Red Hat Enterprise Linux Server installer boot menu.  
12.  For the TCP/IP Configuration during the installation select the needed IP configuration. For this example we will only use IPv4.

 13. For this installation we will use text mode, you can of course select the graphical VNC mode using an external VNC Viewer  
14. Continue the wizard as any normal CentOS installation.
When the installer is finished, reboot

15. Once the VM has booted the newly installedCentOS 5.5 guest operating system, login as root.  

16. Installing the XenServer Tools is very easy; attach the XenTools ISO by selecting VM->Install XenServer Tools.
Execute "mount/dev/xvdd /mnt" and then "/mnt/Linux/install.sh".
 

17. When the XenServer Tools installation scripted has successfully completed you will see the following under VM Guest Properties in XenCenter.
 

18. Now we have installed the XenTools we can activate the GUI integration of CentOS in XenCenter. For this XenServer uses VNC on port 5900. We therefore need to ensure that VNC is enabled.
a.       Configuring GDM to use VNC:

i. root in the VM, run the command rpm -q vnc-server gdm. The package names vnc-server and gdm should appear with their version numbers specified. !image018.png!If you see message saying that one of these packages is not installed then you may not have selected the graphical desktop options during installation. You will need to install these packages before you can continue. See the appropriate CentOS Installation Guide for details regarding installing additional software on your VM.

ii. Open the GDM configuration file (/etc/gdm/custom.conf)with your preferred text editor and add the following lines to the file after the empty [servers] section:
[server-VNC]
name=VNC Server
command=/usr/bin/Xvnc -SecurityTypes None -geometry 1024x768 -depth 16 -BlacklistTimeout 0
flexible=true

iii. Modify the configuration so that the Xvnc server is used instead of the standard X server:
Add the line 0=VNC just below the [servers] section and before the [server-VNC] section.
Save and close the file.
 iv.      Restart GDM for your change in configuration to take effect, by running the command /usr/sbin/gdm-restart
b.      Firewall settings
The firewall configuration should be set to allow VNC traffic to go. You might want to further customize your firewall configuration if you want to use IP connection tracking or limit the initiation of connections to be from one side only. By default, a VNC server listens for connections from a VNC viewer on TCP port 5900 + n, where n is the display number (usually just zero). So a VNC server setup for Display-0 will listen on TCP port 5900, Display-1 on TCP port 5901, and so on. XenCenterconnects on port 5900 to the VNC GUI.
                                                               i.      To customize Red Hat-based VMs firewall to open the VNC port
1. Use system-config-securitylevel-tui

2. Select "Customize" and add 5900 to the other ports list.
c.       Checking runlevels
Red Hat uses runlevel 5 for graphical startup. This section describes how to verify that your VM is configured to start up in runlevel 5 and how to change it if it is not.

i. Check /etc/inittab to see what the default runlevel is set to. Look for the line that reads:
id:n:initdefault:
If n is not 5, edit the file to make it so.

ii. You can run the command telinit q ; telinit 5 after this change to avoid having to actually reboot to switch runlevels


Now let's switch to the graphical console by selecting the "Switch to Graphical Console" button. !image023.png!This concludes the steps needed to install a fully functional CentOS 5.5 server VM on XenServer 5.5 or 5.6.
Additional steps that could be useful to automate the installation of CentOS VMs on XenServer.
-          Fix the installation source in the template
You can alter the templates to have the installation URL preconfigured. For instance to have it preset to http://mirror.centos.org/centos-5/5.5/os/i386/ for the 32-bit template and to http://mirror.centos.org/centos-5/5.5/os/x86_64/ for the 64-bit template.Which would install the CentOS VM straight from the Internet mirror.
This can be achieved in the following way:
From the CLI on one of the XenServers execute the following commands:
CENTOS=$(xe template-list name-label=CentOS\ 5.5\ (32-bit) -minimal)
xetemplate-param-set uuid=$CENTOS\
other-config:install-repository=http://mirror.centos.org/centos-5/5.5/os/i386/
Now the template will have preset the installation repository
-          Use a kickstart configuration file
Another automation feature is making use of CentOS custom kickstart files. A CentOSkickstart file is an automated installation method, similar to an answer file, you can use to provide responses to CentOS's installation prompts. This file can be found in /root/anaconda-ks.cfg after an installation and can among others be modified by the system-config-kickstart tool.
Let's modify our template to have it always use the http://files.ebc.citrix.it/linux/distros/CentOS/5.5/ks.cfgkickstart file for our CentOS5.5 installation.
The kickstart file location is a kernel command-line argument for the template, exactly as it would be specified in the PXE config file, for example
ks=http://files.ebc.citrix.it/linux/distros/CentOS/5.5/ks.cfg
From the CLI on one of the XenServers execute the following commands:
CENTOS=$(xe template-list name-label=CentOS\ 5.5\ (32-bit) -minimal)
xe template-param-set uuid=$CENTOS\
PV-args="ks=http://files.ebc.citrix.it/linux/distros/CENTOS/5.5/ks.cfg"
Disclaimer
Please note the following supportability disclaimer: Only OSs listed in the XenServer Virtual Machine Installation Guide arefully supported by Citrix Technical Support. The OS within this and related blogs are not supported and are installed at the users own risk.


Enter tags to add to this page:
Please wait 
Looking for a tag? Just start typing.
  1. Oct 02, 2010

    Anonymous says:

    With XenServer 5.5, I had a problem executing the script since the script is in ...

    With XenServer 5.5, I had a problem executing the script since the script is in dos format (^M char at the end of lines). I removed an annoying part of the script that checks the XenServer version. Here is how I fixed it.

    1. Go to root dir: cd /root

    2. Get the script: wget http://community.citrix.com/download/attachments/149652553/makecentos5_5.sh?version=1

    3. Make it executable: chmod +x makecentos5_5.sh

    4. (Optional) Make a backup of the script: cp makecentos5_5.sh makecentos5_5.sh backup

    5. Convert the script: yum install dos2unix --enablerepo=base

    6. remove the following lines from the script:

    if [[ -z $CENTOS ]] ; then
    echo "Cant find CentOS 5.3 32bit template, are you on XenServer 5.5 or higher?"
    exit 1
    fi

    7. Execute the script

    1. Nov 30, 2010

      Anonymous says:

      Yes, you must run dos2unix on the script. 1.) yum install dos2unix --enable...

      Yes, you must run dos2unix on the script.

      1.) yum install dos2unix --enablerepo=base

      2.) dos2unix makecentos5_5.sh

  2. Oct 06, 2010

    Thomas Weiss says:

    Very good how-to, except that the naming of the Templates in 5.5 is other than i...

    Very good how-to,
    except that the naming of the Templates in 5.5 is other than in 5.6.

    in 5.5 > "CentOS 5.3"
    in 5.6 > "CentOS 5.3 (32-bit)"

    Therefore i had to change the first line from
    CENTOS=$(xe template-list name-label=CentOS\ 5.3\ (32-bit) --minimal)

    to

    CENTOS=$(xe template-list name-label="CentOS 5.3" --minimal)

    to make the script work on xenserver 5.5

    best regards
    Thomas

  3. Oct 18, 2010

    Anonymous says:

    Caution: One template created using this method can not be removed! I didn...

    Caution:

    One template created using this method can not be removed!

    I didn't find a way to delete the created template.

    --------------------------------
    Joao

  4. Nov 11, 2010

    Anonymous says:

    Works like a charm. Thanks!

    Works like a charm. Thanks!

  5. Nov 16, 2010

    Anonymous says:

    !!! IMPORTANT INFORMATION !!! Maxed out my 35Mbit FIOS connection - Makes insta...

    !!! IMPORTANT INFORMATION !!!

    Maxed out my 35Mbit FIOS connection - Makes installations painless!

    By far the fastest CentOS mirror on the planet - Thanks Zuckerberg!

    http://mirror.facebook.net/centos/5.5/os/i386/

  6. Dec 15, 2010

    Daniel Brockmann says:

    hi, i managed to get centos 5.5 64bit installed. but i wasn't able to install t...

    hi,

    i managed to get centos 5.5 64bit installed. but i wasn't able to install the 32 bit variant. i followed your steps and tried internet installation sources as well as a locally http-mirrored dvd-image (64 bit installation went successfully that way, using a locally http-served dvd-iso).

    do you have any suggestions to get centos 32 bit installed?

    cu,

    daniel.

  7. Dec 17, 2010

    Robert White says:

    So this worked great, and i went production with the fix at the center of this h...

    So this worked great, and i went production with the fix at the center of this howto. I need to resize the partition, so I go to boot a LiveCD to use GParted, but there is no way to add any other bootable device, because the parts in the script don't include any additional hardware. It may be an easy fix for someone, but a huge struggle for me. Any help on this matter would be welcome.

    1. Dec 18, 2010

      Robert White says:

      Create a Windows XP SP3 or similar VM with boot drives and name it "Maintenance ...

      Create a Windows XP SP3 or similar VM with boot drives and name it "Maintenance Mode" or something similar to avoid confusion later. Delete the disk that is created with the Windows XP SP3 VM. Detatch the disk on the CentOS machine and attach to the Maintenance Mode VM. Boot a LiveCD or other ISO image.

      When finished manipulating the virtual disk, detatch it and reattach to the original CentOS VM

      1. Dec 21, 2010

        Robert White says:

        This defeats the purpose of having a Xenified kernel on boot. Grr...

        This defeats the purpose of having a Xenified kernel on boot. Grr...

  8. Dec 18, 2010

    Robert White says:

    I made a CentOS appliance using the facebook mirror, and it was really fast. But...

    I made a CentOS appliance using the facebook mirror, and it was really fast. But now I can't seem to create a new VM using any CentOS mirror. I remember needing to remove the trailing slash from http://centos.mirror.facebook.net/5.5/os/i386/ but i can't get it to work. Any ideas?

    1. Dec 18, 2010

      Robert White says:

      to be more specific, the stage2.img loads from http://centos.mirror.facebook.net...

      to be more specific, the stage2.img loads from http://centos.mirror.facebook.net/5.5/os/i386/images/xen/, but after i have my installation configured correctly, the install tells me that some package can't be found. I believe it to be because of the trailing forward slash, but removing it doesn't change the installer from failing to read the first package of the installation. Any ideas?

  9. Feb 28, 2011

    Anonymous says:

    Hi Great post, I coud install Centos and XenTools ok. But VNC doesn´t work, swi...

    Hi

    Great post, I coud install Centos and XenTools ok. But VNC doesn´t work, switch to the graphical console button appears but disabled. Typing Xvnc in Centos console fires an error "no screens found".
    What is missing?

    Thanks.

    1. Feb 28, 2011

      Anonymous says:

      I tried CentOS 5.5 installation many times and now I got it working fine on XenS...

      I tried CentOS 5.5 installation many times and now I got it working fine on XenServer 5.6. VNC remote access 1024x768 GUI is running smothly!
      Thanks for this tutorial...

Related Links