Every time a VM is started a swapfile is created on the datastore where the VM resides.
The format for these files are .vswp
I was working my way through a customers datastores, trying to find some orphaned VMs or files that could be deleted and I noticed that many of the VM folder had the .vswp files and then some extra ones.
The extra vswp files had a different ending, and that was vswp.xxxxx, where the x’s represent a number.
These files are created when your ESXi hosts crash and when the VM was restarted, the file was still there so it’s renamed and a new .vswp file is created.
For an active VMware environment, you could potentially see a lot of these if you had some ESXi crashing on you in the past. For that environment (around 60 VMs) I found 34 GB of “dead” .vswp files. That’s a lot when your Datastores are at full capacity.
But you really can’t manually go searching for these unless you like repetitive and brain-damaging work.
This really isn’t a big piece of code and really doesn’t deserve a script by itself 🙂
dir vmstores: -Recurse -Include *.vswp.* | Select Name,Folderpath
This will give you a output of:
Note: This will take a lot of time to run on bigger environments. I tried this in a big production environment (40+ Datastores) and it took 5 hours to run. But it found 24GB of emtpy .vswp files.
I hope this helps to find some space on your expensive SAN 🙂
Edit: Raphael Shitz at http://www.hypervisor.fr has a great script for searching for orphaned files on Datastores and he added a search for “*.vswp.*”. And its a lot faster, only few minutes rather than hours. His site is in french so here is a link to his post through Google translate. And if you can read french, Allez.