lvm逻辑卷的扩容

LVM 逻辑卷扩容
1. 查看逻辑卷组
lvdisplay

[root@mn-test-mysql-18-81 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos # 名字
LV UUID ePj1dX-M6sr-XTDl-2Ace-1uDC-VglY-GBtlA6
LV Write Access read/write
LV Creation host, time localhost, 2023-08-10 20:00:07 +0800
LV Status available
# open 1
LV Size <73.12 GiB
Current LE 18718
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0

--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID F1Jiwi-S2fc-XhvI-9AQ2-aJaq-enHG-f1ewc2
LV Write Access read/write
LV Creation host, time localhost, 2023-08-10 20:00:08 +0800
LV Status available
# open 2
LV Size <5.88 GiB
Current LE 1504
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1

2. 添加一块磁盘,这里是/dev/sdb [用 fdisk -l 查看]

3. 扩容卷组
vgextend centos /dev/sdb
WARNING: ext4 signature detected on /dev/sdb at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb.
Physical volume "/dev/sdb" successfully created.
Volume group "centos" successfully extended

4. 查看扩容后的卷组
vgs
[root@mn-test-mysql-18-81 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 278.99g 200.00g

可以看到有200G的剩余空间

5. 扩容卷
lvextend -L +200G /dev/mapper/centos-root

[root@mn-test-mysql-18-81 ~]# lvextend -L +200G /dev/mapper/centos-root
Size of logical volume centos/root changed from <73.12 GiB (18718 extents) to <273.12 GiB (69918 extents).
Logical volume centos/root successfully resized.

6. 刷新
xfs_growfs /dev/mapper/centos-root

[root@mn-test-mysql-18-81 ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=4791808 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=19167232, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=9359, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 19167232 to 71596032

再次查看,已经扩容完成了

posted @ 2024-09-26 09:14  羊脂玉净瓶  阅读(28)  评论(0编辑  收藏  举报