![LVM 基于增加现有磁盘大小来扩展文件系统](https://linux22.com/image/227958/LVM%20%E5%9F%BA%E4%BA%8E%E5%A2%9E%E5%8A%A0%E7%8E%B0%E6%9C%89%E7%A3%81%E7%9B%98%E5%A4%A7%E5%B0%8F%E6%9D%A5%E6%89%A9%E5%B1%95%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F.png)
几个月前,我们通过添加 VMDK sdi 磁盘来扩展根 XFS 文件系统分区大小(仅为 20G),并将根文件系统增加 +100G
[root@DB_OP_SERVER ~]# pvcreate /dev/sdi
Physical volume "/dev/sdi" successfully created.
[root@DB_OP_SERVER ~]# vgextend VG_DB /dev/sdi
Volume group "VG_DB" successfully extended
[root@DB_OP_SERVER ~]# lvresize --size +100g /dev/mapper/VG_DB-lv_root
Size of logical volume VG_DB/lv_var changed from ....
Logical volume VG_DB/lv_var successfully resized.
[root@DB_OP_SERVER ~]# xfs_growfs /root
meta-data=/dev/mapper/VG_DB-lv_var isize=512 agcount=7, agsize=6553600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=42729472, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=12800, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 42729472 to 45350912
df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VG_DB-lv_root 120G 110G 10G 93% /
现在我们想要将根文件系统增加+50G,以使根文件系统大小达到170G
因此我们更新 VMDK 磁盘(通过在 vSphere 客户端中编辑设置来150G)
再次增加根文件系统需要哪些步骤?
答案1
我执行了以下步骤,这样我们就得到了正确的分区大小
首先我们需要重新扫描磁盘
echo 1 > /sys/block/sdi/device/rescan
pvresize /dev/sdi
lvresize --size +50g /dev/mapper/VG_DB-lv_root
xfs_growfs /root