When attempting to perform a disk consolidation on a Virtual Machine (VM) residing on a vSAN datastore, the operation fails with errors indicating that the VMDK file is locked. This prevents the consolidation from completing, potentially impacting Virtual Machine performance or preventing further snapshot operations.
Symptoms:
Disk consolidation tasks fail for the affected Virtual Machine, with errors reported in the vSphere Client or vCenter Server tasks, such as:
Unable to access file since it is locked Consolidation failed for disk node 'scsi0:O': Failed to lock the file. An error occurred while consolidating disks: Failed to lock the file.
The disk consolidation failure is directly caused by a persistent, stale lock being held on one or more of the Virtual Machine's virtual disk objects (.vmdk) or their associated lock files. This lock prevents the ESXi host from modifying the disk chain required for consolidation.
Note: On a vSAN datastore, file locks are validated on the specific virtual disk objects rather than traditional -flat or -delta files as in VMFS, since vSAN is an object-based system.
To resolve consolidation issues, identify and release stale locks on the Virtual Machine's virtual disk objects by moving problematic lock files to a temporary location.
Check for Persistent Locks:
Run the below command to identify any .lck files or associated vSAN object locks:
for file in .*lck; do echo ${file}; vmfsfilelockinfo -p ${file} |grep -i mode; done
This command will list any lock files and their respective modes.If an exclusive lock is shown (as in the Symptoms section), it confirms the issue..lck files:mkdir /tmp/stale_locksmv .*lck /tmp/stale_locks/
On a traditional VMFS datastore, file locks are typically associated with .vmdk, -flat.vmdk, or -delta.vmdk files within the VM's directory. However, vSAN operates as an object-based storage system. Virtual disks (vdisks) on vSAN are not stored directly within the Virtual Machine's namespace directory alongside configuration files but as distinct objects. File lock issues for vSAN Virtual Machine's thus refer to locks on these vdisk objects. The vmfsfilelockinfo command provides an abstraction to identify locks on these underlying objects, helping to diagnose consolidation or power-on failures effectively.
Investigating virtual disk file locks on vSAN