Day: July 3, 2015
Nuclear Option: How to Force Power Off a Hung VM via SSH | Lazy Admin Blog

We’ve all been there: a Windows Update goes sideways or a database lock freezes a guest OS, and suddenly the “Shut Down Guest” command is greyed out or simply times out. When the GUI fails you, the ESXi Command Line (esxcli) is your best friend.
Step 1: Identify the “World ID”
In ESXi terminology, every running process is assigned a World ID. To kill a VM, you first need to find this unique identifier.
- SSH into your ESXi host using Putty.
- Run the following command to see all active VM processes:Bash
esxcli vm process list - Locate your hung VM in the list. Look for the World ID (a long string of numbers). You will also see the Display Name and the path to the
.vmxfile to confirm you have the right one.
Step 2: Execute the Kill Command
ESXi offers three levels of “force” to stop a process. It is best practice to try them in order:
- Soft: The most graceful. It attempts to give the guest OS a chance to shut down cleanly.
- Hard: Equivalent to pulling the power cable. Immediate cessation of the VMX process.
- Force: The “last resort.” Use this only if ‘Hard’ fails to clear the process from the kernel.
The Syntax:
Bash
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
Example (Hard Kill): esxcli vm process kill -t hard -w 5241852
Step 3: Verify the Result
After running the kill command, it may take a few seconds for the host to clean up the memory registration. Run the list command again to ensure it’s gone:
Bash
esxcli vm process list | grep "Your_VM_Name"
If the command returns nothing, the VM is officially offline, and you can attempt to power it back on via the vSphere Client.
Lazy Admin Tip 💡
If esxcli still won’t kill the VM, the process might be stuck in an “I/O Wait” state (usually due to a failed storage path). In that rare case, you might actually need to restart the Management Agents (services.sh restart) or, in extreme cases, reboot the entire host.
#VMware #vSphere #ESXi #SysAdmin #Troubleshooting #Virtualization #ITOps #LazyAdmin #ServerManagement #DataCenter