Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • 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 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

September 15, 2022 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 connection 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
Active Directory Dynamic User Groups with PowerShell

Related Reading

Reset Root Password in VMware ESXi

October 12, 2023

How to Fix ‘An Operating System Wasn’t Found’...

July 14, 2023

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Increase Virtual Machine Disk Size in...

April 6, 2023

How to Install Free VMware Hypervisor (ESXi)

January 24, 2023

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 Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • 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
  • How to Enable and Configure SNMP on VMWare ESXi Host?
Footer Logo

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


Back To Top