Table of Contents

LVM - Logical volume manager

pvcreate /dev/sdX
vgcreate vg0 /dev/sdX

Thin volumes

It's better to use thin provisioned volumes to have snapshots comes for free (copy on write) and are better for SSDs

Thin provisioned volumes are created from a “pool”.

lvcreate -L 100G --thin vg/thin

Then create volume within the pool:

lvcreate -n myvol -T vg/thin -V 10G

Then to take a snapshot:

lvcreate -kn -n myvol_snap -s vg/myvol

To restore the snapshot

lvremove vg/myvol
lvrename vg/myvol_snap vg/myvol

Non-Thin volumes

Create a volume:

lvcreate -L10G -n myvol vg

Take a snapshot, you MUST give a size here, the diff between snapshot and original volume will be stored here. In case of this space being consumed, the snapshot is corrupted :/

lvcreate -L2G -s -n myvol_snap vg/myvol

To restore the snapshot

lvconvert --merge vg/myvol_snap

Backup using lvm snapshots