Patch ESXi using ESXCLi Commands
Last week we discussed how to patch ESXi hosts using VMware Update Manager. However, leveraging Update Manager is not always feasible, so in this post, we’ll walk through the process of installing patches using ESXCLi commands. If you are comfortable executing ESXCLi commands, this process can be completed with relative ease.
In this instance, we will be installing a third-party (HPE iLO) VIB. If you are unfamiliar with VIBs (vSphere Installation Bundle), they are collections of files packaged for installation. VIBs are typically comprised of solutions, drivers, CIM providers or applications. VIB installations can be performed using a local or http setup. The local setup requires the VIB to be manually downloaded from the provider and subsequently uploaded your datastore. The http setup allows the VIB to be obtained from the provider’s online repository. More information on the setups can be found here. For our example, we will utilize the http setup with HPE’s online repository (vibsdepot).
Put Host in Maintenance Mode
To begin the process, enable and SSH to your host. Once logged in, put the host into maintenance mode and ensure virtual machines are migrated off the host. Run the vim-cmd hostsvc/maintenance_mode_enter command to enter maintenance mode.
Update or Install VIB
Once the host is in maintenance mode, run the esxcli software vib command to either install or update the VIB on your host. We will be installing the VIB via the HPE repository, so the command will look like:
esxcli software vib install -v viburl/vibname.vib
As per VMware:
- The update command is recommended for patch application. The update command applies all of the newer contents in a patch, including all security fixes. Contents of the patch that are a lower revision than the existing packages on the system will not be applied.
- The install command overwrites the existing packages on the host with contents of the patch you are installing. This includes installing new packages and removing old packages.
If you are unsure of which command use, this KB is a great resource.
After successful patch installation, reboot the host for the changes to take effect. Run the reboot command to initiate.
Exit Maintenance Mode
After the host boots, exit maintenance mode by running:
vim-cmd hostsvc/maintenance_mode_exit