Andre's Blog
Perfection is when there is nothing left to take away
How to Configure Storage Spaces in Windows 10

This is a technical part of an earlier post about setting up Storage Spaces on Windows 10.

There are dozens of RAID products on the market that allow users to combine multiple hard drives in various combinations and many tech-minded people choose these RAID configurations, thinking that hardware RAID is the best solution money can buy.

The reality is, however, that when these consumer-level RAID enclosures fail, their owners end up either losing their data or spending time and money on data recovery. The manufacturer usually just advises users to backup data when setting up a RAID configuration, which is not helpful for terabytes worth of data.

A software-based drive pool is not as fast and is not a plug-an-play solution as a typical hardware RAID configuration, but it is more resilient against enclosure failures because a failed enclosure just houses separate drives and in most cases can be replaced with another one, even from a different manufacturer, and the software drive pool will continue working as if nothing happened.

On Windows drive pools are implemented with Storage Spaces, on Linux with a Logical Volume Manager (LVM) or and on Mac with mirrored disk sets. This post focuses on Storage Spaces.

Disclaimer

Run all commands described in this blog at your own risk. This post is made in good faith that it may help some people, but I am not responsible for any data loss or hardware damage that may result from applying any commands or techniques described in this blog.

Storage Spaces

Storage Spaces in Windows 10 are are implemented as virtual disks that draw storage from a storage pool containing drives of different capacity. Each virtual drive may be configured to combine storage from all pooled drives or it may be configured to keep multiple copies of data that can survive physical hard drive failures, to a limit.

Storage Spaces may be configured to keep two or three copies of data and are called two-way and three-way mirrors in Windows configuration. The description sounds a lot like RAID1 (mirror), but Storage Spaces are more sophisticated than typical RAID implementations.

For example, there is no striped Storage Space options because any Storage Space with multiple drives can be configured to stripe data across multiple drives via so-called columns, which are parts of a single chunk of data written to a single disk, so 4 columns is similar to RAID0 (striped) with 4 drives, but one can have a Storage Space with 8 drives and 4 columns, if you want to distribute striping to particular disks, which is not something that can be done with common RAID0 implementations.

Similarly, a two-way mirror in Storage Spaces is more flexible than a common RAID1 (mirror) implementation in that one can have a two-way mirror Storage Space with 3, 5, etc, hard drives of any sizes and 2 copies of data will be evenly distributed between those drives, while RAID1 typically requires even number of drives of similar sizes.

One can add more drives of any size to a storage pool any time and expand a Storage Space without having to copy existing data. Storage Spaces will take care of moving data around between all drives.

Storage Space Resiliency

A Storage Space may be formatted as an NTFS or a ReFS volume in general, but latest updates of Windows Home and Windows Pro remove the ReFS option from the format list for some not obvious reason. Both versions of Windows will still work with ReFS volumes and will take advantage of its features, but you cannot create one on these Windows editions. This is very unfortunate because ReFS offers a truly resilient storage option when combined with Storage Spaces.

Without ReFS Storage Spaces offers limited automated recovery and no protection against bit rot - physical storage deterioration over time. When Storage Spaces encounters a write failure, it will mark a disk as failed and will start using a hot spare drive, if one is configured. On read failures, it will read data from a mirror copy and will attempt to write data back to the bad drive and if that fails, will follow the write failure steps. So, the only protection against a disk failure with NTFS Storage Spaces is to have a hot spare disk in the enclosure.

ReFS is where Storage Spaces really shines. When ReFS detects bad data, it goes to the drive pool and asks for another chunk of storage and copies data that corresponds to a damaged chunk from a healthy drive to another storage location. It also periodically scans disks for bit rot if data integrity flag is set on a Storage Spaces virtual drive. It does slow down the OS when this scan is happening, but the benefits outweigh the temporary loss of performance.

Hard Drive Enclosure

The best enclosure you can find for a Storage Space configuration is the one that has no RAID configuration whatsoever, but there is not a lot of choice out there of multi-bay enclosures that just expose individual drives because manufacturers are pushing more expensive and easier to support RAID enclosures.

The best one I found for my use are Mediasonic HF2-SU3S2 with USB 3.0/eSATA and HF2-SU31C with USB C. They hold up to four 3.5" hard drives, have non-obnoxious lights, a reasonably quiet fan that automatically adjusts speed and an external power supply. On the cons side, this enclosure turns off hard drives after one minute of inactivity, regardless of Windows power settings, and when drives spin up, it creates an unpleasant delay and on top of that Windows considers those delays unexpected and reports driver controller errors in the system event log.

In general, any RAID enclosure that has a non-RAID configuration option will also do, but you will pay extra 10-20% for the RAID option you will never use. From the speed and feature set perspective, it's good to buy a recent one, but given that this enclosure will work for you for a few years, whatever features you buy will be obsolete in a year. USB 3.0 and eSATA provide 5-6 Gbps, which is a good base line for most storage configurations for image files, even large ones. For 4K video you may want to look for USB 3.1 Gen II or Thunderbolt options.

One thing to add about USB enclosures is that some of them are configured with automatic power-off when there is no disk activity for a few minutes. You have to be careful with this option because some of them actually turn off the enclosure completely rather than just put it to sleep. Mediasonic HF2-SU3S2 is a good example of this and in default configuration when connected via a USB cable will turn itself off, which will most certainly cause data loss for cached disk data. Fortunately there is a power sync feature in HF2-SU3S2, which can configure the enclosure to go to sleep instead of turning it off or just keep it running until it is turned off manually, but do make sure you test this behavior before you put any data into this enclosure or you may lose the data.

Four-bay 3.5" enclosures will work best for home storage. If you want to carry one with you on a trip, a two-bay 2.5" enclosure would work quite well, but it is harder and harder to find those due to decreasing demand on 2.5" drives, I suppose. With a portable enclosure, you would move images from your camera onto the enclosure and your images will be stored in two copies right from the start. Do keep in mind, however, that many of these small 2-bay enclosures consume more power and many laptops will not be able to sustain their power demands, so you will need one that can be powered externally or carry an externally-powered USB hub.

If you decide to go with an eSATA enclosure, you will also need a port multiplier card in your desktop computer or a USB-to-eSATA adapter.

Hard Drives

There is not much to say here, as any hard drive will work with Storage Spaces. I personally prefer NAS hard drives, like Western Digital Red drives, but you can use any drive, really. I would just stay away from those that turn off by themselves to save power, without Windows telling it to, like Western Digital Green drives do. Those drives seem to freeze for a dozen seconds before becoming operational again. Having said that, do keep in mind that Storage Spaces will work as fast as the slowest drive in the drive pool, so having drives with similar characteristics will provide better performance.

If you plan on reusing some existing hard drives, there is a good chance that you may need to use PowerShell to make them usable.

Basic Storage Spaces Configuration

If you don't want to spend much time configuring storage spaces, your best option is to buy new hard drives. Storage Spaces will most likely recognize those right away and you won't need to do any troubleshooting.

Put all hard drives you plan to use into the enclosure and connect it to the computer. Unformatted drives will not appear in Explorer, which is expected. Click Start and type Storage Spaces. Click Manage Storage Spaces.

In the Storage Spaces configuration click Create a new pool and storage space link. Windows will immediately show you new unformatted drives in a pop-up. Select the hard drives from the new enclosure and click the Create pool button.

Immediately after creating a drive pool, Windows will proceed to creating a Storage Space. Select Two-way mirror option, choose a drive letter and replace the default Storage space name with something meaningful, like Pictures. For Windows Home and Pro editions NTFS will be the only option, so you can leave it at that.

You can select any size for this Storage Space, even a greater size than is available in the current drive pool. Once you use up about 70% of the storage available in the drive pool, Windows will shut down all storage spaces in this pool and will ask you to add more drives. You can still activate the pool as a read-only drive to access your data, but you cannot delete content to free up some space, so your only option is to add drives. I find it more convenient to set the storage space size to the exact value available in the storage pool or a smaller value. This way Windows will warn you to add drives when you reach about 70%, but you will be able to continue using the virtual drive.

Another thing to keep in mind is that you can only increase the size of a storage space and if you set it to a greater size then the enclosure can hold, you will most likely end up in a situation where you will need to add some temporary drives just to remove some content from the affected storage space.

When you set all configuration values, click Create storage space to create the storage space.

The default drive pool name is just Storage pool and you should change it to something more descriptive. Using the enclosure name usually works quite well, unless you have multiple identical enclosures. Click Rename pool link for that drive pool and change the drive pool name.

It is also a good idea to rename physical disks to reflect their slot in the enclosure. It comes in handy when you need to do any hard drive maintenance later on. You can do this by expanding the physical drives section in the Storage Spaces configuration and clicking Rename against each drive.

Ejecting a Storage Space Drive

If you configure a Storage Space on a desktop computer and don't need to physically disconnect the enclosure, you don't have to worry about this part and can skip this section. If, however, the enclosure is connected to a laptop either directly or via a docking station, you will face a very serious design deficiency with Storage Spaces - virtual drives cannot be unmounted and just disconnecting the laptop from the docking station will cost you some of your data that wasn't completely flushed from the file cache.

There is no official solution from Microsoft as of the moment of this writing, so if you don't want to use the custom solution described below, which is certainly a use-at-own-risk solution, your only option is to shut down your laptop when you want to disconnect a Storage Space. It's also worth noting that the Quick Removal disk policy is not available for Storage Space drives. This is a huge inconvenience, but this is what you would need to commit to if you want your data to be safe.

The solution I found for myself is to flush the Storage Spaces volume cache and then disconnect its virtual disk via PowerShell commands. This is not an officially-supported way of disconnecting a Storage Space and if you choose to use it, please realize that you are doing it at your own risk.

In order to test this approach, I wrote a small application that writes a 2 GB file of random data to a Storage Space disk and to a system disk, ran the app, then ran the disconnect commands described below and then physically disconnected the enclosure. After reconnecting the enclosure and attaching the Storage Space, I binary-comparing both files to see if some data was missing from the Storage Space version of the file. Running this test a few times I didn't encounter any differences, so I started using this approach over a year ago and so far didn't lose any data.

Also, do not forget that drives have their own cache, so you would need to make sure the activity lights are not blinking before powering down portable drives.

All PowerShell commands described in this post need PowerShell running with administrative privileges. Run the first command from a PowerShell launched As Administrator and configure desktop shortcuts to run As Administrator (Properties > Shortcut > Advanced > Run as administrator).

Launch PowerShell and change the virtual disk associated with the Storage Spaces to attach and detach manually. This means that when the enclosure is attached, the disk will not appear in the list of disks automatically and you will need to click the shortcuts described in this section to attach and detach this Storage Space.

You need to run this command only once for a given Storage Space. In this example, my Storage Space is called MEDIASONIC (note that it's a Storage Space name, not the Storage Pool name). Substitute MEDIASONIC with your Storage Pool name. Notice that there are no space characters in the Storage Space name - this makes it simpler to use on the command line. Otherwise you will need to put the name in double quotes and work out escaping in desktop shortcuts.

Set-VirtualDisk -FriendlyName MEDIASONIC -IsManualAttach $true

Next, create two shortcuts on the Desktop, one to attach the Storage Space and one to detach it.

This shortcut makes the Storage Space named MEDIASONIC appear in the drive list (line breaks in the command below is for readability - replace each line break with a single space before creating a shortcut):

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command
    "Connect-VirtualDisk -FriendlyName MEDIASONIC"

This command below flushes the cache of the volume called MEDIASONIC and if the flush was successful, detaches the Storage Space virtual disk (line breaks in the command below is for readability - replace each line break with a single space before creating a shortcut):

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command 
   "Write-VolumeCache -FileSystemLabel MEDIASONIC;
   if($?) {Disconnect-VirtualDisk -friendlyname MEDIASONIC}"

You must click the detach command before physically disconnecting the laptop from the docking station or you will lose some data. As a rule of thumb, I disconnect all Storage Spaces before I put the laptop into hibernation, so I can detach it later without waking it up.

If these commands sound too hacky and you don't want to shut down the laptop every time you need to detach an enclosure, Storage Spaces are not for you.

Lastly, I don't know if hibernating a laptop flushes volume caches. The common sense says that it should, but I didn't find any confirmation in Microsoft docs that hibernating a laptop would do the same as these scripts do. If you know leave a comment.

Issues with Adding Drives to a Drive Pool

If you want to reuse older hard drives or if you want, add a hot spare or change the number of columns in your storage pool, PowerShell is the only way to do this on a non-server version of Windows.

Get-Disk vs. Get-PhysicalDisk

One time when I attached a drive, it would appear in Computer Management > Disk Management and in the Get-Disk output, but would be missing from Get-PhysicalDisk output. Storage Spaces would see the drive, but would fail adding it with the error code 0x00000002. After much investigation, I found out that this drive had the same exact Friendly Name as another drive and Windows didn't add it to the primordial Storage Pool.

If you run into this situation, do not change anything on any of the drives, like deleting volumes, etc. Windows gets confused in this case and you may delete good data by accident. Instead, disconnect one of the drive, make sure the remaining one is listed in Get-Disk and Get-PhysicalDisk outputs and then give it a new friendly name with Set-PhysicalDisk -NewFriendlyName. Disconnect the renamed drive, connect the other one and repeat the process, then connect both of them together. This fixed the problem in my case.

Repurposed Drives

A few times I wasn't able to add a drive that used to be in another drive pool. Windows failed to add such drive into a new drive pool and reported only an obscure error 0x00000032. Resetting the physical disk should help in this case.

Run the following PowerShell command to see drives that cannot be used in a drive pool.

Get-PhysicalDisk | ft DeviceId,FriendlyName,UniqueId,SerialNumber,Size,CanPool

The last column shows False if the drive cannot included in a pool. There is also property called CannotPoolReason, but in my case it was showing insufficient capacity, even the drive didn't have any data. The DeviceId column is the disk number that you can use to identify drives in Windows Computer Management configuration. Copy UniqueId value of the disk you want to include in the pool and first make sure it's the right disk (use your UniqueId):

Get-PhysicalDisk -UniqueId "{b3a83565-cf06-81a0-7436-dd7ab7d09b4a}"

Make sure only one disk is returned with this command - some enclosures assign the same UniqueId to all of their disks. Once you confirm it's the right disk, reset it with this command.

Reset-PhysicalDisk -UniqueId "{b3a83565-cf06-81a0-7436-dd7ab7d09b4a}"

In most cases I was able to add disks reset in this way to the pool. A couple of times, however, they were still refused and in those cases I had to change FriendlyName property for both disks to unique values (line breaks are only for readability).

Set-PhysicalDisk -UniqueId "{b3a83565-cf06-81a0-7436-dd7ab7d09b4a}"
   -NewFriendlyName "ULTRADISK1"

Set-PhysicalDisk -UniqueId "{339455b2-942b-e2d1-c2b9-58eb99a570ee}"
   -NewFriendlyName "ULTRADISK2"

After this I was able to add drives to the drive pool.

Some enclosures would assign the same UniqueId to all of their disks and Storage Spaces refused to work with those, but it appears now that a unique combination of FriendlyName and UniqueId works, although this is just my observation.

Removing a Failed Drive

If one of the drives in a mirror has bad blocks, you will need to replace it with a good drive. In order to do this you will need another enclosure or a hard drive dock. The latter is a good thing to have around for cases like this - you just replace the bad drive in the enclosure with a new one and stick the bad one in the dock to finalize the removal.

First, add the new drive to the drive pool. Click Add drives in the drive pool section and select the new drive. Make sure to uncheck the Storage Space optimization option, so it doesn't start moving good data between the drives to use them equally. You will do this after the bad drive is removed.

After adding a new drive, expand the Physical drives section and click Prepare for removal against the failing drive. Note that if the Storage Space is configured to attach manually, it should be attached in order for drive removal to work. Once you do this, Windows will start moving data off the bad drive to the new one.

One unpleasant thing I ran into was that the bad drive was so bad that it was attempting to read bad blocks again and again, so that it would take a month to copy the entire drive. After having it running for half a day, I shut down the computer, which suspended the recovery job, and turned off the hard drive dock with the bad drive. When the computer started back up, Storage Spaces complained about a missing disk, but copied all data from the good drive within about 3 hours. You have to be sure, though, that the remaining drive is in an excellent shape and does not have any bad sectors.

Once all data is copied to healthy drives, Storage Spaces will change the link against drive from Prepare for removal to Remove drive. Turn on the hard drive dock back on to reconnect the bad drive with the drive pool and click Remove drive to remove it.

When a new drive is being populated, there is no progress indicator and it is a bit unsettling to know how the recovery is going, since that one copy of the data is all you got. Fortunately, you can monitor progress with this PowerShell command:

Get-StorageJob

It will show you how much data is supposed to be copied and the percentage of the job that is complete, so you can plan better your day.

Once all data is moved and the Storage Space is healthy again, you can click Optimize drive usage to equally distribute data between all drives.

Adding a Hot Spare Drive

A hot spare drive will be used immediately after Windows detects that one of the drives in a drive pool failed. Without a hot spare, Windows will let you know that the pool has reduced resiliency, but NTFS file system will not attempt to relocate existing copy of the data to a new spot on the same drive, like ReFS would. When this happens, you can rush to the store and buy another drive, but until this happens, part of your data will exist only as a single copy and if anything happens to the second drive, you will lose your data.

In a 4-bay enclosure, you can have three drives work as a mirror and the forth drive can serve as a hot spare. Identify the drive that you want to add as a hot spare with Get-PhysicalDisk:

Get-PhysicalDisk | ft DeviceId,FriendlyName,UniqueId,SerialNumber,Size,CanPool

Its CanPool status should be True. Make sure UniqueId is indeed unique and copy the UniqueId value. Identify your storage pool with this command. Make a note of FriendlyName of the pool to which you want to add a disk.

Get-StoragePool

Now add the disk as a hot spare (line breaks are for readability):

Add-PhysicalDisk -StoragePoolFriendlyName "MEDIASONIC_2X"
   -PhysicalDisks 
      (Get-PhysicalDisk -UniqueId "{339455b2-942b-e2d1-c2b9-58eb99a570ee}")
   -Usage "HotSpare"

Check that the disk was added as a hot spare:

Get-PhysicalDisk | ft DeviceId,FriendlyName,UniqueId,Usage

The Usage column will say Hot Spare if everything worked out without a problem.

Note that in Windows configuration this new drive will not be any different from other drives, except that it won't contain any data unless some other drive fails.

Comments:
Name:

Comment: