01 August 2011

Installing XenServer

I’ve been using VirtualBox on a Windows server host for sometime now but I want to be able to utilise the full power of my host for VMs and this is only really possible if you have what I call a ‘raw’ setup i.e. rather than having a full OS ‘under’ your VM you have a basic cut down OS whose only task is to run VMs. There are many options for this kind of solution but I’m going with XenServer for now as it has been recommended to me.


  1. Download the ISO from: http://www.citrix.com (go to XenServer/Download Now to get Free XenServer)
  2. Burn the ISO to disk: put a blank CD disk in the drive, double click the ISO in Windows and choose the drive.
  3. Put the disk in the drive and turn the system on.
  4. Answer the various questions, including which disk to install onto. I also installed the Linux supplemental pack and Verified the installation source
  5. Install XenCenter (the desktop client for XenServer):
    1. Browse to http://[ip of the XenServer host] and click on XenCenter installer.
    2. Once installed add the server.
    3. Request a key: Tools/License Manager

Installing a Supplemental Pack on a running host

It’s much easier to install supplemental packs at install but you may not have the them at installation so want to install them retrospectively:
  • Download them from http://www.citrix.com go to http://www.citrix.com XenServer, Downloads then login to go to the XenServer version and view downloads.
  • Mount the network share:
    • Edit hosts to give the source computer a name
      vi /etc/hosts
      [ip of computer] [name]
    • Create destination for mount:
      mkdir /mnt/[share name]
    • Edit fstab to add line for the mount:
      vi /etc/fstab
      //[server name]/[share name]  /mnt/[share destination name]  cifs exec,credentials=/etc/cifspw 0 0
    • Create a file with the windows credentials:
      vi /etc/cifspw
      i (to enter insert mode)
      username=[domain or computer name]/[username]
    • Secure the file: chmod 600 /etc/cifspw
    • Mount it: mount –a
      NB if you get Permission denied try adding your computer name as a prefix to username eg:
      username=[domain or computer name]/[username]
    • Check it worked:
      ls /mnt/[share name]
  • Mount the iso and run:
    mkdir /tmp/iso
    mount -o loop /mnt/[share name]/XenServer-5.6.1-fp1-linux-cd.iso /tmp/iso
  • Run the install:
    cd /tmp/iso
  • Clear up:
    umount /tmp/iso
    rmdir /tmp/iso

Create a VM

Once installed and running you may need to download some isos to set up a VM. You can do this from the command line using:
wget 'http://www.ubuntu.com/start-download?distro=server&bits=64&release=latest' –O [output filename]
Alternatively you can install across the network. e.g. select URL and enter a source e.g. http://ftp.uk.debian.org/debian/
Then using XenCenter setup a new VM.
  • Install the XenServer Tools on the Guest
    In Linux:
    cd /mnt
    sudo mkdir xs-tools
    sudo mount /dev/xvdd /mnt/xs-tools/
    #mount: block device /dev/xvdd is write-protected, mounting read-only
    cd /mnt/xs-tools/Linux/
    bash install.sh
NB: If you haven’t used a template I found you might fail to mount the drive. Here is a tutorial on creating a new template: http://forums.citrix.com/thread.jspa?threadID=286471&tstart=0

Auto Startup a Virtual Machine

  1. Get the UUID of the VM:
    xe vm-list
  2. Set it to autostart:
    xe vm-param-set uuid=[UUID of VM] other-config:auto_poweron=true

Auto Shutdown

I wanted to shutdown the server daily to conserve energy. I found the answer on the Citrix forums here but in case that moves or gets deleted I include a summary here:
  1. Find your Server name and VM names with:
    xe vm-shutdown vm=<TAB><TAB>
    xe host-shutdown host=<TAB><TAB>
  2. Log in to the server via SSH
    Create the script in vi:
    vi /usr/local/etc/shutdownscript.sh
    Enable insert mode: i
  3. Type:
    xe vm-shutdown vm=VMNAME1
    xe vm-shutdown vm=VMNAME2
    xe host-disable host=HOSTNAME
    xe host-shutdown host=HOSTNAME
    End insert mode and write the script to disk with:
  4. Make it executable:
    chmod 700 /usr/local/etc/shutdownscript.sh
  5. Get cron to start at at 10pm:
    crontab –e
    Enable insert mode:
    Insert the following line:
    * 22 * * * /usr/local/etc/shutdownscript.sh
    End this edit and write back the crontab with:
  6. Restart cron:

1 comment:

  1. Great Post, took forever to find a working cifs explanation for /etc/fstab!