Fastest way to patch Xenserver using a script

Updating a new or existing Xenserver with multiple updates, is a time consuming task, as the GUI only allows to install one by one patch, and reboots between every patch. Some of the patches is also included with newer patches, so you may save some time by walking through each one from the newest to find out which one is included.

I found a Xenserver script to download and install on the fly by Sean Flattery: http://forums.citrix.com/thread.jspa?threadID=307074&tstart=0

I’ve modified this script to first download, and then apply them in as separate script. This is because if a patch is already there, the script will fail to install the patch. You need to download all patches and unzip them to a webfolder before running the script. Enter the URL to the webfolder in the script. I’m using a public dropbox folder for this, but then the Xenservers needs to have internet access. You can use this powershell script to download and unzip all kinds of Citrix hotfixes, directly from Citrix support website: http://virtexperience.com/2012/11/30/ctxupdate-a-powershell-script-to-download-any-citrix-updates/

for PATCH in XS61E015 XS61E020 XS61E018 XS61E022 XS61E017 XS61E012 XS61E010
do
wget http://mywebserver/$PATCH.xsupdate 
UUID=`xe patch-upload file-name=$PATCH.xsupdate | awk '{print $2}'`
echo "$UUID"
done

You only need to download patches once for each pool. The patch list above is all you need for Xenserver 6.1, to download all 6.02 patches, replace the first line with this:

for PATCH in XS602E006 XS602E010 XS602E019 XS602E024 XS602E026 XS602E027

When download is complete, these patches will now be ready for installation in the Xenserver pool. You may now apply all patches to a specific host and then reboot later. Remember if this is a pool, you need to do this on the master first, and remember to migrate off all workloads from this host manually first. Please replace hostuuid in the script with the UUID of the host you want to patch. User xe host-list to get host UUID

PATCHLIST=`xe patch-list | grep "uuid ( RO) " | awk '{print $5}'`
for UUID in $PATCHLIST
do
echo "Installing patch $UUID"
xe patch-apply host-uuid=(hostuuid) uuid=$UUID
done

When this script is complete, reboot the host and continue on the next host.

UPDATE!

Before applying updates, remember to eject XS-TOOLS CD from all running VM’s.

When using this script I’ve seen that you are unable to boot xenserver after patch is complete whenever you have mulitpath enabled. Here is a blogpost that describes how to solve this: http://xdguy.wordpress.com/2012/10/17/xenserver-5-6-sp2-hangs-after-hotfix-19-applied/

Also from same blog, how to determine what driver disks you need to update: http://xdguy.wordpress.com/2013/04/18/xenserver-6-0-2-hotfix-and-driver-disk-install-summary/

4 thoughts on “Fastest way to patch Xenserver using a script

  1. Pingback: Fastest way to patch Xenserver using a script | Conde Malagueta

  2. Thought I’d share this too-https://github.com/dalgibbard/citrix_xenserver_patcher

    Pulls the updates directly from Citrix’s site, and auto-obtains a list of required updates from Citrix’s XML API. Therefore, no need for user intervention or manual definition of the patch names/locations.

  3. Make sure you have enough free space in HD.
    # df -k
    make sure at least 20% free space (or 80% used)
    If not enough, delete unused gz in /var/log
    I recently can’t apply latest XS6.2 patches because not enought space.
    The patch is >300mb
    Apply patches in master first.
    Evacuate host from HA first

Leave a Reply

Your email address will not be published. Required fields are marked *

*