Skip to Content

How to Reclaim Space on S2D Volumes in Windows Server 2016

Storage Spaces Direct (S2D) is a feature of Windows Server 2016 that allows you to create a highly available and scalable software-defined storage solution using local disks on multiple servers. S2D can be used for various scenarios, such as hyper-converged infrastructure, private cloud, or big data analytics.

However, one of the common challenges that S2D users face is how to reclaim space on S2D volumes after deleting files or virtual hard disks (VHDX). Unlike traditional storage systems, S2D does not automatically free up the space that was occupied by the deleted items. This can lead to inefficient use of storage resources and potential performance issues.

In this blog post, we will show you how to reclaim space on S2D volumes using PowerShell commands and explain why this is necessary. We will also answer some frequently asked questions about S2D and space reclamation.

Why Do You Need to Reclaim Space on S2D Volumes?

S2D uses a technology called Resilient File System (ReFS) to format and manage the volumes that are created from the storage pool. ReFS is a modern file system that offers many benefits, such as data integrity, resiliency, scalability, and deduplication.

However, ReFS also has some limitations, one of which is that it does not support the TRIM or UNMAP commands that are used by NTFS and other file systems to notify the underlying storage layer that blocks of data are no longer in use and can be freed up. This means that when you delete a file or a VHDX on an S2D volume, the space that was allocated to it is not released back to the storage pool. Instead, it remains marked as used by ReFS until it is overwritten by new data.

This behavior can cause several problems, such as:

  • Wasted storage space: If you delete a large amount of data on an S2D volume, you may not be able to use the freed space for other purposes until it is reclaimed manually or overwritten by new data. This can reduce the available capacity and efficiency of your storage system.
  • Reduced performance: If your S2D volume becomes full or nearly full due to unreclaimed space, you may experience performance degradation or errors when trying to write new data or create new VHDX files. This can affect the availability and reliability of your applications and services.
  • Increased fragmentation: If your S2D volume has a lot of unreclaimed space scattered across different blocks, it may become more fragmented over time. This can result in slower read and write operations and higher latency.

Therefore, it is important to periodically reclaim space on your S2D volumes to avoid these issues and optimize your storage utilization and performance.

How to Reclaim Space on S2D Volumes?

To reclaim space on S2D volumes, you need to use two PowerShell cmdlets: Optimize-StoragePool and Optimize-Volume. These cmdlets perform different functions that work together to free up the unused space on your S2D volumes.

Optimize-StoragePool is used to optimize the allocation of physical disks in a storage pool. It balances the distribution of data across the disks and repairs any physical disk failures. It also supports a parameter called -ReclaimStorage that instructs the cmdlet to reclaim any unused space from the storage pool and make it available for new allocations.

Optimize-Volume is used to optimize the performance and reliability of a volume. It performs various tasks, such as defragmentation, slab consolidation, tier optimization, and deduplication. It also supports two parameters that are relevant for space reclamation: -ReTrim and -SlabConsolidate.

-ReTrim tells the cmdlet to send TRIM or UNMAP commands to the underlying storage layer for all the unused blocks on the volume. This allows the storage layer to mark these blocks as free and reuse them for new allocations.

-SlabConsolidate tells the cmdlet to consolidate the slabs on the volume. Slabs are units of allocation used by ReFS to store data on a volume. When you delete data on an S2D volume, some slabs may become partially empty or entirely empty. Slab consolidation moves the data from partially empty slabs to fully empty slabs and releases the empty slabs back to the storage pool.

To reclaim space on an S2D volume, you need to run both Optimize-StoragePool and Optimize-Volume with the appropriate parameters. The order of execution does not matter, but you need to run both commands for each volume that you want to optimize.

For example, if you want to reclaim space on an S2D volume with drive letter E:, you can run the following commands:

Optimize-StoragePool -FriendlyName "S2D" -ReclaimStorage
Optimize-Volume -DriveLetter E -ReTrim -SlabConsolidate

Note that these commands may take some time to complete, depending on the size and state of your S2D volume. You can monitor the progress and status of the optimization tasks by using the Get-StorageJob cmdlet.

Frequently Asked Questions

Here are some common questions and answers about S2D and space reclamation.

Question: How often should I reclaim space on my S2D volumes?

Answer: There is no definitive answer to this question, as it depends on several factors, such as how frequently you delete data on your S2D volumes, how much free space you have on your storage pool, and how sensitive you are to performance and capacity issues. However, a general rule of thumb is to reclaim space on your S2D volumes at least once a month or whenever you notice a significant drop in available space or performance.

Question: Can I reclaim space on my S2D volumes without affecting the availability and performance of my applications and services?

Answer: Yes, you can reclaim space on your S2D volumes without causing any downtime or disruption to your applications and services. The Optimize-StoragePool and Optimize-Volume cmdlets are designed to run in the background and have minimal impact on the foreground operations. However, you may still want to schedule the optimization tasks during off-peak hours or low-traffic periods to avoid any potential interference or contention.

Question: Can I automate the space reclamation process for my S2D volumes?

Answer: Yes, you can automate the space reclamation process for your S2D volumes by using PowerShell scripts or scheduled tasks. For example, you can create a PowerShell script that runs the Optimize-StoragePool and Optimize-Volume cmdlets for all your S2D volumes and then schedule it to run periodically using the Task Scheduler. Alternatively, you can use third-party tools or services that offer automated optimization features for S2D volumes.

Question: What are some best practices for managing and optimizing my S2D volumes?

Answer: Here are some best practices for managing and optimizing your S2D volumes:

  • Monitor the health and performance of your S2D volumes regularly using tools like Performance Monitor, Event Viewer, or Storage Spaces Direct Management Pack.
  • Reclaim space on your S2D volumes periodically using the Optimize-StoragePool and Optimize-Volume cmdlets.
  • Enable deduplication and compression on your S2D volumes to reduce the storage footprint and improve the efficiency of your storage system.
  • Use ReFS as the file system for your S2D volumes to take advantage of its features, such as data integrity, resiliency, scalability, and deduplication.
  • Use fixed-size VHDX files for your virtual machines instead of dynamically expanding VHDX files to avoid fragmentation and performance degradation.

Conclusion

S2D is a powerful feature of Windows Server 2016 that allows you to create a highly available and scalable software-defined storage solution using local disks on multiple servers. However, one of the challenges that S2D users face is how to reclaim space on S2D volumes after deleting files or VHDX files.

In this blog post, we explained why you need to reclaim space on your S2D volumes and how to do it using PowerShell commands. We also answered some frequently asked questions about S2D and space reclamation.

We hope this blog post was helpful and informative. If you have any questions or feedback, please leave a comment below. And if you liked this post, please share it with your friends and colleagues. Thanks for reading!