VMware Disk Consolidation unable to access file since it is locked
I wanted to write up a quick post concerning an error I received recently with consolidating disks on a few VMs. ย Disk consolidation is needed when snapshot disks fail to compact after a Delete or Delete All operation or if the disk did not consolidate. ย Sometimes a snapshot deletion doesn’t commit back to the base disk. ย I had this warning in the summary of a particular VM I was working with recently. ย However, when running the consolidate operation an ominous error presented – VMware disk consolidation unable to access file since it is locked. ย Let’s take a look at this issue and how it was resolved in my case.
VMware Disk Consolidation unable to access file since it is locked
As mentioned above, in logged into the web client recently I saw a virtual machine that was presenting with the warning thatย Virtual machine disks consolidation is needed. ย In looking at the issue initially my suspicion is the deltas were not committed in a backup software run that went down dirty perhaps.
Most know where to find this, but in case you didn’t know, you have theย Consolidateย option under yourย Snapshots menu. ย Here you see it greyed out as this particular VM doesn’t need disk consolidation.
The error I ran into was the below error. ย When I kicked off theย Consolidate process, it came back with aย Unable to access file since it is locked error.
Resolution
There is a pretty helpful VMware KB article onย Unable to delete the virtual machine snapshots issue. ย One of the troubleshooting steps therein was toย restart the management agents on the particular host the VM is running on. ย It can be that the host has a lock on the disk files in question. ย Thinking this could be the culprit, this is exactly what I did. ย You can do this from the command line of the ESXi host itself by running the command:
services.sh restart
After restarting the management agents of the host the particular VM was running on, I was able to successfully run the consolidation process and delete the delta disks.
Thoughts
Snapshot delta disks are definitely a great tool to have when you need them and also the common way that most modern VMware backup software applications are able to grab quick and effective backups. ย However, they can also be a sticky situation as well if you have a situation where you have orphaned delta disks as in my situation here. ย This can happen as it did with me if you have a backup go down dirty or not commit snapshot changes correctly. ย If you try and consolidate the delta disks and see theย VMware Disk Consolidation unable to access file since it is locked error, restarting the management agents may do the trick as the host can have a lock on the files and prevent consolidation.