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.

Re: Reclaim space quickly (sdelete alternative)

looks interesting but getting errors that it's not signed and i'm not up on powershell. says execution of scripts disabled. any idea how to make it run to test it without screwing around with signatures? it does not say it's blocked so can't seem to even run it unsigned.

Re: Reclaim space quickly (sdelete alternative)

Not to hijack this sled, but how are you reclaiming this space once you run the script? My understanding is that running sdelete (or similar) on a volume will fill the available space with zero's, in essence turning a thin provisioned volume into a thick provisioned volume. So if this is one vmdk of many on a vmfs volume, obviously the vmkfstools/unmap command will not apply to the vmdk (only vmfs), that has now expanded in size as a result of the script. So you need to vmotion this vmdk file to a different data store with a different block size, as thin provisioned then in order to reclaim that space and reduce the size of the actual vmdk file, correct?

Re: Reclaim space quickly (sdelete alternative)

Hi C W,

I should have mentioned that I am performing this task on an iSCSI presented volume rather than a VMDK. I have not tried it on a VMDK and I cannot actually test this myself, but the concept might be the same?? When data is written to the disk and then deleted nothing actually changes on disk except the reference to the file. The array therefore stills sees it as used data. Overwriting this with zeros (and of course deleting the file) allows the array to see this as free space again. Be interested to know if the vmfs in between storage and OS makes any difference here...maybe someone has tried it and can comment?

Re: Reclaim space quickly (sdelete alternative)

Hi David,

Testing this on a guest connected iSCSI Nimble thin provisioned volume optimised for SQL Logs. Copied 10GB of ISO files. Guest reports 10GB used and Nimble says the same ish.. Deleted the ISO files and ran your script. BINGO! Within 10 minutes the array reported the space was down by 10GB. Genuinely impressed. Nimble could do worse than engage with you.

Reclaim space quickly (sdelete alternative)

Hi David, I created a new vmfs volume on nimble and added a Datastore through vcenter. Added Vm disk to a windows 2008R2 VM and put 2GB of files into it. Deleted them and ran your script. BINGO once again. Works with vSphere 5.5.

The user account being used is a domain admin account, and is able to run the script locally on the server being specified in this example. Any help you or anyone else can provide would be great. I realize we are starting to deviate off-topic a bit, but I thought this might come in handy for others who might face a similar problem. My powershell experience is very limited.

Re: Reclaim space quickly (sdelete alternative)

Glad to see this is not just me. I am sure we will be able to collectively come up with a solution. Unfortunately my knowledge of powershell is extremely limited, so I am of limited help, but it would be great to have an automated solution to handle all servers in a scripted and scheduled manner. I cant believe there are not others who would benefit from the same thing.

Re: Reclaim space quickly (sdelete alternative)

I'll try this out today and let you know. Will probably need some error handling so it spits out a useful error message. Btw - have you tried to run the invoke-command to a remote server with a simple command?

Re: Re: Reclaim space quickly (sdelete alternative)

Hi Guys,

Turned out to be a memory error. Running powershell script remotely has finite memory limits depending on WinRM settings. This version should fix it by writing smaller chunks to the starting file in a loop. Now I know why Chris Duck did this in his script. Also spits out the error in the catch statement so it will at least tell you why it failed.

Re: Reclaim space quickly (sdelete alternative)

I tested on the ESXi with with a windows 2008 R2 virtual machine using *.vmdk files. The script runs without errors.

From within windows, everything looks great, lots of free space.

From Nimble, everything looks great, the volume size matches the use space reported by windows.

However, from vCenter shows a size warning on the datastore and when I browse the datastore, I see that the vmdk it at its maximum size. The virtual disk was thin provisioned, but now looks like a think provisioned virtual disk.

This does present a couple of challenges:

a) It affects how I provision datastores and virtual disks, because vCenter warnings about datastores have been configured assuming a thin provisioned vmdk, but the script turns them to "thick" provisioned.

b) This is going to increase backup and recovery times. While the zeroed out space does compress well and won't take up space on the backup repositories (we use Veeam), it is increasing backup duration because all the zeros have to be read.

Does anyone have suggestions on how to best reduce the size of the vmdk file?