Storage space reclamation in VMware with Nutanix

I have been researching storage reclamation for a while. When I got my hands on a Nutanix running VMware I was interested how we could get maximum storage space efficiency out of that. Since Nutanix presents NFS share to ESXi hosts the datastore level reclaim will not be needed. This left me with in-guest reclamation.

After some testing I discovered that writing zeros to virtual machine disks had a interesting affect to VMDK files that resided on Nutanix. VM size had shrinked to a size which it actually consumes. No dead space was left inside VMDK files.

VM size before writing zeros to disk

VM size before writing zeros to disk

VM size after writing zeros to disk

VM size after writing zeros to disk

Storage container space did not change immediately – it was still using the same amount of space as before. Container space usage went down by next morning. Analysis page showed that container space usage went down gradually over night.

Writing zeros

Sdelete is the most widely known tool to write zeros to Windows disks. But caveat using Sdelete is that for some short time the disk is full which can cause problems for applications. I found a better solution – “Davidt Fast Space reclaimer” script written by David Tan. The script generates a 1GB file filled with zeros and copies it until less than 1GB of free space is left on the drive. You can download the script from here.

There is also another script written by Chris Duck called “PowerShell Alternative to SDelete” which can be found from here.

There are also commercial products available for Windows that will write zeros over dead space – Raxco PerfectStorage and Condusiv V-locity. They might be worth to checking out.

For Linux I wrote a script my self that will write zeros until there is less than 1GB space free from total mountpoint size minus 10%. I did minus 10% because to avoid out of space condition and unneeded triggers by monitoring software. My shell scripting skills are not that good so all ideas and suggestions are welcome how to make this script better.

— Script begins here —

# Author: Kalle Pihelgas
# Version: 1.0
# Date: 10.12.2014

# list of mount points with ext3/ext4 file system
localmountpoints=`mount | grep “type ext” | awk ‘{ print $3 }’ `

# loop throug all mountpoints
for mountpoint in $localmountpoints; do

# Get free space
freespace=`df -k $mountpoint | tail -1 | tr -s ‘ ‘ | cut -d’ ‘ -f4 `
freespaceint=`echo $freespace`
# end of free space

# get 10% from total size
totalspace=`df -k $mountpoint | tail -1 | tr -s ‘ ‘ | cut -d’ ‘ -f2 `
totalspaceint=`echo $totalspace`
ten_totalspace=`echo $totalspaceint*0.1 | bc`
# end getting 10% from total space

# get free space amount that will be filled with zeros
freespace=`echo “($freespaceint-$ten_totalspace)/1024/1024” | bc`

# counter for zero files

# write zeros until 10% if free
while [ $freespace -gt 0 ]
echo Mount point: $mountpoint, zeros left to write: $freespace GB
dd if=/dev/zero of=$mountpoint/zerofile$a bs=1M count=1000
sleep 5
a=`expr $a + 1`

# Get free space again
freespacenew=`df -k $mountpoint | tail -1 | tr -s ‘ ‘ | cut -d’ ‘ -f4 `
freespaceint=`echo $freespacenew`
freespace=`echo “($freespaceint-$ten_totalspace)/1024/1024” | bc`
# end of free space recalculation
rm -rf $mountpoint/zerofile*

— Script ends here —

DISCLAIMER! I have not tested these scripts extensively. So I urge you to test these scripts thoroughly before running them on your server! I will not be responsible for any damage caused by these scripts!

6 thoughts on “Storage space reclamation in VMware with Nutanix

  1. Kalle,
    If you have Windows guest systems there is an easier way to do reclamation that using SDELETE. Raxco Software’s PerfectStorage supports reclamation using both Zero Fill and UNMAPs. With the right version of VMware you can shrink a VM “on-the-fly” as seen in this video:

    Reclamation can be scheduled with PerfectStorage and servers don’t have to be taken offline.


    • I am aware of PerfectStorage. It looks to be very useful. Just to clarify with Sdelete or those scripts servers don’t have to be taken offline either.


  2. Pingback: Reclaim Storage Space Without Taking Servers Offline | Raxco Software Blog
  3. Pingback: Nutanix – No rebuild capacity available | Kalle's playground
  4. Pingback: Nutanix и Space Reclamation - Virtualization solution with a nuts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.