VMware: ESX Restart A Hung Virtual Machine

This is a last case scenario blog. I recommend always start out using the GUI.  If that does’t work, use vmware-cmd to try and stop the VM.  If all else fails, follow below.  First you need to know what ESX server the VM is running on. The easiest way is to click on the VM you are looking for and go to the summary tab. The ESX server it resides on will be in the “General” section under “Host”. The other method is to connect to each of the ESX hosts and run the following:

You have to su to root for this command to work

[root@esxserverroot]# vmware-cmd -l
/vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/exchangeserv/exchangeserv.vmx
/vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/sql01/sql01.vmx
/vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/domaincontrol01/domaincontrol01.vmx
/vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/tstxp04/tstxp04.vmx
/vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/monitor5/monitor5.vmx

This commands lists all the currently running virtual machines on the individual ESX host. Also displayed is the full path to the vmx file, which is very useful when using vmware-cmd.

Now lets pass -axfww to ps. This will give us the

[root@esxserverroot]# ps -axfww | grep exchangeserv

30008 pts/0    S      0:00                      \_ grep exchangeserv
 2941 ?        S<     0:04 /usr/lib/vmware/bin/vmkload_app /usr/lib/vmware/bin
/vmware-vmx -ssched.group=host/user -# name=VMware ESX Server;version=3.5.0;
licensename=VMware ESX Server;licenseversion=2.0 build-120512; -@
pipe=/tmp/vmhsdaemon-0/vmxce7cca7370d3034d; /vmfs/volumes/
4844ace-b448s7d4-74e-000055858ed/exchangeserv/exchangeserv.vmx

Here is the same example, not using the BSD derivative arguments. Instead we will use -efww

[root@esxserverroot]# ps -efww | grep exchangeserv
root      2941     1  0 Feb02 ?        00:00:04 /usr/lib/vmware/bin/vmkload_app
/usr/lib/vmware/bin/vmware-vmx -ssched.group=host/user -# name=VMware ESX Server;
version=3.5.0;licensename=VMware ESX Server;licenseversion=2.0 build-120512;
-@ pipe=/tmp/vmhsdaemon-0/vmxce7cca7370d3034d; /vmfs/volumes/
4844ace-b448s7d4-74e-000055858ed/exchangeserv/exchangeserv.vmx
root     30029 29692  0 16:08 pts/0    00:00:00 grep exchangeserv

To forcefully stop the hung machine, just kill the process passing -9 to send term signal. This is not recommended unless the machine will NOT resopond to anything else.

[root@esxserver root]# kill -9 2941

Each time I have had to do this, the machine showed powered off in Virtual Center, but the getstate showed on.

[root@esxserverroot]# vmware-cmd /vmfs/volumes/4844ace-b448s7d4-74e-000055858ed/
exchangeserv/exchangeserv.vmx getstate
getstate() = on

Try to force it off before going through the above steps to kill the process.

[root@esxserverroot]# vmware-cmd /vmfs/volumes/
4844ace-b448s7d4-74e-000055858ed/exchangeserv/exchangeserv.vmx stop force

If that errors, you must kill the processes.  Once done, try and restart the virtual machine.

[root@esxserverroot]# vmware-cmd /vmfs/volumes/
4844ace-b448s7d4-74e-000055858ed/exchangeserv/exchangeserv.vmx start

Note: Again, this is a last resort and could possible corrupt the vmdk disk. I have done this successfully about 6 times with no problmes.

~ by Kevin Goodman on February 9, 2009.

6 Responses to “VMware: ESX Restart A Hung Virtual Machine”

  1. [...] VMware: ESX Restart A Hung Virtual Machine « Colocation to Virtualization (tags: vmware esx) Share and Enjoy: [...]

  2. You are the man! It works!!!

  3. Glad it worked for you! It has saved me a few times now.

  4. Thanks it works for me too!!!

  5. Great! Thanks for your help!

  6. For ESXi 4 it seems you need to do ‘ps | grep -i “Database” | grep -i “Worker”‘ instead where ‘Database’ is the server name.

Leave a Reply