A short post to bookmark some CLI commands for putting a VMware ESXi host into a maintenance mode. In my lab, I'm running vCenter in a VM, and this VM runs out of a small local datastore. So I can't simply vMotion this VM elsewhere to do a maintenance and patch using VMware Update Manager (VUM).
When the host where that VM runs, needs to be put into maintenance mode, one needs the CLI. That's why this post. But while here I'll add some more commands which are useful for rebooting, or checking up the VMs that runs on the host etc… which might be useful too.
ESXi maintenance mode is mode when it's possible to install patches and updates or plan for a hardware upgrade such as adding more RAM or more internal hard drives. You might also need to service your host to install new firmware to your storage controller, to your motherboard etc. So the use cases for using a maintenance mode are numerous.
The host is in a state of Entering Maintenance Mode until all running virtual machines are suspended or migrated. When a host is entering maintenance mode, you cannot power on virtual machines on it or migrate virtual machines to it.
Whether you patching standalone ESXi host or if you're using VMware Update manager for patching, in both cases you must put a host into maintenance mode. In case you're using VUM the host is placed into maintenance mode automatically.
If you have VMs running on the host, you must migrate them or shut them down. You cannot leave VM running and put a host into a maintenance mode as the system will wait until all running VMs are shut down or are migrated elsewhere.
How to put a host into maintenance mode?
To enter maintenance mode using the command line interface, use this command:
esxcli system maintenanceMode set –enable true
To exit maintenance mode use this command:
esxcli system maintenanceMode set –enable false
Alternatively, there is another command to enter and to exit maintenance mode:
To enter maintenance mode:
To exit maintenance mode:
vimsh -n -e /hostsvc/maintenance_mode_exit
To check if the host is in maintenance mode:
Use one of these commands:
vim-cmd /hostsvc/hostsummary | grep inMaintenanceMode
vimsh -n -e /hostsvc/hostsummary | grep inMaintenanceMode
While here, some quick commands how to reboot, halt or shutdown:
Through the vMA (vSphere Management Appliance):
From the vMA command prompt, you can also enter maintenance mode.
vicfg-hostops -o enter –server 10.10.5.10
To exit maintenance mode from vMA enter the following.
vicfg-hostops -o exit –server 10.10.5.10
You can also shutdown or reboot ESXi hosts command from vMA.
vicfg-hostops -o shutdown –server 10.10.5.10
vicfg-hostops -o reboot –server 10.10.5.10
Find out which VMs are running on ESXi host:
esxcli vm process list
Check out also my post on How-to power off unresponsive VM through the CLI.
Maintenance mode is a special state where the system assures that no VMs are running so the patching/upgrade of the host is possible. After the host has entered the Maintenance mode, no VMs can be deployed or powered-on on the host.
When no more running virtual machines are on the host, the host’s icon changes to include under maintenance and the host’s Summary panel indicates the new state. Host can exit the maintenance mode automatically after the patching process has finished and rebooted the host only if managed via vSphere Update Manager (VUM). If it is an individual host, no automatic maintenance mode exists.
VMware Update Manager is now part of VMware vCenter Server Appliance (VCSA). Windows-based vCenter needs a separate DB and separate software component. VMware is phasing out the Windows vCenter. The latest news was that the next release of VMware vSphere will be the last release where the Windows vCenter server will be part of the vSphere suite.
More from ESX Virtualization:
- What is VMware Orchestrated Restart?
- How To Reset ESXi Root Password via Microsoft AD
- How to Install latest ESXi VMware Patch – [Guide]
- How to reset ESXi 6.x root password and under which conditions
- What is VMware Instant Clone Technology?