An error occurred while consolidating disks. Failed to lock the file
Following procedure can be used to solve few other issues such as,
- Consolidate virtual machine disk files failed
- An error was received from the esxi host while powering on VM “VM Name”
- Cannot open the disk ‘/vmfs/volumes/59xxxxx./vmname/vmname_vmdk’ or one of the snapshot disks it depends on.
- Unable to power on VM because the file is locked.
What exactly is the problem here, do you know?
You are correct. Virtual machine file is locked and you need to remove the lock in order for the VM to start or function properly.
Solution
First you need to identify what is locking the vmdk (it can be one of your esxi hosts or a process).
I will show you first how to identify if the vmdk is locked by an esxi host.
To identify, connect your esxi host via putty and type following command (in this example my vm name is called “nettest”)
~ # find ./ -iname “nettest.vmx”
Next is to check if any host is holding the lock of “nettest” . To do so, type following command.
~ # vmfsfilelockinfo -p “/vmfs/volumes/56d6b2a5-857cf0cc-4233-6cae8b77f070/nettest/nettest.vmx”
As you can see the host having mac address 6c:ae:8b:77:f0:70 is holding the lock.
Now you know the mac address of the host and you need to find out the host name
(my preferred method is to use vSphere powercli, do you know any other way to get this info fast? )
Get-VMHost | `
Get-VMHostNetworkAdapter | `
Where-Object {$_.Mac -eq “6c:ae:8b:77:f0:70“} | `
Format-List -Property *
(Replace the mac address with yours)
Once you identify the host, remove “your problematic vm” from the inventory and add it. Power on the VM.
Problem solved?
Some time the vmdk can be locked by a process.
In such case you need to kill the process from the host who hold the lock to solve the issue.
If you have many disks on the VM, identifying the correct host and lock can be time consuming.
One recommendation is to cross check the error log (most of the case that give you a hint)
Go to the datastore via putty
# cd /vmfs/volumes/56d6b2a5-857cf0cc-4233-6cae8b77f070/nettest/
Identify the host locking vmdk by using following command
# vmkfstools -D nettest_2-flat.vmdk
6cae8b77f070 is the mac address of the host holding the lock. Connect to the host via putty and kill the process
Note: if you see all zeros like this > owner 00000000-00000000-0000-000000000000 which mean the vmdk is not locked
Type following command to identify the process locking the vmdk
# lsof | grep nettest
Once you identify the process, kill it (my vm is off so I am going to kill)
Once you kill all the process, you should be able to start or consolidate the vm.
I hope one of these method help you solve your issue. Let me know which method help you by adding a comment.
Reference
https://kb.vmware.com/s/article/10051
Click Here to Connect with Jobi via Instagram