Perform better Storage Spaces Direct maintenance with these Powershell functions

Storage Spaces Direct (S2D) is an incredibly powerful technology, and makes up a huge part of the new AzureStack HCI Solution, however performing maintenance on it can catch out new players.

One of the biggest causes of failures while performing maintenance on S2D hosts and clusters, is that the hosts haven’t been correctly put into maintenance mode, so I set out to simplify the process with 3 new functions.

The 3 activities I’ve targeted with these functions are enabling and disabling maintenance mode on a host correctly, and checking the current state of a host or cluster.

With all maintenance, it’s a good idea to make sure the cluster is healthy before starting, and that the host you’re going to make changes to is actually in maintenance mode.
To assist with this, I’ve create Get-S2DNodeMaintenanceState. It can be used to query one or more hosts, as well as one or more clusters at a time.

Querying the state of all hosts in a cluster

Next I have created a function to put a host into maintenance mode, which by default will follow best practice and pause the cluster node, and then put the host’s disks into storage maintenance mode.
This function is called Enable-S2DNodeMaintenance and is designed to be run against a single host at a time.

The final action when performing maintenance is to bring a host out of maintenance mode, so we have Disable-S2DNodeMaintenance for that.
Like Enable-S2DNodeMaintenance, Disable-S2DNodeMaintenance is designed to be run against a single host at a time.

All of these new functions have been uploaded to Github to make it easier for me to maintain them going forwards and can be located here.

To get these into your environment, the below script will help you download the latest version of the functions and import them.

So now that hopefully everyone has a much easier way of ensuring that their hosts are correctly in maintenance mode when they need it.

Update (2019-05-26):
Additional commands have been added to the S2D-Maintainence.ps1 script since this article was initially posted. These commands will be explained in a follow up blog series on best practices for patching S2D and AzureStack HCI Clusters.

Original Code

5 thoughts on “Perform better Storage Spaces Direct maintenance with these Powershell functions

  1. Thank you for the scripts Ben.

    Just to confirm, when patching, one would first run Get-S2DNodeMaintenanceState -Cluster S2D-Cluster, if that’s OK, then Enable-S2DNodeMaintenance for the localhost, patch that host, reboot it, after reboot Disable-S2DNodeMaintenance and move on to the next node in the cluster?

    1. Yeah, you probably won’t be able to move into the next host straight away, as there will probably be storage jobs running, but as long as they’re done, your good to go.

      I’ll be following up with a post on using cluster aware updating to automate patching completely

  2. I’m pretty sure MS doesn’t recommend putting disks in maintenance mode anymore as a best practice? I think that was just a temporary step required after the May 8th 2018 update (KB103723) messed with timings. That has since been fixed. Do you have any reference to this recommendation/best practice form MS?

    1. The October 2018 revolves the issue specifically introduced by the may 2018 patch, however there are other issues known or unknown that can still be avoided by using storage maintenance. The reason it’s not a default recommendation from MSFT is because it will increase the time it takes to resync the volume once maintenance is complete.
      They however have no recommendations against using it, and from my experience, you have more successful maintenance windows when you use storage maintenance mode.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.