Poncho

Ⓐ&♥

LVM

shrink lvm

# Unmount the filesystem and check its' LV
umount /mnt/foo
e2fsck -f /dev/mapper/vg0-foo

# Shrink ext4 and then the LV to the desired size
resize2fs -p /dev/mapper/vg0-foo 40G
lvreduce -L 40G /dev/mapper/vg0-foo

# Before continuing, run e2fsck. If it bails because the partition
# is too small, don't panic! The LV can still be extended with
# lvextend until e2fsck succeeds, e.g.:
# lvextend -L +1G /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo

# Resize the filesystem to match the LVs size, check and mount it
resize2fs -p /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
mount /mnt/foo

expand lvm

umount /mnt/bar

# Extend the LV to use all free space
lvextend -l +100%FREE /dev/mapper/vg0-bar
e2fsck -f /dev/mapper/vg0-bar

# Resize the partition to fill the LV
resize2fs -p /dev/mapper/vg0-bar
e2fsck -f /dev/mapper/vg0-bar
mount /mnt/bar

expand luks encrypted filesystems

umount /crypto
e2fsck -f /dev/mapper/crypto
cryptsetup luksClose crypto
lvextend -L +100M /dev/cryptovg/crypto
cryptsetup luksOpen /dev/cryptovg/crypto crypto
cryptsetup -v resize crypto
e2fsck -f /dev/mapper/crypto
resize2fs /dev/mapper/crypto
e2fsck -f /dev/mapper/crypto
mount /dev/mapper/crypto /crypto

Snapshot

Taking A Snapshot

sudo lvcreate --size 1G -s -n snapshot_lv /dev/vgroup/original_lv

Mounting A Snapshot

sudo mkdir /mnt/snap
sudo mount /dev/ubuntu/mysnap /mnt/snap
cd /mnt/snap

Reverting/Merging To The Snapshot's State

lvconvert --merge /dev/vgroup/snapshot-lv

Removing A Snapshot

sudo lvremove /dev/vgroup/snapshot_lv_name