Failed to Lock The File is something a common issue in VMware Virtual environment and I thought to write this article as few of my colleagues asked couple of times how to find the vmdk locks in similar situations.
Normally, this happens when there is a lock in place from an ESXi host and another host is trying to power on the Virtual Machine with the lock. I have seen this in many times when there is an latency issue, manual registration of the Virtual Machine or due to an incomplete back up jobs. Sometimes finding the lock is bit of time consuming work but these simple steps can help you to save more time when there is a troubleshooting event.
You might be able to see something similar to the below error message
Who locks the VMDK file ?
At this point this Virtual Machine is already registered in an ESXi host and we need to access the shell console to find the actual ESXi host which is not released the previous lock. In this error message we can see the full path of the locked vmdk file and we need to go to the virtual machine folder, and need to see the content of this folder.
“Tab Key” will display the content or us “ls” command to see the content. You might be able to see some files and find the “<vm_name>-flat.vmdk” file, and use “vmkfstools -D /vmfs/volumes/datastore/<vm_folder_name>/<vm_name>-flat.vmdk” command to find the lock owner.
For example, this is the command to Virtual Machine named “VM1” which is in the “datastore01” datastore
vmkfstools -D /vmfs/volumes/datastore01/VM1/VM1-flat.vmdk
Once you execute the command you can find the MAC address of the ESXi which is keeping the lock to the vmdk file. Here is a similar output, unfortunately I had to blur some names in this screen capture
Now, execute the arp discovery command to see the IP address of the ESXi, or you can see the physical network adapter to see the MAC address
use “arp -a” to view the list of the MAC addresses, I normally execute this from vCenter to make sure the management connectivity
From the vCenter you can see the MAC address
Now, you know the ESXi host which keeps the lock on the vmdk and vMotion the Virtual Machine to that host and power it up. Virtual Machine will power on without any issues.
If you found this post as useful please rate the post and share it!
Akash Balaji
September 19, 2018just delete the files similar to “Windows 10 x64.vmdk.lck” and then try to open the file
you can restore the virtual machine
Aruna Lakmal
September 21, 2018If you have the real world experience similar to this then you know it is not that easy to find the host lock and start the Virtual Machine after deleting the lock file in this situation. Deleting .lck file is not working in this situation and it perfectly works in workstation and some easy recovery in ESXis, when you are not able to power on the Virtual Machines. I’m not sure, even you can find a .lck file in my output screen captures.
Jordan
April 10, 2019Once we found the host and network adapter responsible on locking the vmdk whats the next step for us to make the VM turn on?
Aruna Lakmal
April 10, 2019Just vMotion the powered off VM and power it on. Crucial part is identifying the ESXi host which keeps the lock.
Ahmad Al Maraghy
July 23, 2019Hi Aruna
thanks for your help but when i type
vmkfstools -D /vmfs/volumes/datastore01/VM1/VM1-flat.vmdk
get in result
owner 00000000-00000000-0000-000000000000 mtime 1035035
no MAC
any advice
Aruna Lakmal
July 23, 2019Hi Ahamad
Did you try this out?
https://www.techcrumble.net/2019/06/how-to-identify-the-vmware-virtual-machine-file-locks/
Ahmad Al Maraghy
July 24, 2019thanks for your advice but same resault
-GIS-FS.vmx
Lock [type 10c00001 offset 54288384 v 7951, hb offset 3584512
gen 725, mode 0, owner 00000000-00000000-0000-000000000000 mtime 1125699
num 0 gblnum 0 gblgen 0 gblbrk 0]
Addr , gen 15, links 1, type reg, flags 0, uid 0, gid 0, mode 100755
len 3930, nb 1 tbz 0, cow 0, newSinceEpoch 1, zla 2, bs 8192