Locked VMDK files in ESXi server


 In ESX/ESXi 2.0

To determine which ESX host has locked the file:

    Execute:
    
    # vmkfstools -D vmhba0:2:0:8
    # less /var/log/vmkernel
    
    Look for the string lock=  in the affected ESX hosts .vmdk file. This IP address is the IP of the ESX host that created the lock.
    
    Jul  3 10:13:22 cs_tse_d03 vmkernel: 13:20:24:17.562 cpu0)File descriptor 3 (RZ_NLB_TESTW2003EE1.vmdk) is allocated
    Jul  3 10:13:22 cs_tse_d03 vmkernel: 13:20:24:17.562 cpu0)^Ilength=6291456000 toolsVersion=6313 hwVersion=3 lock=10.16.156.45 RO=0
    
    Note: lock= 0.0.0.0 indicates that a file is not locked by another host.



In ESX/ESXi 3.x/4.x and ESXi 5.0


How to check VMDK fiel locked or not ?


# vmkfstools -D /vmfs/volumes/LUN/VM/disk-flat.vmdk

You see output similar to:

Lock [type 10c00001 offset 54009856 v 11, hb offset 3198976
gen 9, mode 0, owner  4655cd8b-3c4a19f2-17bc-00145e808070  mtime 114]
Addr <4, 116, 4>, gen 5, links 1, type reg, flags 0, uid 0, gid 0, mode 600
len 5368709120, nb 0 tbz 0, cow 0, zla 3, bs 1048576


Where:

    The owner 4655cd8b-3c4a19f2-17bc-00145e808070 indicates that the MAC address of the ESX/ESXi host locking the file is 00:14:5E:80:80:70.

    Note: If the owner has the entry 00000000-00000000-0000-000000000000 it indicates that the file has either a read-only lock or a multi-writer lock or there is no lock on the file.

    The mode indicates the type of lock that is on the file. The list of mode locks are:

        mode 0 = no lock
        mode 1 = is an exclusive lock (vmx file of a powered on VM, the currently used disk (flat or delta), *vswp, etc.)
        mode 2 = is a read-only lock (e.g. on the ..-flat.vmdk of a running VM with snapshots)
        mode 3 = is a multi-writer lock (e.g. used for MSCS clusters disks or FT VMs).


3.With ESX 3.x/4.x and ESXi 5.0 you can use the lsof command on the host holding the lock to attempt to identify the process which is holding the lock:

# lsof |grep /vmfs/volumes/LUN/VM/disk-flat.vmdk

4.Once identifed the process which is locking VMDK , we can kill that using #kill -9 PID.


or

Clearing the file lock by rebooting the ESX host  

As a final troubleshooting step, try restarting the ESX host that holds the lock.   To restart the ESX host:  

Note: Prior to restarting the entire VMware ESX host, restart the management agents. For more information see Restarting the Management agents on an ESX or ESXi Server (1003490).

   1.Migrate all virtual machines from the host to new hosts.
   2.When the virtual machine are moved, place the host in maintenance mode and reboot.Note:
   If you have only one ESX host or do not have the ability to migrate virtual machines, you must schedule a downtime for all affected virtual machines prior to rebooting. When the host has rebooted, start the affected virtual machine.




0 comments:

Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks