Today another post of the series ESXi Command List. The title says it all. We’ll have a look at different options to reboot ESXi from a command line and we’ll talk a bit about maintenance mode. You should always put hosts into maintenance mode when you do reboots, firmware updates, apply ESXi updates (most patches require the host to be in maintenance mode) or anything like that.
This will make sure all processes on the host are properly prepared, no VM will be (accidentally/DRS) migrated onto the host again. During maintenance state the HA agent is disabled as well. This command is to know for sure.
After invoking the command, the host will start to enter maintenance mode, but waits until all VMs are suspended or migrated. Always put the host into maintenance mode.
When a host is in maintenance mode, no VMs can be powered On, and also you cannot put this host as a destination host if doing some vMotions, so the host cannot “receive” the VM in case of vMotion. Always put the host into maintenance mode.
To enter and exit maintenance mode:
connect via Putty and enter this: (case sensitive)
esxcli system maintenanceMode set –enable true
You can easily explore a bit further…
So the get command returns the actual state when checking if the host is in maintenance mode or not.
And also you can show the whole esxcli system tree vie esxcli system …
Now, as you can see in the image above, I underlined another command – shutdown. This is obviously for shutting down the host completely. So once your host is in maintenance mode, it’s safe to shut down.
We can shut down an ESXi host with this command, which however needs another two parameters:
- Time –delay=<long> (minimum 10 sec) (note it is double dash – – )
- Reason –reason=<long>
short would be:
- Time -d
- Reason -r
So to show direct example:
esxcli system shutdown powerof -d 10 -r maintenance
Done. Today you have learned another two commands.
As you can see, with just a few commands you can safely put a host into maintenance mode and shut down. Then you can do hardware upgrade or whatever you need to do. You learned another two commands to became a master of ESXi -:).
Few other posts:
- ESXi CLI Networking commands
- ESXi Commands List – Getting Started
- ESXi Commands List – Snapshot Deletion Monitoring
- ESXi Commands List – Storage
- ESXi Command List – Maintenance – (This post)
Hard Reboot option!
You have a host that has hung iSCSI storage device and
You can “hard reboot the host” – with some extra parameters from an SSH command-line.
reboot -n -f
The VMware server will immediately reboot. This is equivalent to a “hard reboot”, meaning you could lose data the same as if you had turned the power off on the server.