Skip to content

Linux - LVM

Globals

Install LVM:

yum install lvm2

Config file:

/etc/lvm/lvm.conf

Archive path which contain all previous lvm map:

/etc/lvm/archive
# Ex of file: vg_data_00002-1038365342.vg

Commands

Logical Volume (LV)

LV detail:

lvdisplay -v {lv-path}
# Ex: lvdisplay -v /dev/Debian/lv_dynatrace

Display all lv:

lvs
lvscan

Extend FS:

lvextend -L +{size} {lv-path} -r
# Ex: lvextend -L +2G /dev/vg_data/lv_data -r

Create LV with max size available:

lvcreate -l 100%FREE -n {lv} {vg}
# Ex: lvcreate -l 100%FREE -n lv_tempdb vg_data

List LV by devices:

lvs -a -o +devices

Delete PV:

pvremove {pv-path}
# Ex: pvremove /dev/sdc

Volume Group (VG)

Disable VG:

vgchange -an {vg}

Enable VG:

vgchange -ay {vg}

List all LVs of a VG:

lvdisplay {vg}

Create VG:

vgcreate {vg} {pv-path} (-s {block-size})
# Ex: vgcreate vg_data /dev/sdb -s 128M

Remove PV of a VG:

vgreduce {vg} {pv-path}
# Ex: vgreduce vg_data /dev/sdc

Troubleshooting

Force refresh of metadata:

systemctl restart lvm2-lvmetad.service
Back to top