As you know VM Swap file only exists when VM is running. Powered On. I'm currently testing an AF VSAN cluster in the lab with 2 hosts + Witness, where the witness is running on a third host (kind of Remote office scenario), and one of the things that allow saving, even more, space on your VSAN datastore is called a Sparse Swap. And the title of today's post is How To Enable Sparse Swap on VSAN.
Sparse Swap – It is possible to reclaim space used by memory swap files. It’s an advanced option on a host which enables the setting policy for swap to no space reservation. You may have some VMs which are configured with a lot of memory and creating large swap files will consume a lot of space on the VSAN datastore. Basically, let's say you run 30 VMs with 8Gb of RAM each. Then the swap capacity consumed by the swap files is 30×8=240Gb.
By specifying an advanced host parameter you can make the swap file thin provisioned. The parameter is:
Now, what's the exact steps?
How To Enable Sparse Swap on VSAN?
Step 0: Check the swap objects consumption on your VSAN datastore. Select your VSAN cluster > Monitor > Virtual SAN > Capacity
Screenshot from my lab. I have over 30 VMs running with different RAM allocation.
Step 1: Connect to each of your hosts via ssh (Putty) and execute this command:
esxcfg-advcfg -s 1 /VSAN/SwapThickProvisionDisabled
Check the value (Optional)
esxcfg-advcfg -g /VSAN/SwapThickProvisionDisabled
Step 2: Reboot All your VMs running on VSAN datastore.
Step 3: Check the Swap objects now….
As you can see, we went from almost 240Gb of space to 300Mb only. Nice savings…..
This post was actually triggered by yesterday's chat on VSAN with @jasemccarty and @vmwarevsan. One of the VSAN users had troubles to activate the thin provisioning. Not with the actual activation. The activation, the advanced config went fine, but there were no savings.
And actually, the problem was that the VMs wasn't restarted and if you think, it is when the VM swap file gets recreated normally. After each reboot, no? So by rebooting those VMs then the space savings are effective.
The lab runs All Flash VSAN 6.2 at the moment and the sparse swap wasn't enabled so far. Now it's done and I have saved some extra Gb of space…
- VMware VSAN 6.2 Released as Part of vSphere 6.0 Update 2
- VMware VSAN 6.2 Licensing Guide
- VMware VSAN 6.2 Announced – Nearline dedupe, Erasure Coding, QoS ++
- VMware VSAN Stretched Cluster Performance and Best Practices