When attempting to consolidate disks on NFS datastore, the task fails with below error:
"Unable to access the file since it is locked. Consolidation failed for disk node 'scsi#:#'. Failed to lock the file. An error occurred while consolidating disks. Failed to lock the file."
Symptoms:
"Failed to open disk link /vmfs/volumes/<Datastore-UUID>/<VM-name>/<VM-name>.vmdk :Failed to lock the file (16392)Disk chain is not consistent : Failed to lock the file (16392)".
YYYY-MM-DDTHH:MM:SS.000Z Wa(180) vmkwarning: cpu35:7302243)WARNING: NFSLock: 4156: File is being locked by a consumer on host esxi1.example.com with read-only lock.YYYY-MM-DDTHH:MM:SS.000Z In(182) vmkernel: cpu35:7302243)NFSLock: 4160: File <VM-name>-sesparse.vmdk(.lck-d1###0000000000). fromUnlink NYYYY-MM-DDTHH:MM:SS.000Z In(182) vmkernel: cpu35:7302243)NFSLock: 5141: failed to get lock on file <VM-name>-sesparse.vmdk(.lck-d1###0000000000) 0x4##########c0 on <Datastore-name> 13#################-9#################27 (127.x.x.x): Busy. fromunlink NYYYY-MM-DDTHH:MM:SS.000Z Wa(180) vmkwarning: cpu30:7302243)WARNING: NFSLock: 4156: File is being locked by a consumer on host esxi1.example.com with read-only lock.YYYY-MM-DDTHH:MM:SS.000Z In(182) vmkernel: cpu30:7302243)NFSLock: 4160: File <VM-name>-sesparse.vmdk(.lck-d1####0000000000). fromUnlink NYYYY-MM-DDTHH:MM:SS.000Z In(182) vmkernel: cpu30:7302243)NFSLock: 5141: failed to get lock on file <VM-name>-sesparse.vmdk(.lck-d1####0000000000) 0x4###########80 on <Datastore-name> 13###################-9################27 (127.x.x.x): Busy. fromunlink N
VMware ESXi 8.x
This problem occurs when a stale NFS lock on the VMDK files exists on an ESXi host different from the host where the VM is located.
As a result, the consolidation process cannot obtain exclusive access to the VMDK files.
1. Identify the locking host:
# ls -larth# hexdump -C .lck-d1####0000000000Output:
00000000 28 ## ## 00 00 00 00 00 ## ## ## ## ## ## ## ## |(Gn.....#.......|000000## 02 00 00 00 ## ## ## ## ## ## ## ## ## ## ## ## |....esxi2.example.com|
In the above example, we can see this lock was being held on a different host esxi2.example.com
2. Reboot the locking host to release the lock.
3. Retry disk consolidation from the vSphere Client:
If the stale NFS lock is on the same host where the vm resides, then follow below KB:
Disk Consolidation Fails with “Unable to access file since it is locked” on NFS Datastore