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

“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: 17 Average: 5]

8 responses

  1. Akash Balaji Avatar
    Akash Balaji

    just delete the files similar to “Windows 10 x64.vmdk.lck” and then try to open the file

    you can restore the virtual machine

    1. Aruna Lakmal Avatar

      If 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.

  2. Jordan Avatar
    Jordan

    Once we found the host and network adapter responsible on locking the vmdk whats the next step for us to make the VM turn on?

    1. Aruna Lakmal Avatar

      Just vMotion the powered off VM and power it on. Crucial part is identifying the ESXi host which keeps the lock.

  3. Ajith P Avatar
    Ajith P

    This is will not work always , we will not get the mac it simply give out put 0000000000 instead of Mac ..

    Here is the steps:

    1- user find find /vmfs/volumes -name VMNAME ( identify where the VMx file )
    2- get into that directory run the below command to get Mac
    3-vmkfstools -D .vmx.lck

    Lock [type 10c00001 offset 409624576 v 71, hb offset 3932160
    gen 83, mode 1, owner 5cd96d7d-58135cfc-4d57-000af7e75c82 mtime 4401
    num 0 gblnum 0 gblgen 0 gblbrk 0]
    Addr , gen 70, links 1, type reg, flags 0, uid 0, gid 0, mode 600
    len 0, nb 0 tbz 0, cow 0, newSinceEpoch 0, zla 4305, bs 65536

    4 you have mac now (000af7e75c82 )

    5 – download RV tool report
    6 seach for the mac 000af7e75c82 ( make it is in a mac format 00-0a-f7-e7-5c-82
    7 – you will get the host name
    8- You are good to power on or power off or move to different ESXi

    Ajith.P
    ajith128@yahoo.co.in

  4. Ahmad Al Maraghy Avatar

    Hi 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

      1. Ahmad Al Maraghy Avatar

        thanks 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

Leave a Reply

Your email address will not be published. Required fields are marked *