Today I had an issue with a VM not wanting to power off. I found an excellent article from http://markvansintfiet.wordpress.com/2010/07/28/forcefully-kill-a-virtual-machine-in-esxi/ that I am reposting in case the website ever goes down.
One day you’ll run into a not responding virtual machine that won’t power off in the vSphere client. If you don’t want to reboot your ESXi host, here is how to forcefully kill the bastard leaving all other virtual machines peacefully running.
Method 1: Use the vmware-cmd command in the vSphere command-line interface (CLI)
- Download and install vSphere command-line interface(http://www.vmware.com/download/download.do?downloadGroup=VCLI40)
- CD to C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>
- List Virtual Machines
vmware-cmd.pl -H <ESXi host name> -l - Get state:
vmware-cmd.pl -H <ESXi hostname> “<vmx file path>” getstate - Kill Virtual Machine:
- vmware-cmd.pl -H <ESXi hostname> ”<vmx file path>” stop hard
When method 1 fails move to method 2.
Method 2: Find the VM’s process identifier and forcibly terminate it (or use SSH if you are lazy and don't mind opening security holes)
- List active virtual machines: vm-support -x
- On the ESXi console, press Alt-F1.
- Type the word unsupported and press ENTER
- Type root password and press ENTER
- Look up the VM process pgid: ps –g | grep
(The number you are looking for is the one that is right before and after mks: and vcpu) - Kill the process: kill -9 <pgid, the number you just found>
- Wait a minute and check if the machine is not running anymore: vm-support -x