From KB 1014165
Symptoms
- You cannot power off an ESXi hosted virtual machine
- A virtual machine is not responsive and cannot be stopped or killed
Resolution
Powering off the virtual machine using the vSphere Client
Attempt to power off the virtual machine gracefully using the client:
- Connect the vSphere Client or VI Client to VMware vCenter Server or VirtualCenter Server.
- Right-click the virtual machine and click Power off. If the power operation fails with Another task is already in progress, wait for the task to complete.
- If the virtual machine remains running, attempt the same operation from the host directly.
- Connect the vSphere Client or VI Client directly to the ESXi host running the virtual machine.
- Right-click on the virtual machine and select Power off.
If the virtual machine cannot be powered off gracefully using the client, use one of the command-line options.
Installing the vSphere Command-Line Interface tool
The vSphere Command-Line Interface (vCLI) is used for some of the procedures in this article. Ensure that it is installed before you proceed.
- For ESXi 3.5 hosts, see Remote CLI Installation and Execution in the Remote Command-Line Interface Installation and Reference Guide.
- For ESXi 4.0 hosts, see vSphere CLI Installation, Execution, and Command Overviews in the vSphere Command-Line Interface Installation and Reference Guide.
- For ESXi 4.1 hosts, see the vSphere Command-Line Interface Installation and Scripting Guide.
- For ESXi 5.0 hosts, see the vSphere Command-Line Interface Documentation.
- For ESXi 5.1 hosts, see the vSphere Command-Line Interface 5.1 Release Notes
- For ESXi 5.5 hosts, see the vSphere Command-Line Interface Documentation.
- For ESXi 6.0 hosts, see the vSphere Command-Line Interface Documentation.
Note: The Remote Command-Line Interface can be accessed from the vSphere Management Assistant (vMA) for ESXi 4.x, ESXi 5.x and ESXi 6.0. If it is your preference to use this tool, see Installing vMA and Running Commands from vMA in the vSphere Command-Line Interface Installation and Reference Guide.
Determining the virtual machine’s location
Determine the host on which the virtual machine is running. This information is available in the virtual machine’s Summary tab in VI Client. Subsequent commands will be performed on, or remotely reference, the ESXi host where the virtual machine is running.
Using the ESXi esxcli command to power off a virtual machine
The esxcli
command can be used locally or remotely to power off a virtual machine running on ESXi 5.x or later. For more information, see the esxcli vm Commands section in the vSphere Command-Line Interface Reference.
- Open a console session where the
esxcli
tool is available, either in the ESXi Shell, the vSphere Management Assistant (vMA), or the location where the vSphere Command-Line Interface (vCLI) is installed. - Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the
.vmx
configuration file by running this command:esxcli vm process list
- Power off one of the virtual machines from the list by running this command:
esxcli vm process kill --type= [soft,hard,force] --world-id= WorldNumber
Notes:
Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.Alternate power off command syntax is: esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
- Repeat Step 2 and validate that the virtual machine is no longer running.
For ESXi 4.1:
- Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file by running this command:
esxcli vms vm list
- Power off one of the virtual machines from the list by running this command:
esxcli vms vm kill --type= [soft,hard,force] --world-id= WorldNumber
Using the ESXi command-line utility vim-cmd to power off the virtual machine
- On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
- Get a list of all registered virtual machines, identified by their VMID, Display Name, and path to the
.vmx
configuration file by running this command:vim-cmd vmsvc/getallvms
- Get the current state of a virtual machine by running this command:
vim-cmd vmsvc/power.getstate VMID
- Shutdown the virtual machine using the VMID found in Step 2 and run this command:
vim-cmd vmsvc/power.shutdown VMID
Note: If the virtual machine fails to shut down, run this command:
vim-cmd vmsvc/power.off VMID
Sending signals on ESXi to power off the virtual machine
kill
command to send a signal to, and terminate, a running virtual machine process.- On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
- Determine if the virtual machine process is running on the ESXi host by running this command:
ps | grep vmx
The output appears similar to:
7662 7662 vmx /bin/vmx 7667 7662 vmx /bin/vmx 7668 7662 mks:VirtualMachineName /bin/vmx 7669 7662 vcpu-0:VirtualMachineName /bin/vmx
Several rows are returned, one for each
vmx
process. Identify the parentvmx
process for the target virtual machine. The first column contains the PID, and the second contains the parent’s PID. Ensure you terminate only the parent process. The parent Process ID (PID) for each process is listed in the second column, identified in this example in bold. Take note of this number for use in the following steps.Caution: Ensure that you identify the line specific only to the virtual machine you are attempting to repair. If you continue this process for a virtual machine other than the one in question, you can cause downtime for the other virtual machine.
- If the
vmx
process is listed, terminate the process by running this command:kill ProcessID
- Wait 30 seconds and repeat step 2 to check for the process again.
- If it is not terminated, run this command:
kill -9 ProcessID
- Wait 30 seconds and check for the process again.
In ESXi 4.x and above, you can use the k
command in esxtop
to send a signal to, and kill, a running virtual machine process.
- On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support Mode for Emergency Support (1003677).
- Run the
esxtop
utility by running this command:esxtop
- Press c to switch to the CPU resource utilization screen.
- Press Shift+v to limit the view to virtual machines. This may make it easier to find the Leader World ID in step 7.
- Press f to display the list of fields.
- Press c to add the column for the Leader World ID.
- Identify the target virtual machine by its Name and Leader World ID (
LWID
). - Press k.
- At the
World to kill
prompt, type in the Leader World ID from step 6 and press Enter. - Wait 30 seconds and validate that the process is not longer listed.