我尝试创建一个脚本,创建2个存储空间池,每个池有4个磁盘。但是,由于缓存要求,我需要将具有LUN0-3的磁盘用于pool1,将磁盘用LUN4-7用于pool2。我使用以下脚本创建了2个池,但每次运行它都会创建来自不同磁盘的池(参见屏幕截图):
$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
答案 0 :(得分:4)
您可以通过deviceId对它们进行排序以获取正确的磁盘吗?
$disks = Get-PhysicalDisk -CanPool $true | Sort-Object deviceid | select -first ((Get-PhysicalDisk -CanPool $true).count/2)
或以其他方式使用deviceId显式指定磁盘0-3和4-7
答案 1 :(得分:3)
master
尝试这样排序
答案 2 :(得分:0)
有点晚了,但是:我使用驱动器序列号或唯一ID来确保获得正确的驱动器。
这是使用序列号的真实示例。这是从我的日志创建一个奇偶校验空间开始,我总是记录我如何创建存储空间。我在这里省略了不用于存储空间的驱动器:
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
我本可以使用唯一ID:
New-StoragePool -FriendlyName Pool-F -StorageSubSystemFriendlyName "Windows Storage*" -LogicalSectorSizeDefault 4096 -PhysicalDisks (Get-PhysicalDisk | ?{"5000C5002DFAB4EE;50014E6EADFAE1EF;50014E6E58A5BD05".Contains($_.uniqueid)})
在您的情况下,您也可以使用PhysicalLocation或ObjectID作为选择器...这里列出了当前位置以及实际位置:
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