David Tan

Reclaim space quickly (sdelete alternative)

Discussion created by David Tan on Jan 29, 2014
Latest reply on Jul 25, 2017 by Tony Savage

This is related to the previous post outlining why pre-Windows2012 does not return space back to the array. I just can't seem to add a tag for "scriptingblitz"




There are two main problems with sdelete that I have observed:


1. It does not recognise mountpoints, so you need to add a letter to the mountpoint to run.

2. It is very, very slow.... taking sometimes days to reclaim a couple of TB.


Chris Duck came up with a great idea of using powershell to perform the same kind of task as sdelete, but has the advantage of working with mountpoints - http://blog.whatsupduck.net/2012/03/powershell-alternative-to-sdelete.html


I have pinch this idea and some of his code to create my own version that runs roughly 10x faster. It uses the same method to create a 1GB initial file (of zeros) which takes about 60 sec. From there I just use good old DOS copy to clone the file until there is no more space left of the drive (ie <1GB). The copy commands are surprisingly fast! and on the 10GB connected array it will reclaim at a rate of 200-300MB/sec, which is roughly 1TB/hr. There could be ways to squeeze more performance out of it using other copy utilities that allow multithreads like robocopy but this works well enough for my liking


Basic Usage is for example


powershell .\NimbleFastReclaim.ps1 E:\

powershell .\NimbleFastReclaim.ps1 E:\dir1\mountpointishere\


It will try to log to C:\temp dir but can specify different file. A third parameter can be passed to sleep between copies to throttle the process if desired.