Ubuntu 22.04
Sponsored Link

Manage Volume Groups2022/09/13

 
This is the basic operation of managing Volume Groups.
It needs to create Physical Volume first.
[1] Create Volume Group.
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               fdv5ul-Vleh-SflC-iFq2-p1JR-G2t0-3jnT01
[3] Change Volume Group's 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               fdv5ul-Vleh-SflC-iFq2-p1JR-G2t0-3jnT01
[4] Display reports of Volume Groups.
root@dlp:~#
vgs

  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <78.00g 1020.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 "ubuntu-vg" using metadata type lvm2
[6] Extend Volume Group.
# 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               fdv5ul-Vleh-SflC-iFq2-p1JR-G2t0-3jnT01
[7] Reduce Volume Group.
# 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               fdv5ul-Vleh-SflC-iFq2-p1JR-G2t0-3jnT01
[8] Delete Volume Group.
# 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