Quite often, VMWare administrators are faced with the fact that the list of virtual machines contains VMs with the Invalid (Unknown) status. As a rule, the issue occurs after deleting a virtual machine, which data remained in the VMWare vSphere/ESXi configuration on some reason. This can also happen after you manually remove VM files from the VMFS storage after running vMotion and in some other cases. You won’t be able to delete such a VM from vSphere Web Client using the built-in tools (the Unregister option in the Actions menu is inactive).
The only way to remove such a VM is to use the SSH console of the ESXi host.
- Enable SSH on the ESXi host with the problem VM (Actions -> Settings -> Security Profile -> Services -> SSH -> Edit -> Start);
- Connect to the ESXi host using SSH client (Putty, mputty, etc.);
- To get the ID of the problem virtual machine, run this command:
vim-cmd vmsvc/getallvms | grep invalid
- A list of all VMs with the Invalid status registered on this host will be displayed. There should be a string like:
Skipping invalid VM '22'
. In this case, 22 is the ID of the virtual machine; - If you want to try and restore this VM in vSphere, run the command:
vim-cmd vmsvc/reload 22
(in a minute refresh the client interface and check the VM status); - If you want to unregister (delete) a problem virtual machine, run the following command:
vim-cmd /vmsvc/unregister 22
- Refresh the vSphere client interface. The virtual machine with the Invalid status should disappear.
Also you can manually delete the problem VM from the host configuration file /etc/vmware/hostd/vmInventory.xml. To do it, delete the section containing the data of the problem VM from the vmInventory.xml file (backup the file before doing anything) in a text editor (vi, nano) and restart the host services: services.sh restart
If a running virtual machine gets the Invalid status, it is likely that the VM configuration file is corrupted. To resolve the issue:
- Remove the VM from the inventory and restart the ESXi host;
- Then create a new VM and connect the virtual disks (vmdk) of the old VM to it (Use an existing disk);
- Perform Storage vMotion to collect all files of the new VM in a single folder;
- Start your new VM and make sure that it works;
- Delete the files of the old VM.
If the problem of the Invalid VM appeared after losing access to VMFS storages, when the access is restored the started VMs will run and the stopped ones will become isolated. You will have to manually remove them from the inventory and manually register them by finding the VMX file of a virtual machine in the VMFS storage, right-clicking it and selecting Register VM. Then start the VM and make sure that it is available.
11 comments
Solved my issue within seconds. Thanks.
Thank you!
Great article, helped me during critical window
This fixed ,my problem in 1 minute – Thank you
Thank you so musch, the first solved my problem!
Thank you so much.
this kind of article should be official on vmware KB, thank you
thanks a lot….Solved issue with this 2 command
vim-cmd vmsvc/getallvms | grep invalid
vim-cmd /vmsvc/unregister
Great article! Worked perfectly! Had 2 invalid VM’s on my home lag and got rid of them instantly!
Thank you!
2020-05-21T17:06:16.603Z error hostd[BC40B70] [Originator@6876 sub=Vmsvc.vm:/vmfs/volumes/5ebabd93-30fc5cf1-3290-b8aeed7fd77c/CentOS1/CentOS1.vmx opID=663195c3 user=root]
register vmx show invalid
please any help
solved my problem, thanks a lot