# creating lv
pvcreate /dev/vda1
vgcreate vg0 /dev/vda1
lvcreate -l100%FREE vg0 -n lv0
mkfs.ext4 /dev/vg0/lv0
mount /dev/mapper/vg0-lv0 /data

# extending vol (virtual disk extend)
ls /sys/class/scsi_device/
echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan
fdisk /dev/vda # d 2 n p 2 enter enter w 
partx -u /dev/vda
pvresize /dev/vda2
lvextend -r -l +100%FREE /dev/vg0/lv0

# extending vol (adding new disk)
gdisk /dev/sdb # n p 1 enter-enter w
partx -a /dev/sdb
pvcreate /dev/sdb1
vgextend vg0 /dev/sdb1
lvextend -l +100%FREE /dev/vg0/lv0
resize2fs /dev/vg0/lv0
LVM moving extents to another disk
pvs -o+pv_used

pvcreate /dev/sdd1
vgextend myvg /dev/sdd1
pvs -o+pv_used

pvmove /dev/sdb1 /dev/sdd1
pvs -o+pv_used

vgreduce myvg /dev/sdb1
LVM thin pools
LVM snapshots (for backup as example)
# !ATTENTION! All block changes are written to original volume and old ones are copied to snapshot volume!
# Be careful! Don't let free space to end! USe `lvs` to control.
# 1. If free space ends in snapshot, it gets invalid and lost.
# 2. Do not leave snapshots! Delete them! IO degradation is VERY high while they exist!

# volume group should have free space

# if none - shrink it (in example we have 30GB used of 50GB disk = shrink to 40GB, 10GB for snapshot)
df -h
umount /dev/cl/data
e2fsck -fy /dev/cl/data
resize2fs /dev/cl/data 39G
lvreduce -L 40G /dev/cl/data
resize2fs /dev/cl/data
e2fsck -fy /dev/cl/data
mount /dev/cl/data /data

# check free space again

# create snapshot
lvcreate -l100%FREE -s -p r -n snapshot /dev/cl/data
lvcreate -l100%FREE --snapshot --permission r --name snapshot /dev/cl/data

# mount
mount -o ro /dev/cl/snapshot /mnt/backup

# control used space in snapshot

# ====== gzip backup from snapshot ============================
tar -czpf /backup/backup-from-snapshot.tar.gz /mnt/backup

# ====== unmount and del snapshot =============================
umount /mnt/backup
lvremove -f /dev/cl/snapshot
Automated resize

# extend root volume script

echo d # Delete partition
echo 2 # Delete partition #2
echo n # Add a new partition
echo p # Primary partition
echo 2 # Partition number
echo   # First sector (Accept default: 1)
echo   # Last sector (Accept default: varies)
echo w # Write changes
) | fdisk /dev/sda

partx -u /dev/sda
pvresize /dev/sda2
lvextend -r -l +100%FREE /dev/centos/root

exit 0