Power off an unresponsive VM using ESXTOP

Just recently we have some hardware issues in our primary datacenter and during that time had a few VM’s that became unresponsive and needed to get them back online. The VM’s had stopped responding to the normal vSphere commands to reboot, shutdown or even restart. I didn’t want to power cycle the entire ESXi host and instead just power off an unresponsive VM.

Here is a quick and easy way to do just that using ESXTOP.

How to kill an unresponsive VM using ESXTOP

  1. SSH into the host that the virtual machine is currently running on using PuTTy or your choice of client.
  2. Type: esxtop to start ESXTOP.
  3. Press c to enter the CPU view of ESXTOP.
    Note: It may be helpful to press shift and V so that only VM’s are shown.
  4. Press f to change what display fields are shown and press c to show the LWID field, then press ENTER to go back to the CPU view.
    SSH add LWID field
  5. Finally, press k to open the “kill” prompt and enter the LWID of the VM you would like to power off and press ENTER.
    Using ESXTOP to kill VM using LWID

At this point the VM should be powered off. Keep in mind this will perform a hard power off, similar to yanking the power from a physical box so you really only want to do this if the VM is not responding to any other commands in order to gracefully power it off.

How to kill a VM using vSphere CLI

You can get the same result as above, powering off a VM, and not needing to use ESXTOP at all.

  1. SSH into the host where the unresponsive VM is located and type the following:
    vim-cmd vmsvc/getallvms
  2. Take note of world ID of the VM and then use the following command to issue a shutdown by typing, making sure to replace (vmid) with the world ID:
    vim-cmd vmsvc/power.off (vmid)
  3. If you find the VM still won’t power off you can kill the PID for the VM. Use lsof to find the pid that has the vmx (config file) open and then use kill to terminate it.
    lsof /vmfs/volumes/datastore/vmname/vmname.vmx
    kill -9 (pid)

Thanks goes to /u/Acaila on Reddit for pointing out this other method!

Similar Posts