1. 存储管理概述
Windows Server 2022的存储管理是系统管理的重要组成部分,包括磁盘管理、分区管理、文件系统管理、动态磁盘管理、Storage Spaces管理和iSCSI管理等。本文将详细介绍Windows Server 2022的存储管理方法。更多学习教程www.fgedu.net.cn
PS C:\> Get-Disk
Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style
—— ————- ————- ———— —————– ———- —————
0 Virtual HD A 12345678-1234-1234-1234-1234567890ab Healthy Online 500 GB MBR
1 Virtual HD B 87654321-4321-4321-4321-0987654321ab Healthy Online 100 GB GPT
2. 磁盘管理
磁盘管理是存储管理的基础,包括磁盘识别、初始化、分区和格式化等操作。
PS C:\> Get-Disk | Select-Object -Property *
Number : 0
FriendlyName : Virtual HD A
SerialNumber : 12345678-1234-1234-1234-1234567890ab
Model : Virtual HD
MediaType : Unspecified
BusType : SCSI
Size : 536870912000
PartitionStyle : MBR
ProvisioningType : Fixed
OperationalStatus : Online
HealthStatus : Healthy
IsReadOnly : False
IsSystem : True
IsBoot : True
IsActive : True
IsPrimary : True
IsOffline : False
IsClustered : False
UniqueId : \?\PhysicalDrive0
Path : \\.\PHYSICALDRIVE0
Manufacturer : Microsoft
Location : Bus 0, Target 0, Lun 0
LunNumber : 0
UniqueIdFormat : Vendor Specific
AllocatedSize : 536870912000
LogicalSectorSize : 512
PhysicalSectorSize : 4096
NumberOfPartitions : 3
SupportsUnsafeShutdown : True
SupportsPowerDownNotification : True
ObjectId : {1}\fgedu\root/Microsoft/Windows/Storage/Providers_v2\WSP_Disk.ObjectId=”{12345678-1234-1234-1234-1234567890ab}”
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
CimClass : ROOT/Microsoft/Windows/Storage:MSFT_Disk
CimInstanceProperties : {
…
}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
3. 分区管理
分区管理是将磁盘划分为多个逻辑区域的过程,便于管理和使用。学习交流加群风哥微信: itpux-com
PS C:\> Get-Partition
DiskPath: \?\PhysicalDrive0
PartitionNumber DriveLetter Offset Size Type
————— ———– —— —- —-
1 C 1048576 450 GB Basic
2 D 483183828992 49 GB Basic
3 E 532095498240 1 GB Basic
DiskPath: \?\PhysicalDrive1
PartitionNumber DriveLetter Offset Size Type
————— ———– —— —- —-
1 F 1048576 100 GB Basic
PS C:\> New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter G
PartitionNumber DriveLetter Offset Size Type
————— ———– —— —- —-
2 G 107479044096 100 GB Basic
# 删除分区
PS C:\> Remove-Partition -DiskNumber 1 -PartitionNumber 2
# 扩展分区
PS C:\> Resize-Partition -DiskNumber 0 -PartitionNumber 2 -Size (450GB)
# 收缩分区
PS C:\> Resize-Partition -DiskNumber 0 -PartitionNumber 1 -Size (400GB)
4. 文件系统管理
文件系统是操作系统用于管理和存储数据的方式,Windows支持多种文件系统,如NTFS、ReFS、FAT32等。
PS C:\> Format-Volume -DriveLetter G -FileSystem NTFS -NewFileSystemLabel “Data” -Force
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
———– ————— ———- ——— ———— —————– ————- —-
G Data NTFS Fixed Healthy OK 99.98 GB 100 GB
# 格式化分区为ReFS文件系统
PS C:\> Format-Volume -DriveLetter G -FileSystem ReFS -NewFileSystemLabel “Data” -Force
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
———– ————— ———- ——— ———— —————– ————- —-
G Data ReFS Fixed Healthy OK 99.98 GB 100 GB
# 查看文件系统信息
PS C:\> Get-Volume
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size
———– ————— ———- ——— ———— —————– ————- —-
C System NTFS Fixed Healthy OK 400.5 GB 450 GB
D Data NTFS Fixed Healthy OK 45.2 GB 49 GB
E Recovery NTFS Fixed Healthy OK 980 MB 1 GB
F Storage NTFS Fixed Healthy OK 95.3 GB 100 GB
G Data ReFS Fixed Healthy OK 99.98 GB 100 GB
5. 动态磁盘管理
动态磁盘是Windows的一种磁盘类型,支持创建跨区卷、条带卷、镜像卷和RAID-5卷等。学习交流加群风哥QQ113257174
PS C:\> Set-Disk -Number 1 -IsDynamic $true
# 查看动态磁盘信息
PS C:\> Get-Disk | Where-Object {$_.IsDynamic -eq $true}
Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style
—— ————- ————- ———— —————– ———- —————
1 Virtual HD B 87654321-4321-4321-4321-0987654321ab Healthy Online 100 GB GPT
# 创建跨区卷
PS C:\> New-Volume -DiskNumber 1,2 -FileSystem NTFS -DriveLetter H -FriendlyName “SpannedVolume”
# 创建条带卷
PS C:\> New-Volume -DiskNumber 1,2 -FileSystem NTFS -DriveLetter I -FriendlyName “StripedVolume” -ResiliencySettingName Simple
# 创建镜像卷
PS C:\> New-Volume -DiskNumber 1,2 -FileSystem NTFS -DriveLetter J -FriendlyName “MirroredVolume” -ResiliencySettingName Mirror
# 创建RAID-5卷
PS C:\> New-Volume -DiskNumber 1,2,3 -FileSystem NTFS -DriveLetter K -FriendlyName “RAID5Volume” -ResiliencySettingName Parity
6. Storage Spaces管理
Storage Spaces是Windows Server 2022的一项存储虚拟化技术,可以将多个物理磁盘组合成一个存储池,然后创建虚拟磁盘。
PS C:\> New-StoragePool -FriendlyName “StoragePool1” -StorageSubSystemFriendlyName “Storage Spaces*” -PhysicalDisks (Get-PhysicalDisk | Where-Object {$_.CanPool -eq $True})
# 查看存储池信息
PS C:\> Get-StoragePool
FriendlyName OperationalStatus HealthStatus IsPrimordial IsReadOnly Size AllocatedSize
———— —————- ———— ———— ———- —- ————-
StoragePool1 OK Healthy False False 300 GB 0 B
Primordial OK Healthy True False 300 GB 0 B
# 创建虚拟磁盘
PS C:\> New-VirtualDisk -StoragePoolFriendlyName “StoragePool1” -FriendlyName “VirtualDisk1” -Size 200GB -ResiliencySettingName Mirror
# 初始化并格式化虚拟磁盘
PS C:\> Get-VirtualDisk -FriendlyName “VirtualDisk1” | Get-Disk | Initialize-Disk -PartitionStyle GPT
PS C:\> Get-VirtualDisk -FriendlyName “VirtualDisk1” | Get-Disk | New-Partition -UseMaximumSize -DriveLetter L
PS C:\> Format-Volume -DriveLetter L -FileSystem NTFS -NewFileSystemLabel “StorageSpaces”
# 查看虚拟磁盘信息
PS C:\> Get-VirtualDisk
FriendlyName ResiliencySettingName OperationalStatus HealthStatus IsManualAttach Size FootprintOnPool StoragePoolFriendlyName
———— ——————— —————- ———— ————– —- ————— ———————-
VirtualDisk1 Mirror OK Healthy False 200 GB 400 GB StoragePool1
7. iSCSI管理
iSCSI是一种通过IP网络传输SCSI命令的协议,可以实现存储设备的网络共享。更多学习教程公众号风哥教程itpux_com
PS C:\> Install-WindowsFeature -Name iSCSI-Target-Server,FS-iSCSITarget-Service
# 启动iSCSI服务
PS C:\> Start-Service -Name msiscsi
PS C:\> Set-Service -Name msiscsi -StartupType Automatic
# 发现iSCSI目标
PS C:\> New-IscsiTargetPortal -TargetPortalAddress 192.168.1.100
# 连接iSCSI目标
PS C:\> Get-IscsiTarget | Connect-IscsiTarget
# 查看iSCSI连接
PS C:\> Get-IscsiConnection
AuthenticationType : NONE
InitiatorAddress : 192.168.1.200
InitiatorPortNumber : 5000
TargetAddress : 192.168.1.100
TargetPortNumber : 3260
TargetPortalAddress : 192.168.1.100
IsConnected : True
ConnectionIdentifier : f8f9fafb-1234-4567-89ab-cdef01234567
SessionIdentifier : f8f9fafb-1234-4567-89ab-cdef01234567
iSCSIConnection : MSFT_iSCSIConnection (ObjectId = “{1}\fgedu\root/Microsoft/Windows/iSCSI/…”)
8. 存储监控
存储监控是确保存储系统正常运行的重要手段,需要定期检查存储状态和性能。
PS C:\> Get-Volume | Select-Object DriveLetter, FileSystemLabel, FileSystem, Size, SizeRemaining
DriveLetter FileSystemLabel FileSystem Size SizeRemaining
———– ————— ———- —- ————-
C System NTFS 483183828992 429785784320
D Data NTFS 52784412672 48564553728
E Recovery NTFS 1073741824 1027604480
F Storage NTFS 107374182400 100933636096
G Data ReFS 107374182400 107352981504
L StorageSpaces NTFS 214748364800 214727163904
# 查看磁盘I/O性能
PS C:\> Get-Counter -Counter “LogicalDisk(*)\% Disk Time” -SampleInterval 1 -MaxSamples 5
Timestamp CounterSamples
——— ————–
4/2/2026 10:00:00 AM \fgedu\logicaldisk(c:)\% disk time : 0
\fgedu\logicaldisk(d:)\% disk time : 0
\fgedu\logicaldisk(e:)\% disk time : 0
\fgedu\logicaldisk(f:)\% disk time : 0
\fgedu\logicaldisk(g:)\% disk time : 0
\fgedu\logicaldisk(l:)\% disk time : 0
\fgedu\logicaldisk(_total)\% disk time : 0
# 查看存储池状态
PS C:\> Get-StoragePool | Select-Object FriendlyName, OperationalStatus, HealthStatus, Size, AllocatedSize
FriendlyName OperationalStatus HealthStatus Size AllocatedSize
———— —————- ———— —- ————-
StoragePool1 OK Healthy 300 GB 400 GB
Primordial OK Healthy 300 GB 0 B
9. 存储故障排查
存储故障排查是系统管理员的重要技能,需要掌握基本的排查方法和工具。
# 检查磁盘状态
PS C:\> Get-Disk | Select-Object Number, FriendlyName, HealthStatus, OperationalStatus
# 检查文件系统
PS C:\> chkdsk C:
# 排查挂载问题
# 检查磁盘管理
PS C:\> diskmgmt.msc
# 排查Storage Spaces故障
# 检查存储池状态
PS C:\> Get-StoragePool | Select-Object FriendlyName, OperationalStatus, HealthStatus
# 检查虚拟磁盘状态
PS C:\> Get-VirtualDisk | Select-Object FriendlyName, OperationalStatus, HealthStatus
# 排查iSCSI故障
# 检查iSCSI服务状态
PS C:\> Get-Service -Name msiscsi
# 检查iSCSI连接
PS C:\> Get-IscsiConnection
10. 最佳实践
存储管理的最佳实践可以提高系统的可靠性和性能。author:www.itpux.com
– 使用Storage Spaces进行存储管理,提高存储灵活性和可靠性
– 配置适当的RAID级别,确保数据安全
– 定期备份重要数据
– 定期监控存储使用情况和I/O性能
– 合理规划分区和文件系统
– 选择合适的文件系统类型
– 定期检查磁盘健康状态
# 备份磁盘分区信息
PS C:\> Get-Partition | Export-Clixml -Path “C:\Backup\PartitionInfo.xml”
# 备份存储池配置
PS C:\> Get-StoragePool | Export-Clixml -Path “C:\Backup\StoragePoolInfo.xml”
# 备份虚拟磁盘配置
PS C:\> Get-VirtualDisk | Export-Clixml -Path “C:\Backup\VirtualDiskInfo.xml”
# 备份iSCSI配置
PS C:\> Get-IscsiTarget | Export-Clixml -Path “C:\Backup\iSCSITargetInfo.xml”
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
