Wondering how to kill an unresponsive virtual machine? We can help you with it.
Here at Bobcares, we have seen several such VMWare related errors as part of our Server Management Services for web hosts and online service providers.
Today we will take a look at how to kill the unresponsive Virtual machine.
Why does a Virtual machine become unresponsive
Sometimes we see that a certain virtual machine on the VMWare ESXi host freezes and it is impossible to turn off or restart it from the vSphere console by any means.
Moreover, it is not advisable to reboot the entire ESXi host due to a single virtual machine.
If the virtual machine process on the ESXi server freezes, it stops responding to vCenter Reset/Power Off commands. As a result, it returns one of the following errors to any action:
- Another task is already in progress;
- The virtual machine might be performing concurrent operations. Actions: Complete the concurrent operation and retry the power-off operation; The virtual machine is in an invalid state;
- The attempted operation cannot be performed in the current state.
How to kill an unresponsive virtual machine
Our Support Engineers manually kill the virtual machine process on the ESXi host from the ESXi Shell or PowerCLI command prompt.
1. First, we determine the hung virtual machine is running on which ESXi host. For that, we find the VM in the vSphere Client interface. The ESXi hostname on which VM is running is specified under the Summary tab in the Related Object >> Host section.
2. Next, we enable the SSH access protocol on the ESXi host. We do it from the vSphere interface. by clicking on the ESXi hostname and go to Configure >> Services >> SSH >> Start.
3. Now we connect to this host via SSH. After that, we run the below command to list the VMs running on the ESXi host.
esxcli vm process list
From the above command’s result, we copy the “World ID” of the problem virtual machine.
4. Next, we execute the below command to terminate the process of a hung virtual machine.
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
5. In our example, we are trying to softly stop the VM with the specified ID:
esxcli vm process kill --type=soft -w=20598247
The VM powers off.
6. Now we stop the frozen virtual machine using the PowerCLI. We also check that the VM is running.
get-vm “web1" | select name,PowerStates
7. Then we force to stop the VM process.
stop-vm -kill "web1" -confirm:$false
8. Also, we can stop an unresponsive VMWare virtual machine using the ESXTOP utility.
For that, we open the SSH session, enter the esxtop, press “c” to display CPU resources and then we press SHIFT+V to display only virtual machine processes.
9. Then we press “f” (to select fields to be displayed), “c” (to display the LWID), and then press ENTER.
10. After that, in the Name column, we find the virtual machine to be stopped and note its LWID number.
11. Now, we press the “k” (kill) and enter the LWID number of the virtual machine that we want to force shut down.
12. The last way of VM “hard“ power off is to use the kill tool. This method will stop the VM along with all child processes.
For that, we get the parent process ID of the VM:
ps | grep "web2"
Finally, we kill the VM process.
kill -9 24288473
[Need any further assistance in fixing VMWare errors? – We are here to help you]
Today, we saw the solution provided by our Support Engineers to this error.