Step By Step: How To Create A Two-Way Mirrored Storage Space via PowerShell? #StorageSpaces #PowerShell

3 Min. Read

In this blog post, we will continue our step-by-step series on Microsoft Storage Spaces. If you missed the previous post on How to Replace a Faulty Disk in a Two-Way Mirrored Storage Tiered Space (a.k.a Azure Stack HCI), check it out here.

Create A Two-Way Mirrored Storage Space

In today’s post, we will walkthrough how to create a Two-way mirror Storage Space via PowerShell.

So, without further ado, let’s get started.

First, we will check the available physical disks in the system:

PS C:\>Get-PhysicalDisk

2WayMirrorStorageSpaces-01

Next, we will list the physical disks that can be pooled into our Storage Pool filtered by Friendly Name, Operation Status, Size, and Media Type.

PS C:\>Get-PhysicalDisk –CanPool $True | ft FriendlyName,OperationalStatus,Size,MediaType

2WayMirrorStorageSpaces-02

As you can see, we have 4 disks that can be pooled (2X136GB and 2X418GB).

We will store all physical disks that can be pooled into a variable, $Pooldisks

PS C:\>$Pooldisks = Get-Physicaldisk | ? {$_.canpool -eq $true}

Next, we will create a new Storage Pool using the disks in variable $Pooldisks with the name of “DCHV-StoragePool1

PS C:\>New-StoragePool -PhysicalDisks $Pooldisks –StorageSubSystemFriendlyName "Storage Spaces*" -FriendlyName "DCHV-StoragePool1"

2WayMirrorStorageSpaces-04

Here is the result in the UI:

2WayMirrorStorageSpaces-05

Now, let’s view the disks in the Storage Pool that we just created.

PS C:\>Get-StoragePool -FriendlyName "DCHV-StoragePool1" | Get-PhysicalDisk | Select FriendlyName, MediaType

2WayMirrorStorageSpaces-06

As you can see, the MediaType is shown as UnSpecified, so before we continue, we must set it properly.

Since we are using only Normal Hard Drives in this demonstration, we will set the MediaType to HDD. If you are creating a tiered Storage Space, make sure to set each type properly (HDD / SSD).

PS C:\>Get-StoragePool DCHV-StoragePool1 | Get-PhysicalDisk | Set-PhysicalDisk -MediaType HDD

2WayMirrorStorageSpaces-07

Let’s view the disks in the Storage Pool after we specified the media type to HDD:

PS C:\>Get-StoragePool -FriendlyName "DCHV-StoragePool1" | Get-PhysicalDisk | Select FriendlyName, MediaType

2WayMirrorStorageSpaces-08

Last but not least, we will create a New-VirtualDisk with ResiliencySettingName Mirror, then the NumberOfDataCopies is equal to (2=Two-way mirror Space, 3=Three-way mirror Space). In this example, we can only create Two-way mirror space since we have only 4 disks; however, for a Three-way mirror, we need 5 disks. A two-way mirror will allow you to suffer the loss of a single disk with no problems, while a three-way mirror will allow you to lose two disks.

Next, we move to choose the ProvisioningType (Fixed or Thin), we will choose Fixed instead of Thin provisioning, and then we specify Maximum disk size. It’s very important to mention that thin provisioning will not prevent storage shortages. Applications will break if storage is not added to the thinly provisioned volumes in time.

The final and confused parameters are the NumberOfColumns and the Interleave.

The more columns means more performance because multiple disks will be engaged at once in Read/Write operations, but it’s also limited in flexibility with expanding existing virtual disks, especially in tiered scenarios. So what’s the best size for columns for Two-way mirror Storage Space?

Typically the column count will be equal to the number of physical disks of the storage space (for simple spaces) or half of the number of disks (for mirror spaces). The column count can be lower than the number of physical disks but never higher.

The more is better in terms of performance, but the less is better in terms of flexibility for future expansion. There is no simple answer here, so it depends!

Here is a Two-way mirror virtual disk with a Number of Columns=1.

PS C:\>New-VirtualDisk -StoragePoolFriendlyName DCHV-StoragePool1 -FriendlyName DCHV01-vDisk1 -ResiliencySettingName Mirror -NumberOfDataCopies 2 -ProvisioningType Fixed -UseMaximumSize -NumberOfColumns 1 -Verbose

2WayMirrorStorageSpaces-17

Here is a Two-way mirror virtual disk with a Number of Columns=2.

PS C:\>New-VirtualDisk -StoragePoolFriendlyName DCHV-StoragePool1 -FriendlyName DCHV01-vDisk1 -ResiliencySettingName Mirror -NumberOfDataCopies 2 -ProvisioningType Fixed -UseMaximumSize -NumberOfColumns 2 -Verbose

2WayMirrorStorageSpaces-15

As you can see, Column#1 has more capacity space than Column#2. If you use only one column, your space will only be as fast as one individual disk.

The Interleave parameter represents the amount of data written to a single column per stripe. The default Interleave value is 262,144 bytes (256 KB).

The final step is to initialize the volume and create the new partition.

Get-VirtualDisk DCHV01-vDisk1 | Get-Disk | Set-Disk -IsReadOnly 0

Get-VirtualDisk DCHV01-vDisk1 | Get-Disk | Set-Disk -IsOffline 0

Get-VirtualDisk DCHV01-vDisk1 | Get-Disk | Initialize-Disk -PartitionStyle GPT

Get-VirtualDisk DCHV01-vDisk1 | Get-Disk | New-Partition -DriveLetter "D" -UseMaximumSize

Initialize-Volume -DriveLetter "D" -FileSystem NTFS -Confirm:$false -NewFileSystemLabel "Hyper-V"

Microsoft has a great Storage Space performance paper that goes into more detail and is worth reading.

Until then… N’joy your day!

__
Thank you for reading our blog.

Please let us know in the comments section below if you have any questions or feedback.

-Charbel Nemnom-

Previous

Step By Step: How To Replace Faulty Disk In Two-Way Mirrored Storage Tiered Space? #StorageSpaces

Live Webinar: StarWind Virtual SAN For Hyper-V Clusters and How To Achieve High Availability and Protection from External Threats For Free Hyper-V Server? #HyperV

Next

2 thoughts on “Step By Step: How To Create A Two-Way Mirrored Storage Space via PowerShell? #StorageSpaces #PowerShell”

Leave a comment...

  1. Hello Denis, thanks for the comment and feedback!
    This was an old article and wasn’t updated for so long.
    I just refreshed it; you should be able to copy the PowerShell code with (Ctrl+C) and paste.
    Hope it works for you now!

Let us know what you think, or ask a question...