Upgrading ESXi 4.0 to ESXi 4.1 via the VMware CLI (Command Line Interface)

Today I had cause to upgrade my firm’s ESXi server from version 4.0 to 4.1. Unless you are lucky enough to own a license of VMware vCentre (and use the update mechanism in this, which I confess I’ve never even looked at) your best option to run the update is from the command line, via VMware’s CLI. Once you get going with this, it really is quite a nice method.

This guide is based on using the free CLI from VMware, running on Windows 7 x64, alongside the vSphere client (version 4.0, from the start off). Please note this is an upgrade guide only, and I won’t be going in to installing ESXi from scratch in this article.

Start by safely shutting down all running virtual machines on your live ESXi server.

Load up the vSphere client (version 4.0) and put the ESXi server into maintenance mode.

Visit www.vmware.com to download the Zip file update of ESXi 4.1. If you haven’t already, you will need to create a free account with VMware, in order to obtain access to all ESXi 4.1 and older downloads (as well as your free license code). Look on the site for the free download of “VMware vSphere Hypervisor”. Note that VMware have decided to change the name in some documentation and site pages to this, but for the sake of this blog I will refer to the new release still as ESXi 4.1. The file you need to download is listed as “ESXi 4.1 (upgrade ZIP from ESXi 4.0)”. I recommend you save this update directly to the C: drive root on your computer, as I have done for this tutorial.

If you don’t already have it, download and install the VMware vSphere CLI (Command Line Interface) from http://communities.vmware.com/community/vmtn/vsphere/automationtools/vsphere_cli and install on your local Windows client. This installer includes ActivePerl – an environment needed for CLI to work.

From your Windows client load up the Windows command line (cmd), ensuring you have full admin rights applied if running Vista or later. Type one of the following from the command prompt in order to get in to the CLI script folder:

For 32-bit OS:
cd C:\Program Files\VMware\VMware vSphere CLI\bin

For 64-bit OS:
cd C:\Program Files (x86)\VMware\VMware vSphere CLI\bin

To list all patches already applied to your ESXi install, type in the following command:

vihostupdate.pl –query server username root password PASSWORD

This will list all patches and updates already installed on your ESXi server (since the last major update), as below. (In the above command, substitute the server IP address to your own ESXi server’s IP, and PASSWORD to be your case sensitive root access password you use).

To analyse the contents of the zip file update you’ve downloaded VMware, and compare it to the patches already installed on your ESXi 4 server, run the following command (same substitution rules apply):

vihostupdate.pl –server –username root –password PASSWORD –scan –bundle c:\upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip

This will produce an output, somewhat similar to the below. Note, this will list all patches within the update that your ESXi server doesn’t already have installed.

This output tells us that the bundle contains the two patches that upgrade us from 4.0 to 4.1, and that these aren’t currently evident as part of your existing install.

Now you’re ready to run your update. Needless to say, by the time you’ve got this far make sure you have backed up all your virtual machines (and their contained data), and your current ESXi install. Things can go wrong, and you must always have a fall back plan. You’ve been warned!

So from here, run the command below (with substitutions as before) to start the update…

vihostupdate.pl –server –username root –password PASSWORD –install –bundle c:\upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip

A message should be returned and read:

“Please wait patch installation is in progress …”

Be patient. It can take quite a few minutes for the install to complete. Once it does a message should read:

“The update completed successfully, but the system needs to be rebooted for the changes to be effective.”

If you haven’t already, fire up your vSphere client and reboot ESXi from the GUI.

Post a reboot of ESXi, attempt to re-logon from the vSphere client, and you will be prompted to update your vSphere client. Either run the installer, or download and install the client update manually – you won’t be able to access ESXi till you do.

Back to the command line, run the following query command again to verify updates:

vihostupdate.pl –query –server –username root –password PASSWORD

A result should be returned as follows:

This shows the update has applied successfully, and you are running ESXi 4.1. You can also check build versions from the ‘About’ menu option in the vSphere client software.

Finally, take your newly upgraded ESXi 4.1 server out of maintenance mode in the vSphere client, and start all your live virtual machines. Upgrade Vmtools in each VM (with reboots), then you’re done!

One thought on “Upgrading ESXi 4.0 to ESXi 4.1 via the VMware CLI (Command Line Interface)”

Comments are closed.