Loading Posts...

“Cannot Open The VM disk or On Failed to Lock The File”

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

Failed to Lock The File - Lock Owner

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

Failed to Lock The File : VC

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!

Click to rate this post!
[Total: 16 Average: 5]

Aruna Lakmal

Associate Technical Specialist, Sri Lanka. Technology junky, enthusiast, a VMware vExpert and a blogger with more than 8 years of Experience in Virtualization and Cloud Native technologies.

Get Updates Directly To Your Inbox!


Show 7 comments

Leave a Comment

Loading Posts...