If virtual machine is disconnected from ESXI due to vmx file lock, follow the below steps to fix the issue.
Note:
Note down the ESXI IP, VM hostname, Ip address & .vmx & .vmdk file path before starting the activity.
Step:1
Remove the VM from the inventory. Select VM ==> Right click and remove VM from inventory.
Step:2
Browse the datastore where the .vmx file is located. Right click .vmx file and try adding to the inventory.
If still issue is not resolved. Need to find the lock and it needs to be removed.
Step:3
Login to ESXI and locate the process ID using below command.
1) esxcli vm process list
Output will be as below.
EG (Output:
VM
World ID: 3338106
Process ID: 0
VMX Cartel ID: 3338103
UUID: 42 00 2c c6 2b d6 17 af-15 58 75 b6 2c 26 f6 10
Display Name: VM
Config File: /vmfs/volumes/531edada-36119f2e-0012-14feb5caca3b/VM/VM.vmx)
Command to kill the process
2) esxcli vm process kill -t (type) -w (world id)
type – soft
hard
force
Step:4
Login to esxi and enter the datasore path as below.
(EG) /vmfs/volumes/531edada-36119f2e-0012-14feb5caca3b/virtual machine #
and run the below command to find the NIC which holds the lock.
#vmkfstools -D VMname.vmx
From above screenshot we can find the lock owner. Here NIC 549f351f04c6 holds the lock.
Step:4
Run the below command to to check the stale process which holds the lock
#lsof | grep VMname
Step:5
Run the command ” kill -9 process Id ” to kill the process.
(EG) kill -9 20425216
Step:7
Browse the datastore where the .vmx file is located. Now right click .vmx file and add VM to the inventory.
VM’s can also be registered using below command
vim-cmd solo/registervm (datastore path)
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=10051 click
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1014165 click