使用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): e
Relocating backup data structures to the end of the disk
返回主菜单:
Expert command (? for help): m
打印分区表
Command (? for help): p
Disk /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): d
Using 1
创建新分区(起始要跟之前一样是2048)
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-7804682206, default = 2048) or {+-}size{KMGTP}: 2048
已经显示扩容之后的容量7804682206否则会显示扩容之前的容量
Last sector (2048-5853511646
, default =5853511646
) or {+-}size{KMGTP}:Partition number:输入
1
First 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): 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.
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 -f
NAME 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!
评论区