# 查看物理磁盘
Get-PhysicalDisk | Format-Table FriendlyName,DeviceId,BusType,UniqueId,Size,MediaType -auto
# 物理磁盘改名
Set-PhysicalDisk -UniqueId "youruniqueid" -NewFriendlyName "yourname"
# 如果不能正确显示磁盘类型则设置磁盘类型
Set-PhysicalDisk -FriendlyName 'VMware Virtual SATA Hard Drive' -MediaType HDD
Set-PhysicalDisk -UniqueId "youruniqueid" -MediaType SSD
# 逻辑扇区大小
Get-PhysicalDisk | Sort-Object SlotNumber | Select-Object SlotNumber, FriendlyName, Manufacturer, Model, PhysicalSectorSize, LogicalSectorSize | Format-Table
# 添加日志盘,给奇偶校验存储加速 2块SSD (没什么用)
# Add-PhysicalDisk -StoragePoolFriendlyName "EmmaStoragePool" -PhysicalDisks (Get-PhysicalDisk -UniqueId "youruniqueid") -Usage Journal
# 新建存储池
New-StoragePool -StoragePoolFriendlyName "EmmaStoragePool" -StorageSubSystemFriendlyName (Get-StorageSubSystem).FriendlyName -PhysicalDisks (Get-PhysicalDisk -CanPool $true) -LogicalSectorSizeDefault 4KB -FaultDomainAwarenessDefault PhysicalDisk
# 使用可用磁盘空间自动重建虚拟磁盘 在执行维护操作之前 RetireMissingPhysicalDisks 属性更改为 Never
Set-StoragePool -FriendlyName "EmmaStoragePool" -RetireMissingPhysicalDisks Always
# 并行重建
Set-StoragePool -FriendlyName "EmmaStoragePool" -RepairPolicy Parallel
# 设置存储池 设置Mirror为一个列(磁盘)写入 Parity(奇偶校验)为五列写入 SSD与HDD设置Resiliency需要一样
Get-Storagepool "EmmaStoragePool" | Set-ResiliencySetting -Name Parity -NumberOfColumnsDefault 1
Get-Storagepool "EmmaStoragePool" | Set-ResiliencySetting -Name Parity -NumberOfColumnsDefault 5
# 查看新建的存储池
$pool = get-storagepool -FriendlyName "EmmaStoragePool"
Get-Physicaldisk -StoragePool $pool
# 新建存储层
# 一块SSD时使用以下命令 ResiliencySettingName是弹性设置名称 Simple是raid0 Mirror是raid1 Parity是raid5
New-StorageTier -StoragePoolFriendlyName "EmmaStoragePool" -FriendlyName SSDTier -MediaType SSD -ResiliencySettingName Simple
# 多块SSD时使用以下命令 NumberOfColumns是数据同时写入磁盘数量,PhysicalDiskRedundancy是最大允许磁盘损坏数量
New-StorageTier -StoragePoolFriendlyName "EmmaStoragePool" -FriendlyName SSDTier -MediaType SSD -ResiliencySettingName Parity -NumberOfColumns 3 -PhysicalDiskRedundancy 1 -FaultDomainAwareness PhysicalDisk
# HDD层
New-StorageTier -StoragePoolFriendlyName "EmmaStoragePool" -FriendlyName HDDTier -MediaType HDD -ResiliencySettingName Parity -NumberOfColumns 3 -PhysicalDiskRedundancy 1 -FaultDomainAwareness PhysicalDisk
# 查看新建的存储层
Get-StorageTier | Format-Table FriendlyName, ResiliencySettingName, PhysicalDiskRedundancy, FaultDomainAwareness, NumberOfDataCopies
# 移除存储层
# Remove-StorageTier -FriendlyName "SSDTier" -Confirm:$false
# Remove-StorageTier -FriendlyName "HDDTier" -Confirm:$false
# 新建虚拟磁盘
# 磁盘大小后期可调节 工作负载的最常见 I/O 大小是 64 KB。对于此虚拟磁盘,Interleave 属性设置为 65536(64 KiB 转换为字节数) 4096? (没什么用,Interleave设置了属性里显示为0)
# New-VirtualDisk -StoragePoolFriendlyName "EmmaStoragePool" -FriendlyName "Disk-1" -StorageTiers (Get-StorageTier -FriendlyName "SSDTier"), (Get-StorageTier -FriendlyName "HDDTier") -StorageTierSizes 10GB, 16GB -Interleave 65536 -ResiliencySettingName Parity -NumberOfColumns 3 -PhysicalDiskRedundancy 1
# Get-VirtualDisk -FriendlyName 'Disk-1'| Initialize-Disk -PartitionStyle GPT -PassThru
# New-Partition -DiskNumber 15 -DriveLetter 'D' -UseMaximumSize
# Format-Volume -DriveLetter 'D' -FileSystem NTFS -AllocationUnitSize 65536 -Confirm:$false -Force
# 移除VirtualDisk
# Remove-VirtualDisk -FriendlyName "Disk-1" -Confirm:$false
# 一步到位,直接建立卷 WriteCacheSize 1GB为默认设置,一般情况,无需更改。NumberOfColumns为每层同时写入磁盘数 PhysicalDiskRedundancy为可容忍最大磁盘故障数
New-Volume -StoragePoolFriendlyName "EmmaStoragePool" -FriendlyName "Disk-1" -AccessPath "D:" -ProvisioningType "Fixed" -StorageTiers (Get-StorageTier -FriendlyName "SSDTier"), (Get-StorageTier -FriendlyName "HDDTier") -StorageTierSizes 5GB, 50GB -FileSystem Refs -WriteCacheSize 1GB -ResiliencySettingName Parity -NumberOfColumns 3 -PhysicalDiskRedundancy 1
# 移除VirtualDisk
# Remove-VirtualDisk -FriendlyName "Disk-1" -Confirm:$false
# 调整存储层大小
(Get-StorageTierSupportedSize -FriendlyName SSDTier -ResiliencySettingName Parity).TierSizeMax/1GB
(Get-StorageTierSupportedSize -FriendlyName HDDTier -ResiliencySettingName Parity).TierSizeMax/1GB
Get-StorageTier
Resize-StorageTier -InputObject (Get-StorageTier -FriendlyName "Disk-1-SSDTier") -Size 664GB
Resize-StorageTier -InputObject (Get-StorageTier -FriendlyName "Disk-1-HDDTier") -Size 8159GB
# 主机每天自动优化存储层一次,此命令为手动优化 分析热数据到SSD层
defrag.exe /C /H /K /G
# 运行以下 Powershell 命令以将文件固定至 SSD 层。
Set-FileStorageTier -FilePath "D:/1/1.txt" -DesiredStorageTierFriendlyName "Disk-1-SSDTier"
#运行以下 Powershell 命令以从 SSD 层取消文件固定。
Set-FileStorageTier -FilePath "D:/1/1.txt"
#运行以下 Powershell 命令以查看当前固定的所有文件。
Get-FileStorageTier -VolumePath "D:/1/1.txt"
# 在任务管理器中显示逻辑磁盘
diskperf -Y
# 向池中添加或删除磁盘
Get-PhysicalDisk | Format-Table FriendlyName,DeviceId,BusType,UniqueId,Size,MediaType -auto
Remove-PhysicalDisk -StoragePool $pool -PhysicalDisks (Get-PhysicalDisk -DeviceNumber 2) -Confirm:$false
Add-PhysicalDisk -StoragePool $pool -PhysicalDisks (Get-PhysicalDisk -DeviceNumber 2)
# 添加硬盘后 优化池
$pool | Optimize-StoragePool
# choose another: Windowsserver 2022 https://learn.microsoft.com/zh-cn/windows-server/storage/storage-spaces/storage-spaces-storage-bus-cache
Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
Get-StorageBusCache
Import-Module StorageBusCache
Enable-StorageBusCache
# https://www.bilibili.com/read/cv4017897?spm_id_from=333.999.0.0
Windows 存储池
于 2022-11-13 19:05:46 首次发布