Disk Consolidation Fails with “Unable to access file since it is locked” on NFS Datastore
search cancel

Disk Consolidation Fails with “Unable to access file since it is locked” on NFS Datastore

book

Article ID: 412870

calendar_today

Updated On:

Products

VMware vSphere ESX 8.x

Issue/Introduction

When attempting to consolidate snapshots for a virtual machine, the task fails with the following error:

          Virtual machine disks consolidation failed - "Unable to access file /vmfs/volumes/<Datastore-UUID>/<VM-Name>/<VM-Name>_X.vmdk since it is locked"

Symptoms:

  • The affected VM is unable to perform snapshot consolidation.
  • Migration and Clone operations for the VM also fail.
  • Running vmfsfilelockinfo or vmkfstools -D on the VMDK does not show any external lock.
  • VM is hosted on an NFS datastore.
  • vmkernel logs show .lck file entries pointing to the same ESXi host.


    Example vmkernel log entries(vmkernal.log):

    NFSLock: oid for existing li(lockfile .lck-500000000 file VMNAME-flat.vmdk) matches for VMNAME-flat.vmdk

    NFSLock: oid for existing li(lockfile .lck-da00000000 file VMNAME_4-flat.vmdk) matches for VMNAME_4-flat.vmdk

    YYYY-MM-DDTHH:MM:SS.00Z In(182) vmkernel: cpu92:13405967 opID=7c6756a8)NFSLock: 2456: oid for existing li(lockfile .lck-500000000 file VMNAME-flat.vmdk) matches for VMNAME-flat.vmdk
    YYYY-MM-DDTHH:MM:SS.00Z  In(182) vmkernel: cpu91:2099015 opID=b28b25af)NFSLock: 2456: oid for existing li(lockfile .lck-da0000000 file VMNAME_4-flat.vmdk) matches for VMNAME_4-flat.vmdk
    YYYY-MM-DDTHH:MM:SS.00Z  In(182) vmkernel: cpu54:13406290)NFSLock: 2456: oid for existing li(lockfile .lck-da00000000 file VMNAME_4-flat.vmdk) matches for VMNAME_4-flat.vmdk
    YYYY-MM-DDTHH:MM:SS.00Z  In(182) vmkernel: cpu60:13406290)NFSLock: 2456: oid for existing li(lockfile .lck-500000000 file VMNAME-flat.vmdk) matches for VMNAME-flat.vmdk

     

 

Environment

VMware ESXi 8.0

Cause

The issue occurs when stale NFS locks remain on the VMDK files on the same ESXi host where the VM resides.

This typically happens when the hostd or vpxa management agents on the host enter a hung or stale state, preventing the lock from being released or re-acquired by consolidation tasks.

As a result, the consolidation process cannot obtain exclusive access to the VMDK files.

Resolution

1. Identify the locking host

    • SSH into the ESX host.
    • Review vmkernel.log for NFS lock messages.
    • Navigate to the appropriate VM directory:
    • Check the .lck files in the VM directory.
           ls -larth
    • Use the hexdump command to interrogate the .lck file for the hostname:
      # hexdump -C .lck-e001000000

      Output:
      00000010 01 00 00 00 64 68 69 6e 67 2d 65 73 78 2e 76 6d |..........esxi1.example.com|
      00000020 77 61 72 65 2e 63 6f 6d 00 00 00 00 00 00 00 00 |esxi1.example.com........|

      In the above example, we can see this lock was being held for esxi1.example.com

2. Place the locking ESXi host into maintenance mode
                   
Command:   esxcli system maintenanceMode set --enable true

3. Restart management agents on the locking host

                    Command:
                    /etc/init.d/hostd restart
                   /etc/init.d/vpxa restart

4. Retry disk consolidation from the vSphere Client:

    • Right-click the VM → SnapshotsConsolidate
    • The task should now complete successfully. 

5. Exit maintenance mode after verification:
                Command:   esxcli system maintenanceMode set --enable false

Additional Information

  • This issue commonly affects VMs hosted on NFS datastores, where locking is managed by the ESXi host rather than the vCenter Server.
  • If VM logging is disabled (logging = "FALSE" in the .vmx file), enable it to improve traceability:
    logging = "TRUE"

  • Regular monitoring of .lck files on NFS datastores can help identify stale locks early.
  • Ensure ESXi hosts and storage firmware are running the latest versions to avoid known NFS locking bugs.

Related Articles:

  • Investigating Virtual Machine file locks on ESXi hosts (KB 314365)
  • Troubleshooting issues resulting from locked virtual disks (KB 316576)
  • NFS Datastore File Locking and Latency Issues (KB 392472)