Storage Spaces in an Azure VM: Part 1

My previous post was about the value of Storage Spaces, and I want I wanted to walk through the initial setup steps for creating a Storage Spaces tier in a an Azure-based Windows Server VM.

Add VHDs to VM

As a first step, we will provision the disk we want on our VM in the Azure Portal, and got to the VM you want to work with (I named my Spaces) and get it’s disks:

Azure Portal – accessing one of my VMs named “Spaces”

I’ve added a few disk there:

Created a mix of SSD and HDDs for my VM

I’m going to add more disk later – using the “+add data disk” button, but for now the disks above will work get things going.  You can add more disk to increase your virtual disk / volumes later when I need the capacity…no need to pay for it now…this is the cloud!!!!

Update Media Type Inside VM

Now that the disks are added and attached to the VM, we’ll want to hop into the VM (via RDP) and go to Server Manager.  Storage Spaces is configured (when using the GUI) in Server Manager > File and Storage Services:

Server Manager:  get to the Storage stuff

You should see the disk that you’ve added in the bottom right corner of the UI – they are part of the unconfigured “Primodial” pool:

Server Manager File and Storage Services

Setting up Storage Spaces in Azure takes a little bit of extra work than it does with physical hardware, because the disks (VHDs) aren’t physically attached to the system… they are of course virtual!  That means Windows can’t detect which disks are SSDs or hard drives… so we have to help!  The “physical disk” box on the screen has all sorts of great info in it…some of which is useless to us in Azure like “Slot”, “Status”, “Bus” – we can get rid of those so we can see the “Media Type” column.  You can do that by clicking on the headings, and selecting the information you would like to see:

Get the Columns you want, including “Media Type”

Our goal is to tag the SSDs we have as SSDs, and the hard drives as HDDs so Storage Spaces can do it’s thing.  In order to manually update the disks Media Type, we have to first create a storage pool and add the disks to it:

Create Your Pool

Walk through the UI, and create a pool…I lack any sort of creativity, so I’ll often call my pool “pool” or “spaces”… that also helps me reuse PowerShell (don’t have to change my code!) – you should select all the disks you want to update.  Once you are done, your storage pool will show up in list of pools (might be the only one, having replaced the “Primodial” pool if you used all the disk…or there could be others).

At this point, we can update the Media Type on the disks.  You can do this individually (using Set-PhysicalDisk -MediaType SSD), but you’ll have to do it disk by disk, and that’s painful!

If we assume that all our SSDs are the same size, and smaller than the HDDs (which are the same size, we can set the Media Type quickly using this Powershell (you’ll have to change the pool name from “Spaces“):

$Pool = New-StoragePool -FriendlyName Spaces -StorageSubSystemFriendlyName *Storage* -PhysicalDisks (Get-PhysicalDisk |? {$_.CanPool})
(($Pool | Get-PhysicalDisk | Group-Object {$_.Size} | Sort-Object {$_.Name})[0]).Group | Set-PhysicalDisk -MediaType SSD
(($Pool | Get-PhysicalDisk | Group-Object {$_.Size} | Sort-Object {$_.Name})[1]).Group | Set-Physi

Once that’s done, your physical disks should be “tagged” with the right media type:

Disks with Media Type Set

Creating Our Storage Tier

With the media type set, we can now create our tiered storage!  Yes, you can do it entirely via PowerShell, but I like to mix it up with the GUI a little… and we’ll need PowerShell later to make adjustments, so we will us it.

I like to create my first virtual disk with only a handful of disks, as it makes updating simpler in the future.  If you add LOTS of disk initially, then it seems you need to add LOTS of disk each time you expand…a smaller initial config has proven to allow me to expand my virtual disk / volumes incrementally…one extra disk at a time.

Go back to Server Manager, and kickoff the “New Virtual Disk” dialog by right-clicking on your pool.  This will run you through a Wizard to create your disk…there a few things to keep in mind:

First thing – you want to tier your storage – so CHECK THE BOX BELOW:

Enable tiering


Second thing – the GUI has some “oppourtunities”
You can’t actually trust the GUI to maximize your storage capacity, so the we’ll build  a smaller virtual disk, and update it with PowerShell later.

If you go too large…the GUI will fail to provision (why you should go small):

Failed!  Tried to use the Maximum usable disk in the GUI

I want to create my initial configuration using one SSD and one HDD so I went way low capacity – between 1/4 to 1/2 of the max:

Go Small for your Tiers in the GUI

Because I went small, it worked, and now I can update the size using powershell.
I first need to get the names of the storage tiers to use for resizing using get-storagetier:

get-storagetier | select friendlyname, size
Finding my tier names (not from the current setup – ignore the sizes)

Now I can use those to resize the ties with the following code – just change the tier names:

get-storagetier | select friendlyname, size
resize-storagetier disk_Microsoft_HDD_Template -size 3.9TB
resize-storagetier disk_Microsoft_SSD_Template -size .24TB

Once you’ve resized, you will have maximized your utilization:

Pool well allocated