Skip to main content
RunBook Academy

LinuxXVI · LVMSnapshots

LVM snapshots and rollback - the local safety net

Intermediate⏱ ~8 minbashlvcreatelvconvertmountumountlvremove

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

Not yet marked complete on this device.

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.
Configuration changetake snapshot
$ lvcreate -L 10G -s -n data-pre-deploy /dev/vg_data/data
Logical volume 'data-pre-deploy' successfully created

Verifying the change

Read-only / Safelvdisplay
$ 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              available

Rolling back

Data-loss riskrollback via merge
$ umount /data; lvconvert --merge /dev/vg_data/data-pre-deploy

Cleaning up

Read-only / Safelv_time
$ 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:00

Knowledge check

Knowledge check · 3 questions

  1. Q1. What does lvconvert --merge do to an LVM snapshot?

  2. Q2. LVM snapshots are safe to use on production databases without downtime.

  3. Q3. Which of the following are correct uses of LVM snapshots? Select all that apply.

Passing score: 75%. Answers are checked in this browser.