How to handle Orphaned VMs

What is an Orphaned VM, let’s find the reason of orphan virtual machines.
In VirtualCenter under very rare circumstances, you may find that you have a virtual machine that has an orphan designation. An orphan virtual machine is one that VirtualCenter discovered previously, but currently is not able to identify the associated host.


An orphan might be created:
If you delete the virtual machine's configuration file through ESX Server Console.
If vmotion is under extreme stress.
This occurred once. The virtual machine continued to run on the destination, however VirtualCenter saw it as an orphan because the configuration file had been removed on the source and was in transition to the destination.


So, How to handle these Orphans?
login to ESX Host and try to find the virtual machine status from console.
use “vmware-cmd –l” command to get the list of VMs. It will show the result that has VMs currently running on ESX Host.
When you try to find orphan VM giving the command “vmware-cmd /vmfs/volumes/LUN/VM/VM.vmx getstate

It gives the result as that “VMControl error -11: No such virtual machine”
Try restarting, mgmt-vmware & vmware-vpxa daemons from esx console.
#service mgmt-vmware restart
#service vmware-vpxa restart

If still finding the orphan, unregister and re-register the VM from ESX console with following command.

Unregister:
vmware-cmd –s unregister /vmfs/volumes/LUN/VM/VM.vmx
The result will be “register(/vmfs/volumes/LUNUUID/VM/VM.vmx = 1

Register:
vmware-cmd –s register /vmfs/volumes/LUNUUID/VM/VM.vmx
The result will be “register(/vmfs/volumes/LUNUUID/VM/VM.vmx = 1


You can also unregister and re-register from VirtualCenter (GUI)

Now the VM appears as normal VM and you can power on it.
While powering on the VM, It may give you a popup asking about the UUID of the VM.


So select as Keep as I you not moved the location of the VM or not copied to new location with different hardware.


A simple method to fixing the orphaned Virtual Machine:
Launch Virtual Center or Virtual Client
Right click on the orphaned virtual machine
Select ‘Remove from Inventory’
Now go the summary page of the ESX host and select correct datastore
Browse the datastore form the .vmx file of the VM
Now locate the VMX file.
Right click on the .vmx file of the VM and choose ‘Add to Inventory’
Go through the wizard and your Virtual Machine should appear online again.


doest it helped you?