电源外壳。使用正确的磁盘创建 2 个存储空间池

标签 powershell

我正在尝试创建一个脚本,该脚本将创建 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   

我怎样才能让它工作? enter image description here

enter image description here enter image description here

最佳答案

您可以按 deviceId 对它们进行排序以获得正确的磁盘吗?

$disks = Get-PhysicalDisk -CanPool $true | Sort-Object deviceid | select -first ((Get-PhysicalDisk -CanPool $true).count/2)

或者以其他方式使用 deviceId 明确指定磁盘 0-3 和 4-7

关于电源外壳。使用正确的磁盘创建 2 个存储空间池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42725867/

相关文章:

azure - 使用 Set-AzStorageBlobContent 上传的文件 <no name>

powershell - 在 powershell 脚本中捕获批处理文件的输出

windows - 为当前 chef-client 运行设置环境变量

json - JSON格式,来自文件或变量

powershell - Powershell仅删除一行的第一个单词

powershell - 非终止错误处理-if $ Error.count和$ ErrorActionPreference = 'stop'之间的区别

powershell - 将名称匹配的文件夹复制到匹配目录的其他子文件夹

git - 如何在右键单击时打开 Github for Windows 的 Git Shell?

c# - 是否可以以编程方式创建哈希规则?

Powershell Copy-Item - 仅当文件存在于目标中时才排除