使用gdisk 对 /dev/sda进行扩容
raid5 添加新磁盘之后
Linux还是会显示原来的磁盘容量在
Linux系统中需要重新对磁盘进行扩容你的 RAID5 阵列已经成功扩容到 3.6TB,但
gdisk仍然显示最大Last sector为5853511646(2.7TB)。这表明 分区表(GPT)还未正确识别整个磁盘空间。你可以使用以下方法重新扫描并
修正 GPT以使用完整的3.6TB空间。
运行gdisk
gdisk /dev/sda进入专家模式:
Command (? for help): x修正 GPT 备份表位置:
Expert command (? for help): eRelocating backup data structures to the end of the disk返回主菜单:
Expert command (? for help): m打印分区表
Command (? for help): pDisk /dev/sda: 7804682240 sectors, 3.6 TiB
Model: MR9361-8i
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): B1E515BD-4B7E-47A5-BA74-3D13E0C199E5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 7804682206
Partitions will be aligned on 2048-sector boundaries
Total free space is 1951172574 sectors (930.4 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 5853511646 2.7 TiB 8300 Linux filesystem
重新调整分区
删除现有分区(不会影响数据,只是更新分区表):
Command (? for help): dUsing 1创建新分区(起始要跟之前一样是2048)
Command (? for help): nPartition number (1-128, default 1): 1First sector (34-7804682206, default = 2048) or {+-}size{KMGTP}: 2048已经显示扩容之后的容量7804682206否则会显示扩容之前的容量
Last sector (2048-5853511646, default =5853511646) or {+-}size{KMGTP}:Partition number:输入
1First sector:输入
2048(必须和原来相同)Last sector:直接 按回车(默认最大值
7804682206)Hex code:直接回车(默认
8300,Linux 文件系统)
Last sector (2048-7804682206, default = 7804682206) or {+-}size{KMGTP}: Current type is 8300 (Linux filesystem)Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'保存
Command (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!Do you want to proceed? (Y/N): yOK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.让系统重新识别分区
echo 1 > /sys/class/block/sda/device/rescan或者
partprobe /dev/sda如果 partprobe 失败,可能需要 重启服务器 让内核识别新的分区大小。
扩展文件系统
你的
/dev/sda1现在已经扩展到了 3.6TB,但文件系统仍然是 2.7TB,所以还需要扩展文件系统:
查看文件是ext4还是XFS
lsblk -fNAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
└─sda1 xfs bd734df4-bcb1-49b9-b7ac-bcb149b9b7ac 169.1G 94% /smb
sdb
├─... 如果是 ext4
resize2fs /dev/sda1如果是 XFS
xfs_growfs /dev/sda1确认扩容成功
df -h文件系统 容量 已用 可用 已用% 挂载点
...
/dev/sda1 3.7T 2.6T 1.1T 71% /smb
...注意:
如果卸载硬盘的时候提示 umount: /disk: 目标忙.
查看是什么使用了这个磁盘(关闭或者kill掉)
fuser -mv /dev/sda1/dev/sda1: root kernel mount /smb
root 13219 F.... qbittorrent-nox
root 13253 ..c.. smbd[192.168.2.END...
Command (? for help): v
Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.
Identified 1 problems!
阵列更换大容量硬盘扩容 1T - 2T
✅ 前提条件
RAID 控制器: 你用的是 LSI 9361-8i,支持 OCE 和 RLM(Rebuild + Logical Drive Expansion)。
当前状态: RAID 5(5 × 1TB),阵列正常、有重要数据。
目标状态: RAID 5(5 × 2TB),保留数据、扩展容量。
🚧 强烈建议前提:
提前做好完整备份! 虽然过程是“在线”的,但一旦中断(如断电或某盘重建失败),可能会丢失整个阵列数据。
🧭 操作流程:逐个替换硬盘 + 重建 + 扩容
第 1 步:替换第一块 1TB 硬盘
storcli /c0/e252/s0 set offline storcli /c0/e252/s0 remove # 插入新的 2TB 硬盘(位置 s0) storcli /c0 add hotsparedrive enclosure=252 slot=0复制编辑
控制器将自动开始重建数据到新硬盘
等待重建完成(可使用 storcli /c0 /vall show rebuild 查看状态)
第 2~5 步:依次替换剩余 1TB 硬盘(s1, s2, s3, s4)
重复上面流程 每次仅替换一块盘,并等待重建完成再继续下一块。
第 6 步:所有硬盘都更换为 2TB 后,扩展阵列容量
storcli /c0/v0 start migrate type=r5 drives=252:0-4查看剩余未分配的容量
storcli /c0/d0 show all分配332GB
storcli /c0/v0 expand size=332GB expandarray查看进度 (10秒更新一次)
watch -n 10 'storcli /c0/v0 show all | grep -i "Active Operations"'扩展后你可以来确认新容量。
storcli /c0/v0 show查看硬盘温度
storcli /c0/eall/sall show all | awk '/^Drive \/.* State :$/ {drive=$0} /Drive Temperature/ {print drive; print $0; print ""}'Drive /c0/e252/s0 State :
Drive Temperature = 43C (109.40 F)
Drive /c0/e252/s1 State :
Drive Temperature = 39C (102.20 F)
Drive /c0/e252/s2 State :
Drive Temperature = 42C (107.60 F)
Drive /c0/e252/s4 State :
Drive Temperature = 44C (111.20 F)
Drive /c0/e252/s5 State :
Drive Temperature = 41C (105.80 F)📌 注意事项
整个过程每替换一块盘都必须等重建完成后再继续。
控制器通常自动开始重建,但你也可以手动指定。
最后扩容有时需要在系统中重新扫描 RAID 分区,或者对文件系统进行扩展(比如
resize2fs或xfs_growfs)。不要同时替换两块盘!RAID 5 只容忍一块坏盘。
✅ 最终效果
最新扩容
[root@Server ~]# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.7
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): x
Expert command (? for help): e
Relocating backup data structures to the end of the disk
Expert command (? for help): m
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
[root@Server ~]# parted /dev/sda
GNU Parted 3.5
使用 /dev/sda
欢迎使用 GNU Parted!输入 'help' 来查看命令列表。
(parted) print
型号:AVAGO MR9361-8i (scsi)
磁盘 /dev/sda:16.0TB
扇区大小 (逻辑/物理):512B/512B
分区表:gpt
磁盘标志:
编号 起始点 结束点 大小 文件系统 名称 标志
1 1049kB 3996GB 3996GB xfs Linux filesystem
(parted) resizepart 1 100%
警告: 分区 /dev/sda1 正被使用。你确定要继续吗?
是/Yes/否/No? yes
(parted) quit
信息: 你可能需要 /etc/fstab。
[root@Server ~]# partprobe
Warning: 并非所有可用于 /dev/nvme0n1 的空间都被用到了,您可以修正 GPT 以使用所有的空间 (额外的 15628032 个区块),还是说要继续使用目前的设置?
[root@Server ~]# fdisk -l /dev/sda
Disk /dev/sda:14.55 TiB,15999998885888 字节,31249997824 个扇区
磁盘型号:MR9361-8i
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):262144 字节 / 262144 字节
磁盘标签类型:gpt
磁盘标识符:B1E515BD-4B7E-47A5-BA74-3D13E0C199E5
设备 起点 末尾 扇区 大小 类型
/dev/sda1 2048 31249997790 31249995743 14.6T Linux 文件系统
[root@Server ~]#
[root@Server ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs tmpfs 7.7G 16K 7.7G 1% /dev/shm
tmpfs tmpfs 3.1G 303M 2.8G 10% /run
/dev/mapper/rl_server-root xfs 100G 46G 55G 46% /
/dev/nvme1n1p1 xfs 932G 816G 116G 88% /minecraft
/dev/nvme0n1p2 xfs 2.0G 364M 1.6G 19% /boot
/dev/nvme0n1p1 vfat 1022M 7.1M 1015M 1% /boot/efi
/dev/sda1 xfs 3.7T 3.4T 325G 92% /smb
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/0
overlay overlay 100G 46G 55G 46% /var/lib/docker/overlay2/049157bc1e8d58decae71299afd0f52a45d165364a7100241c917174767ffc7e/merged
overlay overlay 100G 46G 55G 46% /var/lib/docker/overlay2/9c6b1b0cbce2356108657066f4c40a3625ddc25c65481375a6857328bc18b518/merged
[root@Server ~]# xfs_growfs /smb
meta-data=/dev/sda1 isize=512 agcount=43, agsize=22865280 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=975585019, imaxpct=5
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=357269, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 975585019 to 3906249467
[root@Server ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs tmpfs 7.7G 16K 7.7G 1% /dev/shm
tmpfs tmpfs 3.1G 303M 2.8G 10% /run
/dev/mapper/rl_server-root xfs 100G 46G 55G 46% /
/dev/nvme1n1p1 xfs 932G 816G 116G 88% /minecraft
/dev/nvme0n1p2 xfs 2.0G 364M 1.6G 19% /boot
/dev/nvme0n1p1 vfat 1022M 7.1M 1015M 1% /boot/efi
/dev/sda1 xfs 15T 3.4T 12T 24% /smb
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/0
overlay overlay 100G 46G 55G 46% /var/lib/docker/overlay2/049157bc1e8d58decae71299afd0f52a45d165364a7100241c917174767ffc7e/merged
overlay overlay 100G 46G 55G 46% /var/lib/docker/overlay2/9c6b1b0cbce2356108657066f4c40a3625ddc25c65481375a6857328bc18b518/merged
[root@Server ~]#
评论区