Detecting VMware ESX version from the guest OS

Submitted by dag on Wed, 2008/10/08 - 18:25

For a customer we needed to know what the version of the ESX server is when provisioning a VMware guest. Since the VMwareTools package is significantly different for an ESX 2.5, ESX 3.0 or ESX 3.5 it was important that during the automated installation we selected the correct VMwareTools version.

When I have questions about VMware that go beyond my expertise I consult friend and VMware consultant Bert de Bruijn and also this time we looked at possible ways to find the information.

The easiest would have been that the VPD information contained the ESX version, but that would have been too simple for VMware :-) So we then compare the DMI information of dozens of guests with the known ESX release of the host and Bert wrote down his conclusion on his blog.

The solution is in the BIOS address, BIOS size and BIOS release date.

I wonder why VMware is not providing this information from the DMI System product name and System version like other hardware vendors do.

It would be nice if people running VMware update his article with more information about other versions so the list can be maintained for the future.

The resulting code generalized looks like this:


ESXTYPE="$(dmidecode | grep -A4 "BIOS Information" | grep Address: | awk '{print $2 }')"

case "$ESXTYPE" in
(0xE8480) HWMODEL="esx25";;
(0xE7C70) HWMODEL="esx30";;
(0xE7910) HWMODEL="esx35";;
(*)
echo "Error: ESXTYPE $ESXTYPE not mapped to HWMODEL." >&2
exit 1
;;
esac

case "$HWMODEL" in
(esx25) TOOLSRPM="VMwareTools-2.5.2-32233.cust.i386.rpm";;
(esx30) TOOLSRPM="VMwareTools-3.0.2-55869.i386.rpm";;
(esx35) TOOLSRPM="VMwareTools-3.5.0-82663.i386.rpm";;
(*)
echo "Error: HWMODEL $HWMODEL not mapped to TOOLSRPM." >&2
exit 2
;;
esac

Update: I removed the minor release number because it is not relevant when detecting the ESX server version.

Missing shebang

Nice work - but IMHO it would be good for you to put the http://en.wikipedia.org/wiki/Shebang_(Unix) at the beginning of this script so folks know how to run it:

#!/bin/sh

It looks like shell script to me... but maybe not to everyone out there, and that's assuming you use sh and not csh or ksh... :-)

Nice one!

Cheers
Steve

BTW. I'll forward this link to our tools group and see what they say about exposing the ESX / VMtools version.

Piece of a script

Well, I guess the reason there is no shebang is because it is not intended as a stand-alone script but rather a piece that was integrated (in different form) in a provisioning system.

For instance, the logic to determine that the system in fact is a VMware is missing as well as all the other physical hardware determination pieces.

But you are correct, I could have indicated it was Bash :) On the other hand, people that could not figure that out shouldn't care about the article anyway ;-) To me the lack of any indentation is more concerning. I guess I need to look for a better Drupal theme :-/

Results for VMware Server 2.0

Hi,

I thought you might want to let your friend Bert know the info for VMware server 2.0.0:

~# dmidecode|grep -A4 "BIOS Information"|more
BIOS Information
Vendor: Phoenix Technologies LTD
Version: 6.00
Release Date: 07/29/2008
Address: 0xEA6C0
~#

Looks like the same as he said for WS6.5

Regards,
Mike

thanks

Hi Michael, thanks for posting the results for VMware Server 2.0.
They look similar to the results for WS6.5 indeed (and to the presumed results for ESX4 beta), but not completely identical. Same Address, different Release date (and you didn't post the size, is that the same ?)

Results for vSphere ( esx40)

0xEA550

1 less piped command

Since awk can do pattern matches without getting too ugly, here is 1 less grep to get the BIOS address

dmidecode | grep -A4 "BIOS Information" | awk '/Address:/ { print $2 }'