Category: linux

XenServer Auto Patcher

I put together a little script that might come in handy to get Citrix XenServer fully up to date after doing a factory install. You can find it here:

https://github.com/amesserl/xs_patcher

It will detect the version of XenServer you are running and install all of the latest Citrix XenServer hotfixes that are available in sequential order. It will also detect any previous patches and install anything that might not be present. If you don not have the hotfixes on the machine, it will retrieve them for you. After running the script, all you will need to do is reboot so it will pick up the latest kernel.

To install it automatically during an install, you will need to put the patcher script on the disk with the cache prepropulated with all of the patches to avoid the script retrieving them each time. It’s usually best to put this in place during the post install. You won’t want to run it during the post install because XAPI isn’t up and running at that point which the hotfixes require. You’ll want to install a script into /etc/firstboot.d with a starting number higher than all the other processes that run during firstboot. Once the initial firstboot has run which sets up XenServer and all of it’s storage repositories, you can then kick off the xs_patcher.sh script which will install all of the needed hotfixes. I usually then have one more call to reboot occur after that.

I’ll try and maintain the script going forward as new hotfixes are released by Citrix. Currently it supports Boston, Sanibel, and Tampa. I’ll probably go back and grab earlier versions as well in the future as I have time.

The Dreaded Flipping of NICs

I recently had a problem with NICs flipping around after removing all traces of MAC address rules from the server. I did this because I wanted the flexibility to be able to swap machines around at any point in time and not have to worry about tracking the MAC addresses on all of the devices. The gear was identical in specifications and after doing some research, I ran across a solution that has worked really well so far. It involves creating udev rules that don’t contain any MAC addresses but that instead check the vendor id and bus location of the device. By knowing these items, you can guarantee you’ll always have the correct ethernet device assigned to the correct physical network and you can make the rules a lot more generic in nature. As an example, first you’ll want to identify the devices (example is from an HP ProLiant DL385):

1
2
3
4
lspci | grep -i eth
04:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet (rev 12)
42:00.0 Ethernet controller: Broadcom Corporation
NetXtreme II BCM5708 Gigabit Ethernet (rev 12)

We’ll take the first line for this example and break it down. The first group of numbers is the bus number (04), device number (00), and function
number (0). From here we should be able to generate our udev rules file. Create /etc/udev/rules.d/70-persistent-net.rules and enter in the following or whatever your setup looks like:

1
2
SUBSYSTEM=="net",ACTION=="add",BUS=="pci",KERNEL=="eth*",ID=="0000:04:00.0",NAME="eth0"
SUBSYSTEM=="net",ACTION=="add",BUS=="pci",KERNEL=="eth*",ID=="0000:42:00.0",NAME="eth1"

Once that’s in place, you should be able to reboot and not have to worry about the NICs flipping around. If you’re curious, you can also view more device information by looking at /sys:

1
ls -la /sys/bus/pci/devices/0000:04:00.0

I’ve had success with this in Citrix XenServer (dom0 is based on CentOS) and Debian.