Problem:
How do I enable Space Reclaim on a NetApp FAS or AFF LUN to reflect space used in VMware Datastore
Solution:
This is a solution of the following scenario: data is filled on the datastore and the space used on the VMware datastore matches the space used on the NetApp LUN. However when items are deleted from the VMware datastore and more space is free this is not reflected on the NetApp LUN.
First identify the datastore with the issue:
On the corresponding LUN run the below command on the NetApp cli to see the status of space reclaim
lun show -vserver crp_svm -volume crp_vol3 -lun crp_vol3 -fields space-allocation
To enable it we will need to take the LUN offline so you will need to shut down or move the VMs to another datastore. Then run the following:
lun modify -vserver crp_svm -volume crp_vol3 -lun crp_vol3 -state offline
You should see the datastore go offline in VMware
Run the below command to enable space reclaim:
lun modify -vserver crp_svm -volume crp_vol3 -lun crp_vol3 -space-allocation enabled
You can now bring the LUN online again:
lun modify -vserver crp_svm -volume crp_vol3 -lun crp_vol3 -state online
The last step is to force VMware to map the space used in the datastore with the space used on the LUN. Open the esxcli and run:
esxcli storage vmfs unmap -l crp_vol3