Power off a VM when it is stuck
by alefesta
Got a mail from a customer who just started to “play” with vmware and asked me the following question:
How I may force a VM to powering off when is stuck at 95%?
So my first consideration was: on VMware Esx or Esxi? So again since in the future everyone will have to use esxi I would explain how to do.
First of all it depends on what you know of esxi so let’s say you have three choices:
- From the VI client
- From the Remote command-line tool
- From the Tech Support mode (aka directly from the console of esxi)
From the VI Client:
- Connect VMware Infrastructure (VI) Client to VMware VirtualCenter Server.
- Right-click on the virtual machine and click Power off.
- Connect VI Client directly to the ESXi host.
- Right-click on the virtual machine and click Power off.
I know it sounds a bit odd since you just did the same and the VM is stucked at 95% but sometimes it’s useful give a second try don’t you think?
Now let say that the VM is still there so you’ll have to do one of the following:
Install the remote command-line tool (or better install the vMA) or use directly the esxi console (aka Local Tech support).
From the Remote command-line tool:
(http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_rcli.pdf) for those who want to know more about the command-line vm management.
First of all get the real state of the VM with the command: vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate
-
- If the status is still on or stuck thant go for a second attempt with a “soft” shutdown: vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
- If it doesn’t work thant “use the force Luke” :vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
Now let say that you do not have the vMA installed or you simply wont to use it so let’s go for the local Tech Support.
From the Tech Support mode:
1.On the ESXi console, enter Tech Support mode and log in as root
2.Get the World_ID with the command:
# vm-support -x
3.Kill the virtual machine by using the following command in the home directory of the virtual machine.
# vm-support -X <World_ID> –w <dir>
If everything is done in the right way the VM finally will be shutdown. Last but not least could happen that the VM remain locked in this case you may:
- Reboot the HOST
- Follow the Vmware KB “Virtual Machine does not power on because of locked files” (http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=10051)