What to do when a VM hangs in a task or stops responding with an ESX host
We’ve all run into issues before where a VM is hanging or taking a long time with an operation and eventually fails and goes in a funky state. You can’t turn it off, you can’t turn it on, you can’t edit it, etc.
Here are some tips to try out if you run into these circumstances to cancel operations and get control back on your VM:
RESTART ESX MANAGMENT SERVICES
Try restarting the management services on the ESX host that the VM is running on.
NOTE: This operation should not have any effect on running VMs on the host. I have never seen it affect running VMs, but if you are doing something like a disk consolidation, be wary that this can abruptly stop it and leave it in an inconsistent state.
- Turn on SSH services on your ESX host if you dont already have this running
- Login to the ESX host via SSH
- Run the following commands
/etc/init.d/hostd restart
/etc/init.d/vpxa restart
This should kick it out of that funky state restart and re-initialize the VM from the host perspective. To give you a hold on things again.
Fore more information you can check this out –
https://kb.vmware.com/s/article/1003490
REFRESHING YOUR VM
Another thing I have seen help in the past is where there are bad files or issues with a VM from operating correctly from either old snapshots or failed disk consolidations. One way to help give you a clean start is
A. Kill your VM process if necessary
If your VM is stuck in a funky state, it may be necessary to kill it.
1. List all the VMs on the currently logged on host and note down the vmid (1st column) of the unresponsive VM.
vim-cmd vmsvc/getallvms
2. Try to shutdown gracefully if possible
vim-cmd vmsvc/power.shutdown <your_vm_number>
3. If all else fails force a power off
vim-cmd vmsvc/power.off <your_vm_number>
For more on this – I found this blog article helpful for really stubborn VMs that don’t want to die.
https://www.altaro.com/vmware/how-to-terminate-unresponsive-virtual-machines-in-vsphere/
B. Vmotioning to another datastore
If your VM has issues starting or has a problem with disk consolidation. It might help to recopy the VM leaving all the garbage behind to give it a clean start.
C. Take it out of inventory and re-add the VM
Sometimes taking it out of inventory can also help reset any bad juju that may have been left behind in the previous state. I would recommend putting it on a different host than where it was before.
D. A new VM from old disks.
If you are really having issues with your VM, you can try to create a new VM with no disks and then attach the old disks, or maybe even copy the content manually to new disks.
Note: This would be a method of last resort. I’ve only seen this help if there is a weird VM hardware issue.
Ben Tuma
Over 20 years of experience in the Information Technology field. I love technology and seeing how it changes and impacts peoples lives for the better. I have healthy appetite for innovation and problem solving.
I am sharing my knowledge and challenges in hopes to help others as we constantly face ever changes problems in IT and technology.