Tuesday, 12 January 2016

Finding Lock On A File

Written by Suhas Savkoor

If we want to determine which ESXi host is holding a lock on the file, we usually end up following this KB article. The classic command we use is vmkfstools -D /path/to/the/file

I came across another command, which is pretty good and also saves the time for us in finding out which host corresponds to the MAC address that is locking the particular file. From the SSH of the host, browse the virtual machine directory. 

Once you are inside the virtual machine's directory run the following command against the file, that you want to check for lock. 
vmfsfilelockinfo -p <file_name> 
For example:
# cd /vmfs/volumes/52a62585-b8e592b8-3570-005056030027/CentOS7 
# vmfsfilelockinfo -p CentOS7-flat.vmdk 

The output is as follows:

vmfsfilelockinfo Version 1.0
Looking for lock owners on "CentOS7-flat.vmdk"
"CentOS7-flat.vmdk" is locked in Exclusive mode by host having mac address ['00:50:56:03:0d:38']
Trying to make use of Fault Domain Manager
Found 3 ESX hosts using Fault Domain Manager.
Searching on Host
Searching on Host
    MAC Address : 00:50:56:03:0d:38

Host owning the lock on the vmdk is, lockMode : Exclusive
Total time taken : 0.02 seconds.

This tells us the MAC address of the host having the lock on the file, as well as which host corresponds to that MAC address even if the SSH session is conducted through a different ESXi host.

This will again not work for NFS!


Post a Comment