2011-09-07

How to unlock a VMDK file

while trying to power on an old VM i've got the following error message:

Unable to access file <unspecified filename> since it is locked

to investigate the issue i've looked and the vmware.log in the VM home folder and i've found the following error


Sep 07 10:18:24.260: vmx| Msg_Post: Error
Sep 07 10:18:24.260: vmx| [msg.disk.noBackEnd] Cannot open the disk '/vmfs/volumes/49b105df-0d080910-d97a-000423d87441/server/server.vmdk' or one of the snapshot disks it depends on.
Sep 07 10:18:24.260: vmx| [msg.disk.configureDiskError] Reason: Failed to lock the file.----------------------------------------

it seemed that the vmdk file was locked, but i was pretty sure that no other VM was using it and no snapshots were active.
after a little googling i've found the following thread that shows how to identify who is locking a vmdk file.
unfortunately, on my host it gave the following output:

[root@esx server]# vmkfstools -D server-flat.vmdk
[root@esx server]# tail /var/log/vmkernel
Sep  7 17:48:42 esx vmkernel: 36:03:13:22.953 cpu4:1041)FS3: 130: <START server-flat.vmdk>
Sep  7 17:48:42 esx vmkernel: 36:03:13:22.953 cpu4:1041)Lock [type 10c00001 offset 17129472 v 99, hb offset 3367936
Sep  7 17:48:42 esx vmkernel: gen 150, mode 0, owner 00000000-00000000-0000-000000000000 mtime 1213998]
Sep  7 17:48:42 esx vmkernel: 36:03:13:22.953 cpu4:1041)Addr <4, 21, 20>, gen 21, links 1, type reg, flags 0x0, uid 0, gid 0, mode 100600
Sep  7 17:48:42 esx vmkernel: 36:03:13:22.953 cpu4:1041)len 13958643712, nb 6656 tbz 0, zla 3, bs 2097152
Sep  7 17:48:42 esx vmkernel: 36:03:13:22.953 cpu4:1041)FS3: 132: <END server-flat.vmdk>

owner 00000000-00000000-0000-000000000000 was of no use to identify the culprit.
that same datastore was visible to several others esx hosts, so i tried the same command from another host and i had more luck: that time a full UUID was returned as the owner.
i've followed the original thread instructions to identify the esx host that was owning the lock and i've restarted it after migrating off all the VMs.
the reboot removed the lock and i was able to turn on again the old VM.

lesson learned: if at first you don't succeed, try on another host

4 comments:

  1. Anonymous9/1/13 18:22

    Hey you could able to unlock the VMDK file even with out rebooting the host.
    a. After you have identified the host, login to the service console of ESXI host.
    b. Use the command lsof | grep vmname (name of the VM which you couldn't able to start).
    c. use command kill -9 pid ( to kill the process which is offending or locking your VMDK file)
    Very good post man Thank You

    ReplyDelete
  2. Anonymous23/3/13 01:08

    To the person who posted above:

    I restarted every server in our relatively small environment, and I couldn't get this fixed. I looked all over the web, and your comment was the only solution I found. I would have cried like an angry baby had I not found this. Thank you!

    ReplyDelete
  3. Anonymous25/4/13 16:01

    Let me chime in with another Thanks! Very simple solution, worked for me.

    ReplyDelete