GPT盘新增容量后如何扩容?

场景:一块5T的GPT盘,现有需求再加10T,

在虚拟化平台加10T盘后,机器不重启,执行命令

echo 1 > /sys/block/sdb/device/rescan刷新磁盘容量,可看到容量已刷出。

但执行fdisk /dev/sdb时,发现创建不了逻辑分区,且默认选项的分区大小还是跟以前一样无变化:

切换使用parted命令来进行分区,碰到如下报错:

复制代码
[root@LVFS-BB59CC ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes
the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra
21474836480 blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 16.5TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  5498GB  5498GB               primary

报错原因是:

说明

Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?

GPT分区表信息存储在磁盘开头,为了减少分区表损坏的风险,同时在磁盘末尾会备份一份。当磁盘容量扩大后,末尾位置也会随之变化,因此需要根据系统提示输入"Fix",将分区表信息的备份文件挪到新的磁盘末尾位置。

修复之后,正常打印无问题,然后创建第二个分区,并将新增容量全部给它:

复制代码
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 16.5TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  5498GB  5498GB               primary

(parted) mkpart primary 5499G 100%
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 16.5TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  5498GB  5498GB               primary
 2      5499GB  16.5TB  11.0TB               primary

可以看到已经成功分区了,执行quit退出parted

查看分区,可以看到sdb2有了:

复制代码
[root@LVFS-BB59CC ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0    6T  0 disk
├─sda1            8:1    0    2M  0 part
├─sda2            8:2    0    2G  0 part /boot
└─sda3            8:3    0    2T  0 part
  ├─centos-root 253:0    0   12T  0 lvm  /
  └─centos-swap 253:1    0    8G  0 lvm  [SWAP]
sdb               8:16   0   15T  0 disk
├─sdb1            8:17   0    5T  0 part
│ └─centos-root 253:0    0   12T  0 lvm  /
└─sdb2            8:18   0   10T  0 part
sdc               8:32   0    5T  0 disk
└─centos-root   253:0    0   12T  0 lvm  /
sr0              11:0    1 1024M  0 rom

最终扩容,将新增10T空间划给根分区:

复制代码
[root@LVFS-BB59CC ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   3   2   0 wz--n- <12.00t    0
[root@LVFS-BB59CC ~]# vgextend centos /dev/sdb2
  Physical volume "/dev/sdb2" successfully created.
  Volume group "centos" successfully extended
[root@LVFS-BB59CC ~]# lvextend -l +100%FREE /dev/mapper/centos-root
  Size of logical volume centos/root changed from 11.99 TiB (3143165 extents) to <21.99 TiB (5764260 extents).
  Logical volume centos/root successfully resized.
[root@LVFS-BB59CC ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=101, agsize=32112384 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=3218600960, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=62719, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 3218600960 to 5902602240
[root@LVFS-BB59CC ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  8.9M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   22T   12T   11T  53% /
/dev/sda2                2.0G  137M  1.9G   7% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
相关推荐
liu****8 小时前
2.深入浅出理解虚拟化与容器化(含Docker实操全解析)
运维·c++·docker·容器·虚拟化技术
池央8 小时前
CANN 诊断工具链深度解析:oam-tools 的自动化故障信息收集、软硬件状态快照与 AI Core 错误溯源机制
运维·人工智能·自动化
云边有个稻草人9 小时前
打工人摸鱼新姿势!轻量斗地主服务器,内网穿透让同事远程联机不翻车
运维·服务器·cpolar
乾元9 小时前
终端安全(EDR):用深度学习识别未知勒索软件
运维·人工智能·网络协议·安全·网络安全·自动化·安全架构
wbs_scy9 小时前
Linux 进阶指令实操指南:文件查看、时间管理、搜索压缩全场景覆盖(附高频案例)
linux·运维·服务器
安科瑞刘鸿鹏179 小时前
高速路灯故障难定位?用 ASL600 实现精确单灯监测与维护预警
运维·网络·物联网·安全
馨谙9 小时前
Ansible 事实(Facts)全面指南:自动化运维中的主机信息管理
运维·ansible
Lethehong9 小时前
实测可用|一文搞定OpenClaw部署,免费kimi-k2.5+飞书远程,新手也能秒上手
linux·运维·服务器·玩转openclaw·云端创意实践
馨谙9 小时前
Ansible处理程序完全指南:实现智能的任务触发机制
运维·ansible
承渊政道9 小时前
Linux系统学习【Linux基础开发工具】
linux·运维·笔记·学习·centos·编辑器