Cannot delete virtual machine (VM) folder due to active file lock from stale ESXi process.
search cancel

Cannot delete virtual machine (VM) folder due to active file lock from stale ESXi process.

book

Article ID: 431782

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

  • Following error is received upon deleting the VM folder from vcenter:
  • Attempts to delete a virtual machine folder or specific virtual disk files (e.g., -ctk.vmdk, -flat.vmdk) on a datastore fail.
  • Virtual machine highlighted is in powered off state. 

 

Environment

VMware vSphere ESXi
VMware vCenter Server

Cause

An orphaned or stale virtual machine process running on an ESXi host is holding an invalid exclusive lock on the file, preventing the directory from being modified or deleted.

Resolution

 

  • Identify the ESXi host owning the MAC address returned by the vmfsfilelockinfo command by matching it against the physical network adapters in the cluster.
         
       Execute the Command: vmfsfilelockinfo -p <filename>-flat.vmdk (Note: Replace <filename>-flat.vmdk with the actual file name, such as a delta disk, snapshot, or .vmx file).

  • Establish an SSH session to the identified ESXi host as root.

  • Identify the specific World ID of the process holding the lock using the lsof command: lsof | grep <locked_file_name>

  • Terminate the stale process using the identified World ID: esxcli vm process kill -t soft -w <WorldID> (Note: If the soft kill fails to terminate the process, escalate the termination type to hard or force.)

  • Re-run the vmfsfilelockinfo command on the target file to verify the lock is now released and reports as free.

  • Proceed with the standard deletion of the virtual machine folder from the datastore.

 

Additional Information

For more comprehensive details on identifying lock owners across different storage types, refer to the Broadcom Knowledge Base documentation on investigating virtual machine file locks. KB: Investigating Virtual Machine file locks on ESXi Host(s)