vgs - Display information about volume groups (free space etc.) lvs - Display information about logical volumes lvdisplay - display attributes of a logical volume lvremove - remove a logical volume
install
apt-get intall -y lvm2
create volume group
pvcreate /dev/md1 vgcreate vg2 /dev/md1 pvdisplay
create lvm volume
lvcreate --name VOLUME_NAME --size 4G vg2 # lvcreate -n NAME -l 100%FREE vg0 mkfs.ext3 /dev/vg2/VOLUME_NAME
renamee lvm
lvrename /dev/vg01/mx-swap /dev/vg01/mx-swap.org
Delete
# delete all VG vgs --noheadings -o vg_name | xargs -L1 vgremove -y # delete all PV pvs --noheadings -o pv_name | xargs -L1 pvremove /dev/nvme0n1 --force --force -y
Activatie volume group
vgchange -ay <VG_NAME>
Disable all LVMs
vgchange -an
Restore LVM
pvcreate --uuid "5a3727b0-8d1c-4f41-b0fe-eea17baac244" --restorefile /etc/lvm/archive/vg1_00005.vg /dev/sda1 vgcfgrestore vg1
Clear VG
lvchange -an LV_NAME vgchange -an VG_NAME
Thin pool
lvcreate -L 250G --thinpool kvm system https://www.tecmint.com/setup-thin-provisioning-volumes-in-lvm/
Resize LV and filesystem
lvresize -r -L 120G /dev/mapper/containers_kvm--stage
Restart LVM
systemctl stop lvm2-lvmetad rm /run/lvm/* rm /etc/lvm/{archive,backup}/* systemctl start lvm2-lvmetad
Remove PV
vgremove /dev/mapper/data pvremove /dev/sdb
Resize swap
swapoff -a lvresize /dev/system/swap -L 64G mkswap /dev/system/swap swapon -a
Links
http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
http://www.debian-administration.org/article/A_simple_introduction_to_working_with_LVM
http://www.linuxhaven.de/dlhp/HOWTO-test/DE-LVM-HOWTO-2.html