How to find empty delta files
When you have a large number of delta files caused by a rogue snapshot, in some cases, we end up with lots of delta files that are empty.
The way to determine if the file is empty is to compare the CIDs inside the delta VMDK descriptor.
To explain further, each VMDK is actually made out of 2 files:
- filename.vmdk, the descriptor file
- filename-flat.vmdk or filename-delta.vmdk (delta in case of snapshot file)
The descriptor file is a plain text file, you can read it by doing cat filename.vmdk and in that file you will have the 2 values that we are interested in.
If CID and ParentCID values are identical, we can bypass that file and go to the previous one, in case of a small number of deltas you can easily cat each file and see the values, but when dealing with hundreds of file, you need to script it, and this is what I did:
#!/bin/bash # for i in *0000??.vmdk do FCID=`grep CID $i | grep -v parent | cut -d '=' -f 2` PCID=`grep parentCID $i | cut -d '=' -f 2` #echo $PCID $FCID if [ $FCID == $PCID ]; then echo $i $FCID $PCID fi done
This should spit out a list of delta files that can be bypassed, in some instances you will find that all of them can be bypassed and in this case you can just point the VMX to the flat file and move on.
Of course this breaks when there are spaces in the filenames, but I'm too lazy to perfect this, if someone does, let me know