User Tools

Site Tools


vmware:vmdklock

Who is locking that file?

Sometimes you run into a situation where you think or know a file is being used, but you have no idea who is using it. It could be that you attached it to another VM, or it could be that something like VPXa is locking it because someone left a datastore browser window open, regardless, you need to know who so you can unlock it, how to do that?

Well, the good news is that this is relatively easy to do, at least under block storage.

  • Which ESX is locking that file?

Remember that a VMDK has 2 parts: descriptor and data, the descriptor is rarely locked, you need to focus on the data portion, which has a file name ending in -delta.vmdk or -flat.vmdk

vmkfstools -D <filename>

This will result in an output similar to this:

Lock [type 10c00001 offset 67784704 v 190, hb offset 4038656 
gen 19, mode 1, owner 4aa5c319-7272c09a-3976-00221925665d mtime 9451] 
Addr <4, 141, 178>, gen 179, links 1, type reg, flags 0x0, uid 0, gid 0, mode 100600 
len 4294967296, nb 4096 tbz 3897, cow 0, zla 3, bs 1048576 vmkernel: 0:11:33:16.169

Focus on that line:

4aa5c319-7272c09a-3976-00221925665d

The last part of it

00221925665d

is the MAC address of one of the pNICs on one of the ESX servers.

  • SSH into that host:

Now that we know the MAC address, we need to find out which ESX host has it, you can get that through your switch ARP table or you can simple check the Configuration→Network Adapters page, the NIC does have to be in use so be careful. Once you find out the ESX host, ssh into that one.

  • What process is doing the locking?

This is where 'lsof' comes in handy, lsof stands for List Open File, all we have to do is this:

lsof -n | grep <FILENAME>

Now you will have the process ID and some other related info, if it is a VMX process, check the VM, if it is vpxa for example, restart it.

Good luck

vmware/vmdklock.txt · Last modified: 2015/02/25 15:26 by naccad