Tuesday, September 1, 2015

VMWare 5.5 Remove Locked File To Consolidate Snapshot


1. SSH into the ESXi host using Putty or another SSH client.
2. Drilled down to the Datastore where the VM in question resides: 
cd /vmfs/volumes/[datastore]/[VMDIR]
3. Locate the vmware.log and open with a text viewer.  I used cat vmware.log to view the log.  Also, used putty and set my session to log all screen output but you could extract that log to better review.
4. After you open the log, see if you see any errors regarding locked files, etc. (These errors existed in my case)
5. If errors exist such as "Failed to lock the file" there is possibly a active process that didn't stop correctly from a previous failed task.
6. Run # lsof | grep [name_of_locked_file]
7. Next run Kill [PID] .  The should be at the beginning from the output in step 6 which has been underlined in the following example. 
(EX:  5303   vpxa-worker  12   29  /vmfs/volumes/4360c6cf-2fee4d90-2404-5ef3fc344abb/VM/[name_of_locked_file])
8. The host may appear to have went offline for a few seconds if you happen to have a vSphere client open but should reconnect.
9. Next, select the VM which should still have a message of "Virtual machine disks consolidation is needed" and select Snapshot-->Consolidate.
10. The file should begin to consolidate and the error message should disappear.