måndag, augusti 04, 2008

Patching VMware ESX 3.0.1, with VMware ESX patches

One way to do this of many.. :)
This patching procedure asumes no Virtual Center just standalone ESX w NAS (NFS)

First download and install Patch ESX-5874303

VMware ESX Server 3.0.1, Patch ESX-5874303: Update to the esxupdate Utility
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=5874303

# /usr/sbin/esxupdate -v 10 -noreboot -r file:/mnt/ESXPatches/ESX-5874303


Then create list of extracted patches within /mnt/ESXPatches/

#!/bin/sh
#
# Create list of patchid's in /mnt/patches to patchesList.txt
cd /mnt/ESXPatches
rm patchesList.txt
ls -l | grep '^d' | awk '{ print $9 }' > patchesList.txt
echo DONE
echo /mnt/ESXPatches/patchesList.txt created


Now we are ready to install every patch that been downloaded and installed

patchESX.pl
#!/usr/bin/perl
# patchESX.pl -- auto update esx perl script
# by Vincent Vlieghe
# Version 6/03/2007
# Edited by Niklas Eriksson
use LWP::Simple;
$patchlist = get 'file:///mnt/ESXPatches/patchesList.txt';
@array = split(/\n/, $patchlist);
foreach $item (@array)
{
print $item;
$item = trim($item);
$cmdQuery = "/usr/sbin/esxupdate query | grep $item";
if(system($cmdQuery) == 0)
{
print "\n$item is already installed - skipping\n";
}
else
{
print "\n$item is not yet installed - installing\n";
$cmdUpdate = "/usr/sbin/esxupdate -v 10 -n -r file:///mnt/ESXPatches/$item update";
system($cmdUpdate);
}
}
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

Now we can verify installed software and REBOOT our server!!!

[root@esx1 bin]# /usr/sbin/esxupdate -l query
Installed software bundles:
------ Name ------ --- Install Date --- --- Summary ---
3.0.1-32039 18:14:49 10/11/07 Full 3.0.1 release of VMware ESX Server
ESX-2158032 12:12:28 10/12/07 Add LFENCE for RWO on AMD K8 before RevF
ESX-1410076 12:15:33 10/12/07 BSOD 0x109 during 64-bit Windows install
ESX-1006511 12:16:10 10/12/07 Fixing TX hang in 80003ES2LAN Controller
ESX-9986131 12:16:54 10/12/07 Updated openssh, python, and openssl
ESX-8173580 12:18:11 10/12/07 Fix COS Oops running Dell OM5 w/ QLogic
ESX-6921838 12:20:38 10/12/07 hot removal of a virtual disk thru SDK
ESX-2066306 12:21:08 10/12/07 Patch for VM crashes and possible freeze
...

Shutdown ESX 3.0.1 VM's from console

Small script for VMware ESX 3.0.1

VMShutdown.sh
--------------------
#!/bin/sh
# VMware ESX 3.0.1
# Get VM state, shutdown running VM's
# From http://www.mgeups.com/download/soft/install/linux/nsm/how_to_vmware_en_1_2.pdf
# VMware tools MUST be installed in each VM for this script to work
#
VMLIST=`/usr/bin/vmware-cmd -l`
for VM in $VMLIST
do
VMSTATE=`/usr/bin/vmware-cmd "$VM" getstate -q`
# Guest OS shutdown if VMSTATE is equal to "on"
if [ "$VMSTATE" == "on" ]
then
/usr/bin/vmware-cmd $VM stop trysoft hard
echo Waiting 10 SEC
sleep 10
fi
done
echo ----------------------------------------------------------------
echo DONE, check for errors if VM's don't have VMware tools installed
echo ----------------------------------------------------------------

fredag, augusti 01, 2008

Extract several VMware ESX patches within one directory (ESX 3.0.1 Console)

I wanted to extract all archives with one line.

First mounting my NFS share (R/W)
#mount 172.16.1.20:\ESXPatches /mnt/ESXPatches
#cd /mnt/patches
#ls
..
ESX-9986131.tgz
ESX-8173580.tgz
..

Action begins here;

root@esx1 patches]# for i in *.tgz; do tar -xzvf $i;done
ESX-1000039/
ESX-1000039/VMware-esx-scripts-3.0.1-42368.i386.rpm
ESX-1000039/VMware-esx-vmkernel-3.0.1-47426.i386.rpm
ESX-1000039/headers/
ESX-1000039/headers/VMware-esx-scripts-0-3.0.1-42368.i386.hdr
ESX-1000039/headers/VMware-esx-vmkernel-0-3.0.1-47426.i386.hdr
ESX-1000039/headers/header.info
ESX-1000039/descriptor.xml
ESX-1000070/
ESX-1000070/VMware-esx-scripts-3.0.1-42368.i386.rpm
ESX-1000070/VMware-esx-tools-3.0.1-47426.i386.rpm
ESX-1000070/VMware-esx-vmx-3.0.1-47426.i386.rpm
..
..

Seems OK!

Now I just need to wait for rest of 118 archives untaring..

Cheers!