LVM

Concepts

Physical volumes

pvs – Display information about physical volumes

$ sudo pvs
  PV         VG  Fmt  Attr PSize   PFree 
  /dev/sda       lvm2 ---   40,02t 40,02t
  /dev/sdb   vg1 lvm2 a--  <54,57t     0 
  /dev/sdc   vg1 lvm2 a--   63,64t     0

pvdisplay – Display various attributes of physical volume(s)

--units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|EAll sizes are output in these units: human-(r)eadable with ‘<‘ rounding indicator, (h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalise to use multiples of 1000 (S.I.) instead of 1024. Custom units can be specified, e.g. –units 3M.
sudo pvdisplay
sudo pvdisplay --units T

Volume groups

vgdisplay – Display volume group information

sudo vgdisplay

vgs – Display information about volume groups

sudo vgs

vgextend – Add physical volumes to a volume group

$ vgextend vg1 /dev/sda
  Volume group "vg1" successfully extended

Logical volumes

lvdisplay – Display information about a logical volume

lvdisplay

Also gives the LV Path needed by lvextend.

lvcreate – create a logical volume in an existing volume group

lvcreate --name test --size 50G vm-disks

lvextend – Add space to a logical volume

# lvextend /dev/vg1/lvol0 -l +100%FREE
  Size of logical volume vg1/lvol0 changed from <118,21 TiB (30987514 extents) to <158,23 TiB (41478521 extents).
  Logical volume vg1/lvol0 successfully resized.

After extending the LV you still have to extend the partition (filesystem dependent).

Tasks

To monitor the activity of the different parts of a logical volume spanning on several physical volumes, check the monitoring page.

“Device /dev/sda excluded by a filter”

Zap the partition table using gdisk (https://ithero.eu/documentation/disk/).

Remove LVM from a disk

lvremove /dev/ceph-6e3e748c-b2bd-44c3-a9bd-f73d7c903bc9/osd-block-1fe9017e-419e-4b02-9876-e2c915f5df18
vgremove ceph-6e3e748c-b2bd-44c3-a9bd-f73d7c903bc9
pvremove /dev/vdb
lsblk
lsblk -fs