LVM snapshots and rollback - the local safety net
What you'll learn
- Take an LVM snapshot before a risky change
- Roll back by merging the original LV back to the snapshot
- Monitor and clean up snapshot metadata
- Avoid the common snapshot pitfalls
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
LVM snapshots are the cheap, instant way to roll back local changes. Use them before a deployment, a database migration, or any other risky operation. This lesson shows the workflow.
When to take a snapshot
Take an LVM snapshot before:
- A database migration or schema change.
- A deployment to production.
- An OS upgrade (if you must do it on a live system).
- Any operation that changes a lot of data on the LV.
$ lvcreate -L 10G -s -n data-pre-deploy /dev/vg_data/dataLogical volume 'data-pre-deploy' successfully createdVerifying the change
$ lvdisplay /dev/vg_data/data-pre-deploy | head -10--- Logical volume ---
LV Path /dev/vg_data/data-pre-deploy
LV Name data-pre-deploy
VG Name vg_data
LV UUID xyz...
LV Write Access read/write
LV Snapshot status active destination for data
LV Status availableRolling back
$ umount /data; lvconvert --merge /dev/vg_data/data-pre-deployCleaning up
$ lvs -o+lv_time LV VG Attr LSize
data vg0 -wi-ao---- 100.00g
snap-old vg0 swi-aos--- 5.00g 2026-01-01 10:00:00Knowledge check
Knowledge check · 3 questions
Q1. What does lvconvert --merge do to an LVM snapshot?
Q2. LVM snapshots are safe to use on production databases without downtime.
Q3. Which of the following are correct uses of LVM snapshots? Select all that apply.
Passing score: 75%. Answers are checked in this browser.