VMware ESXi 6 and 7: checking and setting/clearing maintenance mode from the console
Posted by jpluimers on 2021/04/21
Every now and then it is useful to be able to do maintenance work from the ESXi console addition to the ESXi web-user interface.
I know there are many sites having this information, but many of them forgot to format the statements with code
markup, so parameters with two dashes --
(each a Wayback Unicode Character ‘HYPHEN-MINUS’ (U+002D)) now have become an [Wayback] Unicode Character ‘EN DASH’ (U+2013) which is incompatible with most console programs, especially the ESXi ones (as they are Busybox based to minimise footprint).
Note you can use this small site (which runs in-browser, so does not phone home) to get the unicode code points for any string: [Wayback] What Unicode character is this ?.
Links like below (most on the vmware.com domain) have this EN DASH
and make me document things on my blog instead of trying code directly from blogs or forum posts:
- [Wayback] About vCenter 6.7 command operations – VMware Technology Network VMTN
- [Wayback] vSphere 7 with Multi-Instance GPUs (MIG) on the NVIDIA A100 for Machine Learning Applications – Part 2 : Profiles and Setup – Virtualize Applications
- [Wayback] Using GPUs with Virtual Machines on vSphere – Part 3: Installing the NVIDIA Virtual GPU Technology – Virtualize Applications
- [Wayback] ESXi Maintenance Mode Via CLI How-to And Some More Commands | ESX Virtualization
So below are three commands I use that have to do with the maintenance mode (the mode that for instance you can use to update an ESXi host to the latest patch level).
-
- Check the maintenance mode (which returns
Enabled
orDisabled
):
esxcli system maintenanceMode get
- Enable maintenance mode (which returns nothing when succeeded, and
Maintenance mode is already enabled.
when failed):
esxcli system maintenanceMode set --enable true
- Disable maintenance mode (which returns nothing when succeeded, and
Maintenance mode is already disabled.
when failed):
esxcli system maintenanceMode get
- Check the maintenance mode (which returns
Some examples, especially an the various output possibilities (commands in bold
, output in italic
):
# esxcli system maintenanceMode get Disabled # esxcli system maintenanceMode set --enable false Maintenance mode is already disabled. # esxcli system maintenanceMode set --enable true # esxcli system maintenanceMode get Enabled # esxcli system maintenanceMode set --enable true Maintenance mode is already enabled. # esxcli system maintenanceMode set --enable false # esxcli system maintenanceMode get Disabled
I made these scripts for this:
esxcli-maintenanceMode-show.sh
:
#!/bin/sh esxcli system maintenanceMode get
esxcli-maintenanceMode-enter.sh
:
#!/bin/sh esxcli system maintenanceMode set --enable true
esxcli-maintenanceMode-exit.sh
:
#!/bin/sh esxcli system maintenanceMode set --enable false
Note I have not checked the exit codes for these esxcli
commands yet, but did blog about how to do that: Busybox sh (actually ash derivative dash): checking exit codes.
–jeroen
Leave a Reply