背景:现已有lvm根分区,不能满足业务需求,在业务不下线的情况下对/分区扩容 思路:创建新分区 => 创建物理卷 => 加入卷组 => 扩容
1、找到要扩容的分区
2、找到新添加的磁盘
3、对该磁盘进行分区
fdsk /dev/sdb
4、刷新分区并创建物理卷
刚分完区可能看不见,可是使用partprobe命令刷新一下,在lsblk就可以看见了
[root@localhost ~]# partprobe /dev/sdb
[root@localhost ~]# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created.
5、将新创建的物理卷添加到根的卷组中
可以看见根的卷组是centos
[root@localhost ~]# lvdisplay
使用vgextend命令将/dev/sdb3物理卷添加到卷组centos中
[root@localhost ~]# vgextend centos /dev/sdb3
Volume group "centos" successfully extended
6、将卷组中的空闲空间分配给根分区(根分区需要是绝对路径df命令可以看见)
[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from 197.99 GiB (50686 extents) to <199.99 GiB (51197 extents).
Logical volume centos/root successfully resized.
7、刷新一下根分区就可以了
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=5, agsize=12910336 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=51902464, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=25215, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 51902464 to 52425728
8、可以看见根分区已经从198G扩到200G了
::: hljs-center
那里不对的还请小伙伴们指正,以便改进,谢谢!!
:::
标签:4096,centos,分区,dev,centos7,LVM,root,localhost From: https://blog.51cto.com/u_14348846/6101380