How to enable Maintenance mode on ESX host from command line

Posted by on May 11, 2010 in VMware, vSphere | 2 comments

This is something that I’ve been meaning to post for a while now. It’s a simple thing but can save you from having to open up the vSphere client or allow you to use this in a script. The commands listed below will allow you to place a ESX host in and out of Maintenance mode from the command line or Service Console (what ever you like to call it).

To enter maintenance mode run the following command

vimsh -n -e /hostsvc/maintenance_mode_enter

To exit maintenance mode run the following command

vimsh -n -e /hostsvc/maintenance_mode_exit

So your probably wondering how do I know if the host is in Maintenance Mode, here you go:

vimsh -n -e /hostsvc/runtimeinfo | grep inMaintenanceMode | awk ‘{print $3}’

Update: March 1st 2011

I thought an update to cover the commands you can run from vMA to enter maintenance mode from vCLI. From the vMA command prompt you can enter the following command to enter maintenance mode.

vicfg-hostops -o enter –server 192.168.1.114

To exit maintenance mode from vMA enter the following.

vicfg-hostops -o exit –server 192.168.1.114

You can also issue shutdown or reboot commands from vMA.

vicfg-hostops -o shutdown –server 192.168.1.114
vicfg-hostops -o reboot –server 192.168.1.114

Also note that after entering any of the above commands from the vMA it will make you provide Username and Password for the Host that you are working on. Unless you choose to use Fast Pass or Passthrough authentication.

About Brian Suhr

Brian is a VCDX5-DCV and a Sr. Tech Marketing Engineer at Nutanix and owner of this website. He is active in the VMware community and helps lead the Chicago VMUG group. Specializing in VDI and Cloud project designs. Awarded VMware vExpert status 6 years for 2016 - 2011. VCP3, VCP5, VCP5-Iaas, VCP-Cloud, VCAP-DTD, VCAP5-DCD, VCAP5-DCA, VCA-DT, VCP5-DT, Cisco UCS Design

2 Comments

  1. Without grep:
    vimsh -n -e /hostsvc/runtimeinfo 2>/dev/null | awk '/inMaintenanceMode/ { print $NF } '

  2. Without grep:
    vimsh -n -e /hostsvc/runtimeinfo 2>/dev/null | awk '/inMaintenanceMode/ { print $NF } '

Trackbacks/Pingbacks

  1. Some ESXi CLI Commands - [...] shutdown -r now… it was not so much.Resources:I adapted the maintenance mode commands from here: http://www.virtualizetips.com/2010/05/how-to-enable-maintenance-mode-on-esx-host-from-command-line/Tagged as: esxi, VCAP, …

Leave a Reply

%d bloggers like this: