vmware

vSAN user objects consuming large amount of space

Recently I’ve been working on vSAN cluster where unassociated objects were consuming around 20Tb and all together it was 800 objects. After verification it was clear that those objects are orphaned VMs that were removed from vcenter inventory instead or removing from disk. I was looking for a quick way how to remove them using script.

Unassociated objects can be verified using the rvc tool.

Referencing KB : 70726 , I have followed the steps to get the attributes from all 800 unassociated objects.

Identification of these Objects can be achieved via RVC:
1. Create a list of the unassociated Object UUIDs by copying the formatted list from the end of the output from RVC to a txt file:

 vsan.obj_status_report -t <pathToCluster>


2. Unformat the list by copying the formatted output into a text file (e.g. using vi or another available text editor) and run the below script against this file (on vCSA/ESXi) to generate a file with all UUIDs in a single line:

cat /tmp/inputlist.txt | awk '{print $2}'  |awk '/^'.'/ {printf "%s ",$0} END {print ""}' > /tmp/outputlist.txt

3. Use the input file data in conjunction with objtool on any host in the cluster via CLI:

for i in `cat /tmp/inputlist.txt | awk '{print $2}'`; do python -c "print('*' * 100)";/usr/lib/vmware/osfs/bin/objtool getAttr -u $i | grep -E 'UUID|Object class|Object path'>> outputlist.txt ; done

Processing removing objects in loop based on outputlist.txt prepared in previous step

for x in cat outputlist.txt | grep UUID | cut -f2 -d:; do /usr/lib/vmware/osfs/bin/objtool delete -u $x -f ; done

Leave a comment