I was recently doing some maintenance and upgrades on some of the hosts in my lab environment when I had the need to enter maintenance mode and reboot my hosts from the command line. I have used esxcli a bit, which is handy if you’re going for your VCAP-DCA exam, but I’d not rebooted a host from command line. Fortunately it was easy to find out how to do it, and it’s well documented. I thought I’d let you know where to find it, and what the commands are, just in case you ever need to know.
Firstly, to put a host into maintenance mode there are two options. ESXCLI, which I was familiar with, or vicfg-hostops, which I’ve only just discovered.
To enter and exit maintenance mode:
esxcli <conn_options> system maintenancemode set –enable true, where <conn_options> are the connection options such as –server=<servername>
To exit maintenance mode
esxcli <conn_options> system maintenancemode set –enable false
In addition to the above using vicfg-hostops you can issue the following
vicfg-hostops <conn_options> –operation enter or –operation exit to enter or exit maintenance mode.
All of the above is documented in the official VMware vSphere CLI Documentation – Entering and Exiting Maintenance Mode.
To reboot a host:
To reboot a host from the command line we would use the vicfg-hostops –operation reboot command, to force a reboot you could add the –force option, similarly to shutdown a host you use –operation shutdown, which can also be used with the –force option.
This is also nicely documented in the official VMware vSphere CLI Documentation – Stopping, Rebooting, and Examining Hosts.
The VMware CLI options have come a long way over the years and you can really quickly and easily automate a lot of tasks using esxcli, PowerCLI and the other command line tools. I would encourage all of you to check them out. They are covered in the blueprint for the VCAP-DCA exam, so if you wanted to achieve the advanced level administration certification from VMware you should learn how to use these tools, and how much easier they could make your job if you’re a vSphere Admin.
This post appeared on the Long White Virtual Clouds blog at longwhiteclouds.com, by Michael Webster +. Copyright © 2013 – IT Solutions 2000 Ltd and Michael Webster +. All rights reserved. Not to be reproduced for commercial purposes without written permission.