← Storage & LVM
Linux · Storage & LVM
How to create and manage an LVM snapshot in Linux
Create a point-in-time LVM snapshot for backups or a safe rollback point, then merge or remove it.
Take a point-in-time snapshot of a logical volume, for a consistent backup or a rollback point before a risky change. Run as root.
A snapshot needs free space in the volume group and grows as the origin changes; if it fills up it becomes invalid. Size it adequately and remove it when done, since snapshots slow writes to the origin.
# Create a 5G snapshot of an existing LV
sudo lvcreate -L 5G -s -n <lv>_snap /dev/<vg>/<lv>
# Mount it read-only to back it up
sudo mkdir -p /mnt/snap
sudo mount -o ro /dev/<vg>/<lv>_snap /mnt/snap
# Roll the origin back to the snapshot (merge; may need remount/reboot)
sudo umount /mnt/snap
sudo lvconvert --merge /dev/<vg>/<lv>_snap
# Or just discard the snapshot
sudo lvremove /dev/<vg>/<lv>_snapLinuxLVMSnapshot