#创建物理卷,将新增磁盘加入到物理卷。
[root@Template~]# pvcreate /dev/sdb
Physical volume"/dev/sdb"successfully created
##查看物理卷。
[root@Template~]# pvs
PV VG Fmt Attr PSize PFree/dev/sda2 vg_template lvm2 a--u 39.51g 0
/dev/sdb lvm2 ---- 20.00g 20.00g
##查看物理卷信息。
[root@Template~]# pvdisplay--- Physical volume ---PV Name/dev/sda2
VG Name vg_template
PV Size39.51 GiB / not usable 3.00MiB
Allocatable yes (but full)
PE Size4.00MiB
Total PE10114Free PE0Allocated PE10114PV UUID A6Ai9a-LdqF-GbCn-p0DF-3V3X-j3h1-KfvlI4"/dev/sdb" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---PV Name/dev/sdb
VG Name
PV Size20.00GiB
Allocatable NO
PE Size0Total PE0Free PE0Allocated PE0PV UUID sxgFvu-x0au-8CxD-g6I6-yCJe-M9gg-Ax2jiu
##扩展卷组vg_template,即将PV加入卷组(VG)。
[root@Template~]# vgextend vg_template /dev/sdb
Volume group"vg_template"successfully extended
###先查看vg信息,然后将原/dev/vg_template/lv_root 逻辑卷的大小增加。
[root@Template~]# vgdisplay--- Volume group ---VG Name vg_template
System ID
Format lvm2
Metadata Areas2Metadata Sequence No4VG Access read/writeVG Status resizable
MAX LV0Cur LV2Open LV2Max PV0Cur PV2Act PV2VG Size59.50GiB
PE Size4.00MiB
Total PE15233Alloc PE/ Size 10114 / 39.51GiB
Free PE/ Size 5119 / 20.00GiB
VG UUID p5VnUJ-vdh9-7ffb-guxI-97sR-GnzU-rwzyc4
###运行扩容命令,对/dev/vg_template/lv_root逻辑卷进行扩容[root@Template vg_template]# lvextend-l +100%FREE /dev/mapper/vg_template-lv_root
###查看分区格式,如果分区格式是ext,用resize2fs扩容;如果分区格式是xfs,用xfs_growfs扩容。命令如下:
[root@node172 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root xfs 930G 70G 861G 8% /