扩展LV手记

情景概览

系统:CentOS Linux release 7.4.1708 (Core)

磁盘情况:

目标:将sda3扩展到sda2下的centos-root虚拟盘上

操作步骤

1、建立新的PV

# pvdisplay 

--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <198.76 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 50881
Free PE 1
Allocated PE 50880
PV UUID MOS4Au-AmMY-oRQK-TrgL-V4vP-TjMp-eaqd8e

# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.

# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <198.76 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 50881
Free PE 1
Allocated PE 50880
PV UUID MOS4Au-AmMY-oRQK-TrgL-V4vP-TjMp-eaqd8e

"/dev/sda3" is a new physical volume of "300.24 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 300.24 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID c9zrf4-Q6u9-2BEe-ci88-yCb0-G9AC-TVUsvx

2、扩展VG,将PV加入到VG中

# vgextend centos /dev/sda3
Volume group "centos" successfully extended
# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 498.99 GiB
PE Size 4.00 MiB
Total PE 127742
Alloc PE / Size 50880 / 198.75 GiB
Free PE / Size 76862 / 300.24 GiB
VG UUID 4EPf01-TOsz-YLe6-ny77-vWQt-tifb-cDirE8

3、扩展LV,100%空闲的vg全部加入

# lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from 133.00 GiB (34048 extents) to 433.24 GiB (110910 extents).
Logical volume centos/root successfully resized.

4、扩展文件系统

# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=8716288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=34865152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=17024, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 34865152 to 113571840

5、验证磁盘情况

最后附上一张结构图,学习

猜你喜欢

转载自www.cnblogs.com/ipoke/p/9045199.html