Symptoms:
hostd.log
on the ESXi Host where the virtual machine is running, entries are seen similar to the below:hostd.log
can be located in /var/run/log/hostd.log
Unable to open Swap File.
Unable to access a file since it is locked.
Unable to access a file filename since it is locked.
Unable to access Virtual machine configuration.
An unexpected error was received from the ESX host while powering on VM <VM_name>.
Reason: Cannot open the disk disk_name or one of the snapshot disks it depends on.
vmkernel.log
, on the ESXi Host where the virtual machine is running, entries similar to the below are seen:vmkernel.log
can be located in /var/run/log/vmkernel.log
WARNING: World: VM xxxx: xxx: Failed to open swap file path: Lock was not free
WARNING: World: VM xxxx: xxx: Failed to initialize swap file path
Virtual Machine File Lock most common scenarios:
1) Proxy Back Up Virtual Machine (Veeam, Avamar, Unitrends,...etc) is locking one or more of the virtual machine .vmdk
files.
2) An ESXi Host is locking the Virtual Machine files abnormally.
First Scenario
Caution: Make sure there is no backup or snapshot task running on the virtual machine before applying the resolution.
# vim-cmd vmsvc/getallvms | grep -i "VM_Name"
# cd /vmfs/volumes/datastore_name/virtual_machine_name/
--->From step 1grep -i vmdk *vmx
Test_File_Lock-000002.vmdk
in the examplels | while read x; do vmfsfilelockinfo -p $x| grep -i "is locked"; done
vmfsfilelockinfo -p
on each and every file listed under the virtual machine directory.vmfsfilelockinfo -p Test_File_Lock-flat.vmdk
lsof | grep -i "VM_Name"
# /etc/init.d/vpxa stop
# /etc/init.d/vpxa start
hostd
or hostd-profiler
---> this can be fixed by restarting hostd
agent using the below commands:# /etc/init.d/hostd stop
# /etc/init.d/hostd start
/dev/deltadisks
----> this can be fixed by going to the temp directory and remove the files# cd /dev/deltadisks
# rm -rf "VM_Name_00000x-delta.vmdk"
---->file name might be slightly different like "8857142-Test_File_Lock-000002-delta.vmdk
"/dev/deltadisks
. This is the only directory where it is safe to remove the VM files without data loss.device or resource busy
" while trying to run the rm
command , you will need to power off the VM, make sure that there is still a VM file in the /dev/deltadisks
and perform the remove again."00:50:##:##:##:16"
in the exampleesxcli network ip neighbor list
Neighbor Mac Address Vmknic Expiry State Type
-------------- ----------------- ------ -------- ----- -------
192.168.x.xx 00:50:##:##:##:09 vmk0 1190 sec Unknown
192.168.x.xx 00:50:##:##:##:01 vmk0 989 sec Unknown
192.168.x.xx 00:50:##:##:##:16 vmk0 572 sec Unknown ----> 192.168.x.xx is the IP address of the locking ESXi Host
192.168.x.xx 00:50:##:##:##:0a vmk0 662 sec Unknown
192.168.x.xx 00:50:##:##:##:1c vmk0 733 sec Unknown
192.168.x.xx 00:50:##:##:##:09 vmk1 122 sec Unknown
192.168.x.xx 00:50:##:##:##:c6 vmk2 833 sec Unknown
# lsof | grep -i "VM_Name"
vpxa
agent using the below commands:# /etc/init.d/vpxa stop
# /etc/init.d/vpxa start
hostd
or hostd-profiler
---> this can be fixed by restarting hostd
agent using the below commands:# /etc/init.d/hostd stop
# /etc/init.d/hostd start
/dev/deltadisks
----> this can be fixed by going to the temp directory and remove the files# cd /dev/deltadisks
# rm -rf "VM_Name_00000x-delta.vmdk"
---->file name might be slightly different like "8857142-Test_File_Lock-000002-delta.vmdk"
/dev/deltadisks
. This is the only directory where it is safe to remove the VM files without data loss.lsof | grep -i "VM_Name"
) then this is a stale process and the locking ESXi Host has to be rebooted to release the lock."device or resource busy"
while trying to run the rm
command, you will need to power off the VM, make sure that there is still a VM file in the /dev/deltadisks
and perform the remove again.