Thursday, October 4, 2012

Configuring storage pool by PowerShell in Windows Server 2012

Storage pools enable you to group physical disks into one or more containers known as storage pools. You can then create virtual disks from available capacity in a storage pool without the need to manage each physical disk individually. This aggregation of disks enables you to make more efficient use of disk capacity, easily add storage without impacting users, and delegate administration of storage. You can use storage pools with Storage Spaces in Windows Server 2012 or Windows 8, or with non-Microsoft storage subsystems, including subsystems that use the SMI-S standard.

File and Storage Services Overview

In Windows Server 2012, storage pools supports to be configured by GUI or PowerShell.

I will try to use PowerShell to configure a storage pool.

Lab environment
  • 1 Windows Server 2012 with 4 hard disks
Creating a new storage pool
1. On a server, log in as Administrator.
2. Launch "PowerShell".
3. Perform "Get-PhysicalDisk" to verify the hard disks.

The PhysicalDisk1 - 3 can be added to a storage pool because "CanPool" is true.

4. Perform "Get-StorageSubSystem".

I need to know the "FriendlyName" of "StorageSubSystem" to create a storage pool.

5. Perform "$PhysicalDisks = (Get-PhysicalDisk -FriendlyName PhysicalDisk1)".

The line uses the "Get-PhysicalDisk" cmdlet to get a PhysicalDisk object than is not yet in a (concrete) storage pool, and assigns the array of objects to the $PhysicalDisks variable. We must perform this cmdlet before creating a storage pool.


6. Perform "New-StoragePool -FriendlyName DataPool_01 -StorageSubSystemFriendlyName "Storage Spaces on DC01" -PhysicalDisks $PhysicalDisks" to create a storage pool named "DataPool_01".

7. Perform "Get-StoragePool -FriendlyName DataPool_01 | Get-PhysicalDisk".

PhysicalDisk1 has been added into "DataPool_01".

Adding physical disks in a storage pool
8. Still in "PowerShell", perform "Get-PhysicalDisk".

The PhysicalDisk2 and 3 can be added to a storage pool because "CanPool" is true.

9. Perform "$PhysicalDisks = (Get-PhysicalDisk -CanPool $True)".

10. Perform "Add-PhysicalDisk -PhysicalDisks $PhysicalDisks -StoragePoolFriendlyName DataPool_01" to add the physical disks to "DataPool_01".

11. Perform "Get-StoragePool -FriendlyName DataPool_01 | Get-PhysicalDisk".

PhysicalDisk1 -3 were added into "DataPool_01".

Creating a new virtual disk in a storage pool
12. Still in "PowerShell", perform "New-VirtualDisk -StoragePoolFriendlyName DataPool_01 -FriendlyName DataDisk_01 -Size 2GB -ResiliencySettingName Parity -ProvisioningType Thin" to create a new virtual disk named "DataDisk_01" with "Parity" layout and "Thin" provisioning type.

Remark: To use "Parity" layout, at least 3 hard disks or more added to a storage pool. If there is not enough hard disk, it shows the following error.

Initialize a new virtual disk and create a new volume
13. Still in "PowerShell", perform "Get-Disk".

The operation status of the hard disk, Microsoft Storage Space Device which is the virtual disk, "DataDisk_01",, is offline. I need to initialize the disk.

14. Perform "Initialize-Disk -VirtualDisk (Get-VirtualDisk -FriendlyName DataDisk_01)" to initialize the virtual hard disk.

15. Perform "Get-Disk".

The operation status of the virtual hard disk is online. I need to create a volume (Partition) in the virtual disk.

16. Perform "New-Partition -DiskNumber 4 -UseMaximumSize -AssignDriveLetter" to create a new partition.

Remark: The "Disk Number " can be retrieved from the result of "Get-Disk".

17. Perform "Format-Volume -DriveLetter E" to format the volume.
18. Enter "Y".

Extend the virtual hard disk size
19. Perform "Resize-VirtualDisk -FriendlyName DataDisk_01 -Size 4GB".

20. Perform "Get-VirtualDisk".

The disk size of DataDisk_01 has been extended to 4GB.

Extend the volume size
21. Perform "Get-Partition -DriveLetter E".

The volume size of E drive is 1.97GB.

22. Perform "Get-PartitionSupportedSize -DriveLetter E" to check the volume supported size.

The virtual disk size was updated. However, the maximum supported size of this partition hasn't been updated. I need to update the maximum supported size of this partition before extend it.

23. Perform "Update-Disk -Number 4" to update the maximum supported size of the partition.

24. Perform "Get-PartitionSupportedSize -DriveLetter E" to check the volume supported size.

The maximum supported size of the partition has been updated.

25. Perform "Resize-Partition -DriveLetter E -Size 4261330432" to update the partition size to maximum.

26. Perform "Get-Partition -DriveLetter E" to verify the result.

Remove the volume in the virtual disk
27. Perform "Remove-Partition -DriveLetter E" to remove the volume.
28. Enter "Y".

29. Perform "Get-Partition -DiskNumber 4" to verify the partition in the virtual disk.

The volume, E, has been removed.

Remove the virtual disk in the storage pool
30. Perform "Get-VirtualDisk" to verify the virtual disk.

31. Perform "Remove-VirtualDisk -FriendlyName DataDisk_01" to remove the virtual disk.
32. Enter "Y".

33. Perform "Get-VirtualDisk" to verify the virtual disk.

The virtual disk has been removed.

Remark: You can remove the virtual disk without removing the volume.

Remove the storage pool
34. Perform "Get-StoragePool" to verify the storage pool.

35. Perform "Remove-StoragePool -FriendlyName DataPool_01" to remove the storage pool.
36. Enter "Y".

37. Perform "Get-StoragePool" to verify the storage pool.

The storage pool has been removed.

Remark: You have to remove the virtual disk before removing the storage pool.

For more information:
Storage Cmdlets in Windows PowerShell

Storage Spaces Overview

Storage Management Overview

This posting is provided “AS IS” with no warranties, and confers no rights!