New Storage Spaces in Windows Server 2012 R2 Video

In the video below I whiteboard the new features of Windows Server 2012 R2 Storage Spaces and then perform a full demo using PowerShell in my lab.

Below is all the code I use.

#Create a storage Space            

#List all disks that can be pooled and output in table format (format-table)            
Get-PhysicalDisk -CanPool $True | ft FriendlyName,OperationalStatus,Size,MediaType            

#Store all physical disks that can be pooled into a variable, $pd            
$pd = (Get-PhysicalDisk -CanPool $True | Where MediaType -NE UnSpecified)            

#Create a new Storage Pool using the disks in variable $pd with a name of My Storage Pool            
New-StoragePool -PhysicalDisks $pd –StorageSubSystemFriendlyName “Storage Spaces*” -FriendlyName “My Storage Pool”            
#View the disks in the Storage Pool just created            
Get-StoragePool -FriendlyName "My Storage Pool" | Get-PhysicalDisk | Select FriendlyName, MediaType            

#Create two tiers in the Storage Pool created. One for SSD disks and one for HDD disks            
$ssd_Tier = New-StorageTier -StoragePoolFriendlyName "My Storage Pool" -FriendlyName SSD_Tier -MediaType SSD            
$hdd_Tier = New-StorageTier -StoragePoolFriendlyName "My Storage Pool" -FriendlyName HDD_Tier -MediaType HDD            

#New-VirtualDisk –SNtoragePoolFriendlyName “My Storage Pool” –ResiliencySettingName Simple –Size 10TB –Provisioningtype Thin –FriendlyName “Documents”             
#Create a new virtual disk in the pool with a name of TieredSpace using the SSD (50GB) and HDD (300GB) tiers            
$vd1 = New-VirtualDisk -StoragePoolFriendlyName "My Storage Pool" -FriendlyName TieredSpace -StorageTiers @($ssd_tier, $hdd_tier) -StorageTierSizes @(50GB, 300GB) -ResiliencySettingName Mirror -WriteCacheSize 1GB   #cannot also specify -size if using tiers and also cannot use provisioning type, e.g. Thin            

#Online, initialize and create volume            
Get-Disk | Where-Object BusType -Eq Spaces | Where-Object PartitionStyle –Eq "RAW"| Initialize-Disk -PartitionStyle GPT            
Get-Disk | Where-Object IsOffline –Eq $True | Set-Disk –IsOffline $False            
Get-Disk | Where-Object BusType -Eq Spaces | New-Partition -UseMaximumSize -DriveLetter M | Format-Volume -FileSystem NTFS -NewFileSystemLabel "Mirror" -Confirm:$False            
New-Item M:Important -ItemType directory            
Copy-Item C:TestTest.jpg M:Important            

#Pin an item to SSD tier            
Set-FileStorageTier –FilePath M:Importanttest.jpg -DesiredStorageTier ($vd1 | Get-StorageTier –MediaType SSD)            
#Force an optimization to move the data to SSD tier just pinned            
Optimize-Volume –DriveLetter M –TierOptimize #forces the move of pinned files now. Normally this happens in the background on schedule 1am by default            

#View the automated optimization task            
Get-ScheduledTask | Where-Object TaskPath -EQ "MicrosoftWindowsStorage Tiers Management" | fl            

#To force a media type on disks (useful in virtual environments) but not normally needed. Here for Info ONLY            
Get-PhysicalDisk | Where Size -EQ 267630149632 | Set-PhysicalDisk -MediaType SSD            
Get-PhysicalDisk | Where Size -EQ 536065605632 | Set-PhysicalDisk -MediaType HDD            
Get-PhysicalDisk | Where MediaType -EQ UnSpecified | Set-PhysicalDisk -MediaType HDD            

#Remove all the virtual disks and Storage Space Created above. Only use this if want to delete in preparation for demoing again            
Remove-Partition -DriveLetter M -Confirm:$False            
Get-Disk | Where-Object BusType -Eq Spaces | Clear-Disk -RemoveData -Confirm:$False            
Remove-VirtualDisk -FriendlyName TieredSpace -Confirm:$False            
Remove-StorageTier -FriendlyName SSD_Tier -Confirm:$False            
Remove-StorageTier -FriendlyName HDD_Tier -Confirm:$False            
Remove-StoragePool -FriendlyName "My Storage Pool" -Confirm:$False

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: