当我们的vg和lv空间不够用了那么我们该怎么办呢?
六、vg的扩展,缩减,移除
扩展vg卷大小
我之前还有一个/dev/sdb4分区没有,现在可以派上用场了。
[root@linuxidc ~]# vgextend vg0 /dev/sdb4
Physical volume "/dev/sdb4" successfully created##将/dev/sdb4分区创建成了pv
Volume group "vg0" successfully extended###/dev/sdb4这个pv成功的加入到了vg中来了
[root@linuxidc ~]# pvscan
PV /dev/sdb1 VG vg0 lvm2 [30.00 GiB / 0 free]
PV /dev/sdb2 VG vg0 lvm2 [30.00 GiB / 9.99 GiB free]
PV /dev/sdb3 VG vg0 lvm2 [30.00 GiB / 30.00 GiB free]
PV /dev/sdb4 VG vg0 lvm2 [30.00 GiB / 30.00 GiB free]##看此时相比前面多了一个pv
Total: 4 [119.98 GiB] / in use: 4 [119.98 GiB] / in no VG: 0 [0 ]
[root@linuxidc ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg0" using metadata type lvm2
[root@linuxidc ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 4
Act PV 4
VG Size 119.98 GiB###看大小发生了改变了
PE Size 4.00 MiB
Total PE 30716
Alloc PE / Size 12800 / 50.00 GiB
Free PE / Size 17916 / 69.98 GiB
VG UUID p8dacU-UFYP-eazU-Jelp-vRAN-wEP3-hxzXfW
缩减vg大小
[root@linuxidc ~]# pvscan
PV /dev/sdb1 VG vg0 lvm2 [30.00 GiB / 0 free]
PV /dev/sdb2 VG vg0 lvm2 [30.00 GiB / 9.99 GiB free]
PV /dev/sdb3 VG vg0 lvm2 [30.00 GiB / 30.00 GiB free]
PV /dev/sdb4 VG vg0 lvm2 [30.00 GiB / 30.00 GiB free]
Total: 4 [119.98 GiB] / in use: 4 [119.98 GiB] / in no VG: 0 [0 ]
##查看下pv有哪些是没有被使用的,由此我们可以看出/dev/sdb3 /dev/sdb4没用
[root@linuxidc ~]# vgreduce vg0 /dev/sdb4
Removed "/dev/sdb4" from volume group "vg0"
[root@linuxidc ~]# pvscan
PV /dev/sdb1 VG vg0 lvm2 [30.00 GiB / 0 free]
PV /dev/sdb2 VG vg0 lvm2 [30.00 GiB / 9.99 GiB free]
PV /dev/sdb3 VG vg0 lvm2 [30.00 GiB / 30.00 GiB free]
PV /dev/sdb4 lvm2 [30.00 GiB]
Total: 4 [119.99 GiB] / in use: 3 [89.99 GiB] / in no VG: 1 [30.00 GiB]
[root@linuxidc ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 89.99 GiB
PE Size 4.00 MiB
Total PE 23037
Alloc PE / Size 12800 / 50.00 GiB
Free PE / Size 10237 / 39.99 GiB
VG UUID p8dacU-UFYP-eazU-Jelp-vRAN-wEP3-hxzXfW
七、扩展、缩减LV