Reputation: 923
I'm trying to create a script that will Create 2 Storage Spaces Pools with 4 disks each. However, due to caching requirements I need to use disks with LUN0-3 for pool1 and disks with LUN4-7 for pool2. I use the following script to create 2 pools, but each time I run it it creates pools from different disks (see screenshots):
$disks = Get-PhysicalDisk -CanPool $true | select -first ((Get-PhysicalDisk -CanPool $true).count/2)
New-StoragePool -FriendlyName "DataPool" -StorageSubsystemFriendlyName "Windows Storage*" -PhysicalDisks $disks | New-VirtualDisk -FriendlyName "DataDisk" -UseMaximumSize -NumberOfColumns $disks.Count -ResiliencySettingName "Simple" -ProvisioningType Fixed | Initialize-Disk -Confirm:$False -PassThru | New-Partition -DriveLetter S –UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SQLDATA" -AllocationUnitSize 65536 -Confirm:$false
$disks2 = Get-PhysicalDisk -CanPool $true
New-StoragePool -FriendlyName "LogsPool" -StorageSubsystemFriendlyName "Windows Storage*" -PhysicalDisks $disks2 | New-VirtualDisk -FriendlyName "LogsDisk" -UseMaximumSize -NumberOfColumns $disks.Count -ResiliencySettingName "Simple" -ProvisioningType Fixed | Initialize-Disk -Confirm:$False -PassThru | New-Partition -DriveLetter L –UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SQLLOGS" -AllocationUnitSize 65536 -Confirm:$false
Upvotes: 3
Views: 1598
Reputation: 332
A bit late but: I either use the drive serialnumber OR unique ID to make sure I get the right drives.
Here an real world example for using the serialnumber. This is from my log creating a parity space, I always log how I create the storage space. I am omitting the drives I am not using for storage space here:
Get-PhysicalDisk | ft friendlyname,canpool,cannotpoolreason,size,uniqueid,SerialNumber,Usage
friendlyname canpool CannotPoolReason size uniqueid SerialNumber Usage
------------ ------- ---------------- ---- -------- ------------ -----
ST33000651AS True 3000592982016 5000C5002DFAB4EE 9XK0EC9S Auto-Select
WDC WD30EFRX-68AX9N0 True 3000592982016 50014E6EADFAE1EF WD-WMC1T3418930 Auto-Select
WDC WD30EFRX-68AX9N0 True 3000592982016 50014E6E58A5BD05 WD-WMC1T3536082 Auto-Select
New-StoragePool -FriendlyName Pool-F -StorageSubSystemFriendlyName "Windows Storage*" -LogicalSectorSizeDefault 4096 -PhysicalDisks (Get-PhysicalDisk | ?{"9XK0EC9S;WD-WMC1T3418930;WD-WMC1T3536082".Contains($_.SerialNumber)})
FriendlyName OperationalStatus HealthStatus IsPrimordial IsReadOnly Size AllocatedSize
------------ ----------------- ------------ ------------ ---------- ---- -------------
Pool-F OK Healthy False False 8.19 TB 768 MB
I could have used Unique ID:
New-StoragePool -FriendlyName Pool-F -StorageSubSystemFriendlyName "Windows Storage*" -LogicalSectorSizeDefault 4096 -PhysicalDisks (Get-PhysicalDisk | ?{"5000C5002DFAB4EE;50014E6EADFAE1EF;50014E6E58A5BD05".Contains($_.uniqueid)})
In your case you can use PhysicalLocation or ObjectID as selector as well... Here the list how it looks right now with physical location:
Get-PhysicalDisk | ft friendlyname,canpool,cannotpoolreason,size,uniqueid,SerialNumber,PhysicalLocation,Usage
friendlyname canpool CannotPoolReason size uniqueid SerialNumber PhysicalLocation Usage
------------ ------- ---------------- ---- -------- ------------ ---------------- -----
WDC WD30EFRX-68AX9N0 False In a Pool 3000592982016 50014E6EADFAE1EF WD-WMC1T3418930 PCI Slot 1 : Bus 4 : Device 0 : Function 0 : Adapter 1 : Port 1 Auto-Select
WDC WD30EFRX-68AX9N0 False In a Pool 3000592982016 50014E6E58A5BD05 WD-WMC1T3536082 Integrated : Bus 1 : Device 0 : Function 1 : Adapter 0 : Port 3 Auto-Select
ST33000651AS False In a Pool 3000592982016 5000C5002DFAB4EE 9XK0EC9S Integrated : Bus 1 : Device 0 : Function 1 : Adapter 0 : Port 4 Auto-Select
Upvotes: 1
Reputation: 111
Can you sort them by deviceId to get the correct disks?
$disks = Get-PhysicalDisk -CanPool $true | Sort-Object deviceid | select -first ((Get-PhysicalDisk -CanPool $true).count/2)
Or in some other way make use of the deviceId to explicitly specify disks 0-3 and 4-7
Upvotes: 4
Reputation: 72191
$disks = (get-physicaldisk -canpool $true).PhysicalLocation | sort
Try this to sort those
Upvotes: 3