Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / VMware ESXi: How to Kill an Unresponsive (Stuck) Virtual Machine

October 9, 2019 VMWare

VMware ESXi: How to Kill an Unresponsive (Stuck) Virtual Machine

Sometimes I see that a certain virtual machine on the VMWare ESXi host freezes and it’s impossible to turn off or restart it from vSphere console by any means. Rebooting the entire ESXi host due to a single virtual machine is not entirely advisable (especially if you have only one ESXi host, or the remaining servers in the DRS cluster are not able to cope with the extra load of virtual machines from the server to be restarted). Consider the main ways to force kill an unresponsive (hung) virtual machine on VMWare ESXi host.

If the virtual machine process on the ESXi server freezes, it stops responding on vCenter Reset/Power Off commands, and returns one of the following errors to any action:

  • Another task is already in progress;
  • The virtual machine might be performing concurrent operations. Actions: Complete the concurrent operation and retry the power-off operation; The virtual machine is in an invalid state;
  • The attempted operation cannot be performed in the current state.

In such cases, you can manually kill the virtual machine process on the ESXi host from the ESXi Shell or PowerCLI command prompt.

First you need to determine on which ESXi host the hung virtual machine is running. To do this, find the VM in the vSphere Client interface. The ESXi host name on which VM is running is specified on the Summary tab in the Related Object -> Host section.

vmware vsphere client get vm host

Next, SSH access protocol must be enabled on your ESXi host. You can do it from the vSphere interface. Click on the ESXi host name, go to Configure -> Services -> SSH -> Start.

vmware esxi - run ssh

Now you can connect to this host via SSH using the putty client. List the VMs running on the ESXi host:

esxcli vm process list

esxcli vm process list

Copy the “World ID” of the problem virtual machine.

To terminate the process of a hung virtual machine on an ESXi host, use the following command:

esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

There are three kill types of the VM process:

  • Soft – the safest way to kill the VMX process (similar to kill -SIGTERM);
  • Hard – immediate termination of the VM process (kill -9);
  • Force – the hardest VM process stop mode. Should be used last if nothing else helps.
Make sure that there are no active snapshots, backups, and similar tasks for VM, and VM not in the “Virtual Machine disks consolidation is needed” state. Otherwise, you can break your VM and you will have to restore it from backup.

Let’s try to softly stop the VM with the specified ID:

esxcli vm process kill --type=soft -w=20598249

esxcli vm process kill

The VM should be powered off.

You can stop the frozen virtual machine using the PowerCLI (this is convenient, because when connecting to vCenter you don’t need to find the hostname on which the VM is running and enable SSH shell on it). Check that the VM is running:

get-vm “web1" | select name,PowerStates

Force stop the VM process with the command:

stop-vm -kill "web1" -confirm:$false

PowerCLI stop-vm -kill

Also, you can stop an unresponsive VMWare virtual machine using the ESXTOP utility.

Open the SSH session, enter the esxtop, press “c” to display CPU resources and then SHIFT+V to display only virtual machine processes.

esxtop

Then press “f” (to select fields to be displayed), “c” (to display the LWID- Leader World Id) and then press ENTER.

esxtop get vm lwid

In the Name column, find the virtual machine to be stopped and note its LWID number in the corresponding column.

Now you have to press “k” (kill) and enter the LWID number of the virtual machine that you want to force shut down.

And the last way of VM “hard“ power off is to use the kill tool. This method will stop not only the VM, but also all child processes.

Get the parent process ID of the VM:

ps | grep "web2"

Kill the VM process:

kill -9 24288474

esxi kill vm process with ps

After such a “hard reset”, the installed OS will boot in the Recovery mode. In the case of guest Windows, the screen will look like this.
Windows Error Recovery

1 comment
2
Facebook Twitter Google + Pinterest
previous post
PowerShell: Generating QR Code for Wi-Fi Network in Windows 10
next post
Fix: Saved RDP Credentials Didn’t Work in Windows

Related Reading

How to Access VMFS Datastore from Linux, Windows,...

July 1, 2022

Updating VMware ESXi Host from the Command Line

May 11, 2022

How to Change or Disable Session Timeout in...

April 13, 2022

How to Upgrade VM Hardware Version in VMware...

March 4, 2022

VMware PowerCLI: How to Install and Manage vSphere...

February 28, 2022

1 comment

Marsellus Maynard November 26, 2016 - 7:25 pm

Great post! esxtop rocks!!

You can also use: esxcli or PowerCLI.

– esxcli:

esxcli vm process kill

– PowerCLI cmd-let:

Stop-VM with -Confirm:$false

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows 7
  • Windows Server 2019
  • Windows Server 2016
  • Windows Server 2012 R2
  • PowerShell
  • VMWare
  • Hyper-V
  • MS Office

Recent Posts

  • Using PowerShell Behind a Proxy Server

    July 1, 2022
  • How to Access VMFS Datastore from Linux, Windows, or ESXi?

    July 1, 2022
  • How to Deploy Windows 10 (11) with PXE Network Boot?

    June 27, 2022
  • Checking Windows Activation Status on Active Directory Computers

    June 27, 2022
  • Configuring Multiple VLAN Interfaces on Windows

    June 24, 2022
  • How to Disable or Enable USB Drives in Windows using Group Policy?

    June 24, 2022
  • Adding Domain Users to the Local Administrators Group in Windows

    June 23, 2022
  • Viewing a Remote User’s Desktop Session with Shadow Mode in Windows

    June 23, 2022
  • How to Create a Wi-Fi Hotspot on your Windows PC?

    June 23, 2022
  • Configuring SSH Public Key Authentication on Windows

    June 15, 2022

Follow us

woshub.com

ad

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Adding Third-Party Drivers into VMWare ESXi 6.7 ISO Image
  • Windows Server Licensing for Virtual Environments
  • Invalid State of a Virtual Machine on VMWare ESXi
  • ESXi: Slow Disk Performance on HPE Gen8
  • Match Windows Disks to VMWare VMDK Files
  • System Logs on ESXi Host are Stored On Non-Persistent Storage
  • Configuring USB Devices Passthrough from VMWare ESXi to a Virtual Machine
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top