CentOS Stream 8
Sponsored Link

LVM : Manage Volume Groups2021/03/08

 
This is the basic operation of managing Volume Groups.
It needs to create Physical Volumes first.
[1] Create Volume Groups.
[root@dlp ~]#
vgcreate vg_dlp /dev/sdb1

  Volume group "vg_dlp" successfully created

# specify like follows if you'd like to use multiple devices

[root@dlp ~]#
vgcreate vg_dlp /dev/sdb1 /dev/sdd1

  Volume group "vg_dlp" successfully created
[2] Display Volume Groups.
[root@dlp ~]#
vgdisplay vg_dlp

  --- Volume group ---
  VG Name               vg_dlp
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / <80.00 GiB
  VG UUID               zvTFJF-YYC8-xhdZ-GyQM-axS5-sk1q-iTq4fD
[3] Change Volume Groups' name.
[root@dlp ~]#
vgrename vg_dlp vg_data

  Volume group "vg_dlp" successfully renamed to "vg_data"

[root@dlp ~]#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / <80.00 GiB
  VG UUID               zvTFJF-YYC8-xhdZ-GyQM-axS5-sk1q-iTq4fD
[4] Display reports of Volume Groups.
[root@dlp ~]#
vgs

  VG      #PV #LV #SN Attr   VSize   VFree
  cs        1   2   0 wz--n- <79.00g  96.00m
  vg_data   1   0   0 wz--n- <80.00g <80.00g
[5] Scan Volume Groups.
[root@dlp ~]#
vgscan

  Found volume group "vg_data" using metadata type lvm2
  Found volume group "cs" using metadata type lvm2
[6] Extend Volume Groups.
# add [sdc1] to [vg_data]

[root@dlp ~]#
vgextend vg_data /dev/sdc1

  Volume group "vg_data" successfully extended

[root@dlp ~]#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               159.99 GiB
  PE Size               4.00 MiB
  Total PE              40958
  Alloc PE / Size       0 / 0
  Free  PE / Size       40958 / 159.99 GiB
  VG UUID               cP1GSC-F7FJ-0RH9-k3n9-O14K-emKx-g3O8xc
[7] Reduce Volume Groups.
# remove [sdc1] from [vg_data]

[root@dlp ~]#
vgreduce vg_data /dev/sdc1

  Removed "/dev/sdc1" from volume group "vg_data"

[root@dlp ~]#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / <80.00 GiB
  VG UUID               cP1GSC-F7FJ-0RH9-k3n9-O14K-emKx-g3O8xc
[8] Delete Volume Groups.
# disable target volume group first and delete it

[root@dlp ~]#
vgchange -a n vg_data

  0 logical volume(s) in volume group "vg_data" now active

[root@dlp ~]#
vgremove vg_data

  Volume group "vg_data" successfully removed
Matched Content