# 实验环境 3块SSD 奇偶校验 | 3块HDD 奇偶校验 | 1块HDD热备 (如做归档使用,建议不做SSD存储层,直接用HDD,本文以有SSD存储层为例)
# 安装重复数据删除
Install-WindowsFeature -Name FS-Data-Deduplication
# 查看物理磁盘
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
# 如果磁盘数量允许,多一个磁盘设置为热备
Set-PhysicalDisk -UniqueId "youruniqueid" -Usage HotSpare
# 使用可用磁盘空间自动重建虚拟磁盘 在执行维护操作之前 RetireMissingPhysicalDisks 属性更改为 Never
Set-StoragePool -FriendlyName "EmmaStoragePool" -RetireMissingPhysicalDisks Always
# 并行重建
Set-StoragePool -FriendlyName "EmmaStoragePool" -RepairPolicy Parallel
# 设置存储池 设置Mirror为一个列(磁盘)写入 Parity(奇偶校验)为五列(HDD数量,单奇偶至少3块,双奇偶最少7块)写入 SSD与HDD设置Resiliency需要一样 此处设置不合理 会导致创建虚拟磁盘不成功
Get-Storagepool "EmmaStoragePool" | Set-ResiliencySetting -Name Parity -NumberOfColumnsDefault 3 -PhysicalDiskRedundancy 1
# 查看新建的存储池
$pool = get-storagepool -FriendlyName "EmmaStoragePool"
Get-Physicaldisk -StoragePool $pool
# 新建存储层
# 一块SSD时使用以下命令 ResiliencySettingName是弹性设置名称 Simple是raid0 Mirror是raid1 Parity是raid5 PhysicalDiskRedundancy 2 为双奇偶校验,7块盘中允许有2块磁盘同时损坏
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
# 一步到位,直接建立卷 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
# 启用重复数据删除
Enable-DedupVolume -Volume D: -UsageType Default
# 移除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
# 标记损坏的磁盘
Set-PhysicalDisk -UniqueId "youruniqueid" -Usage Retired
# 先加入一块新盘 或 将热备盘设置为Auto
Add-PhysicalDisk -StoragePool $pool -PhysicalDisks (Get-PhysicalDisk -DeviceNumber 2)
# 当有故障时,存储池会自动把HotSpare设置为Auto ?
Set-PhysicalDisk -UniqueId "youruniqueid" -Usage Auto
# 重建磁盘,取消对将要移除的物理磁盘的依赖
Repair-VirtualDisk -FriendlyName "Disk-1"
Remove-PhysicalDisk -StoragePool $pool -PhysicalDisks (Get-PhysicalDisk -DeviceNumber 2) -Confirm:$false
# 添加硬盘后 优化池
$pool | Optimize-StoragePool -AsJob
# 查看后台任务
Get-StorageJob
# 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
# 预配模式 共享(默认):缓存将只占用较快媒体层的一部分。 确切的百分比可通过“共享缓存百分比”字段配置
Set-StorageBusCache -ProvisionMode Shared
# 共享缓存百分比 使用镜像加速奇偶校验卷时,不应使用超过 50% 的值,因为缓存与镜像层之间需要平衡。
Set-StorageBusCache -SharedCachePercent 50
Import-Module StorageBusCache
Enable-StorageBusCache
New-Volume –FriendlyName "TestVolume" -FileSystem ReFS -StoragePoolFriendlyName Storage* -StorageTierFriendlyNames MirrorOnSSD, ParityOnHDD -StorageTierSizes 200GB, 800GB
# 升级存储池版本
Update-StoragePool -FriendlyName "EmmaStoragePool"
# https://www.bilibili.com/read/cv4017897?spm_id_from=333.999.0.0
#查看池子的状态
Get-StoragePool -IsPrimordial $False | Select-Object HealthStatus, OperationalStatus, ReadOnlyReason
Get-VirtualDisk | Select-Object FriendlyName,HealthStatus, OperationalStatus, DetachedReason
# https://learn.microsoft.com/en-us/windows-server/storage/storage-spaces/storage-spaces-states
Get-StorageSubSystem