Configure LVM on Centos7
  Manage physical Volumes:
  
	
This is the basic operation of managing physical  Volumes.
  
Create physical  Volume:-
 
[root@server ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
# specify like follows if you'd like to specify volume size
[root@server ~]# pvcreate --setphysicalvolumesize 40G /dev/sdb1
 Physical volume "/dev/sdb1" successfully created
<>bruse_localtime=YES
Display physical  Volumes
 
# To display physical volumes
[root@server ~]# pvdisplay /dev/sdb1
Change size of physical  Volume
    
  # change to 40G
[root@server ~]# pvresize --setphysicalvolumesize 40G /dev/sdb1
Physical volume "/dev/sdb1" changed
  
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@server ~]# pvdisplay /dev/sdb1
 
Display reports of physical  Volumes.
   
[root@server ~]# pvs /dev/sdb1
 
To Scan physical  Volumes.
 
[root@server ~]#  pvscan
 
To 	Delete physical  Volume
 
[root@server ~]#  pvremove /dev/sdb1
 
Labels on physical volume "/dev/sdb1" successfully wiped
 
[root@server ~]# pvdisplay /dev/sdb1
 
 Failed to find physical volume "/dev/sdb1".
 
 Manage Volumes Grouops:
  
	
This is the basic operation of managing physical  Volumes.
  
Create Volume Group from PV /dev/sdb1:-
[root@server ~]# vgcreate vg_svr /dev/sdb1
 
 
Display  Volumes Groups
[root@server ~]# vgdisplay vg_svr
Change Volume Group's name
    
[root@server ~]# vgrename vg_srv vg_example
Volume group "vg_srv" successfully renamed to "vg_example" vgdisplay
  
[root@server ~]# vgdisplay vg_example
 
Display reports of Volume Groups
   
[root@server ~]# vgs
 
To Scan Volume Groups
 
[root@server ~]#  vgscan
 
To Delete Volume Group
 
# disable target volume group first and delete it
[root@server ~]#  vgchange -a n vg_example
 
0 logical volume(s) in volume group "vg_example" now active
 
[root@server ~]# vgremove vg_example
 
 Volume group "vg_example" successfully removed
 
  
  Manage Logical Volumes:
  
	
This is the basic operation of managing Logical Volumes.
  
Create Logical Volume from VG vg_example:-
[root@server ~]# lvcreate -L 50G -n lv_data vg_srv
 
 
Display  Logical Volumes.
[root@server ~]# lvdisplay /dev/vg_srv/lv_data
Rename Logical Volume
    
[root@server ~]# lvrename vg_srv lv_data lv_example
Renamed "lv_data" to "lv_example" in volume group "vg_srv"
  
[root@server ~]# lvdisplay /dev/vg_srv/lv_example
 
Display reports of Logical Volumes
   
[root@server ~]# lvs
 
To Scan Logical Volumes
 
[root@server ~]#  lvscan
[root@server ~]# lvdisplay
 
Extend Logical Volume.
 
[root@server ~]# lvextend -L 60G /dev/vg_srv/lv_example
#for the case of extending ext4 filesystem
[root@server ~]# lvdisplay /dev/vg_srv/lv_example 
 [root@server ~]# resize2fs 
Reduce Logical Volume.
#Unmount target device first.
# for ext4, check it first
[root@server ~]# e2fsck -f /dev/vg_srv/lv_example 20G 
[root@server ~]# resize2fs /dev/vg_srv/lv_example 20G
#reduce logical volmue at last
[root@server ~]# lvreduce -L 20G /dev/vg_srv/lv_example 
To Delete Logical Volume. first unmount then stop logical volume then delete logical volume
 
# disable target volume group first and delete it
[root@server ~]#  lvchange -an /dev/vg_srv/lv_example
 
0 logical volume(s) in volume group "vg_example" now active
 
[root@server ~]# lvremove /dev/vg_srv/lv_example
 
 Logical volume "lv_example" successfully removed