LVM – VG 指令

vgcreate 將一個或一個以上的 PV 組成一個 VG
 # vgcreate diskvg /dev/sdb1 /dev/sdb2 /dev/sdb3
  Volume group “diskvg” successfully created

vgdisplay 顯示 VG 的相關訊息,包括 PE 的數量、大小等資訊
# vgdisplay diskvg
  — Volume group —
  VG Name               diskvg
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               2.99 GiB
  PE Size               4.00 MiB
  Total PE              765
  Alloc PE / Size       114 / 456.00 MiB
  Free  PE / Size       651 / 2.54 GiB
  VG UUID               KP7wM8-DDuZ-a5jy-RsBP-Be22-5nVu-dk9hCl

[@more@]vgscan 掃描系統中所有的 VG 資訊
# vgscan
  Reading all physical volumes.  This may take a while…
  Found volume group “diskvg” using metadata type lvm2

vgextend 擴充 VG 容量,把 PV 加入已存在的 VG
# vgextend diskvg /dev/sdc1
  Volume group “diskvg” successfully extended
# vgdisplay diskvg
  — Volume group —
  VG Name               diskvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               3.98 GiB
  PE Size               4.00 MiB
  Total PE              1020
  Alloc PE / Size       114 / 456.00 MiB
  Free  PE / Size       906 / 3.54 GiB
  VG UUID               KP7wM8-DDuZ-a5jy-RsBP-Be22-5nVu-dk9hCl

vgchange 停止 VG 的作用,目的是讓所有程式不能再存取此 VG
# vgchange -a n diskvg
0 logical volume(s) in volume group “diskvg” now active

vgremove 刪除 VG
要先停止 VG 後,才能刪除 VG
# vgremove diskvg
Volume group “diskvg” sucessfully removed

vgreduce 移除加入到 VG 的 PV
# vgreduce diskvg /dev/sdc1
Removed “/dev/sdc1” from volume group “diskvg”