SmbStorageTier.ps1: A simple way to pin files to tiers in Scale-Out File Servers

 

Storage Spaces Tiering

 

Storage Spaces has an interesting new feature introduced in Windows Server 2012 R2: you can create a single space using different types of disk (typically HDDs and SSDs) and it will automatically move hot data to the fast tier and cold data to the slow tier. You can read more about it at https://technet.microsoft.com/en-us/library/dn789160.aspx. You can also try my step-by-step instructions at https://blogs.technet.com/b/josebda/archive/2013/08/28/step-by-step-for-storage-spaces-tiering-in-windows-server-2012-r2.aspx.

 

Pinning Files to a Tier

 

While Storage Spaces will automatically track “heat” and move data to correct tier, there are situations where you already know ahead of time that a certain file will work best when placed in the fast tier (like when you have the base OS VHDX file for many differencing disks in a VDI setup) or the slow tier (like when you create a VHDX file specifically for backups). For those situations, you have the option to pin a file to a specific tier. That means Storage Spaces will place those pinned files on the tier you specified, tracking heat and moving automatically only the other files in the space.

Here are the cmdlets used to pin, unpin and report on pinned files with some sample parameters:

  • Set-FileStorageTier -CimSession <computer> -FilePath <String> -DesiredStorageTierFriendlyName <String>
  • Clear-FileStorageTier -CimSession <computer> -FilePath <String>
  • Get-FileStorageTier -CimSession <computer> -Volume <CimInstance>

 

Tiers on a Scale-Out File Server

 

The cmdlets above are fine if you are using the Storage Spaces on a standalone system, but when you are using them with a Scale-Out File Server, they are not so convenient.

First of all, when running from a remote computer, they require you to know which server owns the storage space at that time. When you have your multiple spaces running on a Scale-Out File Server, they are naturally spread across the nodes of the cluster (that’s why we call it “Scale-Out”). You can, of course, query the cluster to find out which node owns the space, but that’s an extra step.

Another issue is that the cmdlets above require you to know the local path to the file you want to pin (or the volume you want to report on). When you’re using the Scale-Out File Server, you typically refer to files using the UNC path (also called the remote file path). For instance, you might refer a VHDX file as \Server1Share2Folder3File4.VHDX, even though the local path to that file on the cluster shared volume might be C:ClusterStorageVolume1SharesShare2Folder3File4.VHDX. There are ways to query the path behind a share and calculate the local path, but that’s again an extra step.

The third item is that the cmdlet requires you to know the name of the tier to pin the file. Each tiered storage space has two tiers (typically one associated with HDDs and the other associated with SSDs) and they each are independent objects. If you have 5 tiered storage spaces, you effectively have 10 tiers (2 per space), each with their own unique ID and friendly name. If you name things consistently, you can probably create a scheme where the name of the tier uses the name of the space plus the media type (SSD or HDD), but sometimes people get creative. So you need to gather that third piece of information before you can pin the file.

The last thing to keep in mind is that the pinning (or unpinning) will only happen after the Storage Spaces Tiering Optimization task is run. So, if you want this to happen immediately, you need to run that schedule task manually. It’s a simple command, but you should always remember to do it.

 

The SmbStorageTier.ps1 PowerShell Script

 

Faced with these issues, I decided to write a little PowerShell script that makes life easier for the Hyper-V or Scale-Out File Server administrator. Using the Cluster, SMB and Storage PowerShell cmdlets, the script helps you pin/unpin files to a storage tier in a Scale-Out File Server. To pin a file, all you need to specify is the UNC path and the media type. To unpin, just specify the UNC path. You can also get a report for files pinned on a specific file share (actually, on the volume behind that share).

Here are the script parameters used to pin, unpin and report on pinned files with some sample parameters:

  • .SmbStorageTier.ps1 –PinFile <String> –MediaType <hdd/ssd>
  • .SmbStorageTier.ps1 –UnpinFile <String>
  • .SmbStorageTier.ps1 –ReportShare <String>

The file path specified is the UNC path, starting with \ and the name of the server. The same format that you use in Hyper-V when creating VMs. The media type is either HDD or SSD.

The script will basically take those parameters and calculate the information required to run the Set-FileStorageTier, Clear-FileStorageTier or Get-FileStorageTier. It will also kick off the Storage Spaces Tiering Optimization task, to make the change effective immediately. It’s not all that complicated to do using PowerShell, but it has the potential to save you some time if you pin/unpin files on a regular basis.

This script has been tested with both Windows Server 2012 R2 and the Windows Server Technical Preview.

 

Sample Output

 

To help you understand how this works, here are some examples of the script in action.

Note that it actually shows the input parameters, the calculated parameters required by the native Storage cmdlets and the command line it actually executes.

 

PS C:> .SmbStorageTier.ps1 -PinFile \josebda-fsshare2VM2VM2.vhdx -MediaType ssd

Input parameters
File to pin: \JOSEBDA-FSSHARE2VM2VM2.VHDX
Media type: SSD

Calculated parameters
Local file path: C:ClusterStorageVolume2Share2VM2VM2.VHDX
Node owning the volume: JOSEBDA-A3
Tier Name: Space2_SSDTier

Executing command:
Set-FileStorageTier -CimSession JOSEBDA-A3 -FilePath C:ClusterStorageVolume2Share2VM2VM2.VHDX –DesiredStorageTierFriendlyName Space2_SSDTier

PS C:> .SmbStorageTier.ps1 -ReportShare \josebda-fsshare2

Input parameter
Share Name: \JOSEBDA-FSSHARE2

Calculated parameters
Volume behind the share: \?Volume{37bb3bf3-80fc-4a43-bc79-37246e5d2666}
Node owning the volume: JOSEBDA-A3

Executing command:
Get-FileStorageTier –CimSession JOSEBDA-A3 –VolumePath \?Volume{37bb3bf3-80fc-4a43-bc79-37246e5d2666} | Select *

PlacementStatus : Partially on tier
State : Pending
DesiredStorageTierName : Space2_SSDTier
FilePath : C:ClusterStorageVolume2Share2VM2VM2.vhdx
FileSize : 9063890944
FileSizeOnDesiredStorageTier : 7987003392
PSComputerName : JOSEBDA-A3
CimClass : ROOT/Microsoft/Windows/Storage:MSFT_FileStorageTier
CimInstanceProperties : {DesiredStorageTierName, FilePath, FileSize, FileSizeOnDesiredStorageTier...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties

PS C:> .SmbStorageTier.ps1 -UnpinFile \josebda-fsshare2VM2VM2.vhdx

Input parameter
File to unpin: \JOSEBDA-FSSHARE2VM2VM2.VHDX

Calculated parameters
Local Path: C:ClusterStorageVolume2Share2VM2VM2.VHDX
Node owning the volume: JOSEBDA-A3

Executing command:
Clear-FileStorageTier -CimSession JOSEBDA-A3 -FilePath C:ClusterStorageVolume2Share2VM2VM2.VHDX

PS C:>

 

 

Well, now I guess all you need is the link to download the script in the TechNet Script Center. Here it is: https://gallery.technet.microsoft.com/scriptcenter/SmbStorageTierps1-A-simple-934c0f22

Let me know what you think. Add your comments to the blog or use the Q&A section in the TechNet Script Center link above.