Terminate unresponsive virtual machines by ESXi Methods

I’ve written this post after coming across an issue I had not seen in a while, an unresponsive VM in vSphere client to any orders issued to it such as restart, shutdown, or power off.

It happens from time to time by unresponsive; I meant a guest OS that will categorically ignore any remote orders made to a VM that is utterly oblivious to anything triggered by a vSphere client.

Thankfully, there are some methods used to kill the offending VM. The first port of call is PowerCLI. If this fails, we still have some options left at our disposal, and they all involve running commands directly off an ESXi host.

The alternative to this, of course, is to reboot the ESXi host assuming we can migrate VMs elsewhere. Hopefully, we will never have to resort to this act of reckless.

ESXi Methods

There are three command line methods we can use on ESXi to terminate unresponsive VMs.

These methods are vim-cmd, esxcli, and esxtop tool presents itself as a third option, we need to enable SSH and/or Shell on ESXi after which we could use them directly from the console.


Method 1 (vim-cmd)

Vim-cmd is another command line utility, very similar to esxcli, but bearing a somewhat different syntax. Similarly, it can be used to manage VMs as well as other resources. Keeping in line with the subject matter, here’s how vim-cmd is used to terminate a VM.

To power on/off a virtual machine from the command line:
  • List the inventory ID of the virtual machine which has the problem with the command:
    # vim-cmd vmsvc/getallvms |grep ESXi1

  • Check the power state of the virtual machine with the command, put vmid as below:
    # vim-cmd vmsvc/power.getstate 37

To Power-off the unresponsive virtual machine with the command, you have to determine how you want to do this with the hard or soft way due to may be using the hard way caused VM corruption.
This command allows the VMX process to shutdown the VM normally.
# vim-cmd vmsvc/power.shutdown 37


This command kills the VMX process looks like force shutdown.

# vim-cmd vmsvc/power.off 37

Power-on the VM with the command:

# vim-cmd vmsvc/power.on 37


Thanks for Reading!
To be Continued >>>>

Leave a Reply

Your email address will not be published. Required fields are marked *