WatkinsT123
Contributor
Contributor

Unable to clear locked file.

Hi,

I currently have two VMs that for one reason or another had to be removed from inventory but now i am unable to add them back in due to a locked file. I know what host is locking the file (by running vmfsfilelockinfo -p /vmfs/volumes/DATASTORE/FILELOCATION) and i have tried to reboot the host/shutting it down but it still says its locked.

Is there a way to manually remove this locked file?

thanks in advance.

4 Replies
Alex_Romeo
Leadership
Leadership

Hi,

the file .lck must be deleted from the virtual machine folder

or

How to remove vmx.lck file , Unable to poweron VM

Cause

This issue occurs when the .lck-xxx file located in the virtual machine folder holds a lock on the vmdk file. When an ESXi/ESX host accesses a virtual machine disk file on a NFS based datastore a .lck-xxx lock file is generated in the same directory as the disk file. This file prevents other ESXi/ESX hosts from accessing the virtual disk file.

  
   Resolution

To resolve this issue, delete the .lck-xxxx file located in the virtual machine folder.

Caution: Ensure the vmdk files are not in use by another virtual machine before performing these steps. Removing a valid .lck can cause instability.

To delete the .lck-xxxx file:

  1. Ensure the virtual machine is powered off.
  2. Connect to the ESXi/ESX host using Secure Shell (SSH). For more information, see Connecting to an ESX host using a SSH client (1019852).
  3. Go to the virtual machine folder, run the command:

    cd /vmfs/volumes/datastore_name/virtual_machine_folder
     
  4. List all files including the hidden files, run the command:

    ls -la
     
  5. Remove the lock file, run the command:

    rm .lck-xxxx

    Where xxxx is a sequence of numbers. For example, lck-001455721.

    Note: Ensure the virtual machine is not running.
     
  6. Power on the virtual machine.

  Note

: When the virtual machine is powered on, you see a new .lck-xxxx

file generated in the virtual machine folder. This is expected behavior.

ARomeo

Blog: https://www.aleadmin.it/
WatkinsT123
Contributor
Contributor

Hi,

Thanks for this.

When i run rm VMNAME.vmx.lck

rm: can't remove 'VMNAME.vmx.lck': Device or resource busy

0 Kudos
Alex_Romeo
Leadership
Leadership

Follow the procedure of this Kb

VMware Knowledge Base

Blog: https://www.aleadmin.it/
0 Kudos
continuum
Immortal
Immortal

Hi

if you dont make any progress - send a 2gb headerdump and I try to figure out a patch

see Create a VMFS-Header-dump using an ESXi-Host in production | VM-Sickbay

Ulli


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos