LVM Snapshots & Practical Use Cases

Linux Filesystems

Chapter 6 · LVM Snapshots & Practical Use Cases

fs1-5's own compare-table flagged LVM snapshots as "COW-based, distinct from Btrfs/ZFS's own." This chapter is that distinction, in full — plus the one real-world use case that makes LVM snapshots worth knowing well: safely backing up data that's actively being written to.

How LVM Snapshots Work — COW at the Block Layer, Not the Filesystem Layer

Btrfs and ZFS snapshots (fs1-3, fs1-4) are implemented inside the filesystem itself, which natively understands blocks being shared between a subvolume/dataset and its snapshots. LVM snapshots are a genuinely different mechanism, working one layer below the filesystem — the filesystem sitting on top has no idea a snapshot even exists.

Creating an LVM snapshot doesn't copy the volume. It creates a new, small logical volume that initially holds nothing, reserved purely to record changes made to the original after the snapshot point. When the original volume is written to, LVM first copies the block's old content into the snapshot volume before letting the write proceed — copy-on-write, but implemented as "move the old data out of the way," not Btrfs's more sophisticated multi-way block sharing. This means an LVM snapshot has to be sized in advance to hold however many changed blocks are expected during its lifetime — a real, practical difference from Btrfs/ZFS's own dynamically-growing snapshots.

Real Commands

lvcreate -L 5G -s -n mylv-snap /dev/myvg/mylv mount /dev/myvg/mylv-snap /mnt/snap # roll the origin back to the snapshot's point-in-time state lvconvert --merge /dev/myvg/mylv-snap # done with the snapshot — release its reserved space lvremove /dev/myvg/mylv-snap

-s marks the new logical volume as a snapshot of mylv; -L 5G reserves 5GB purely for the snapshot's own changed-block store — not a full copy of the original volume's size.

Why the Reserved Size Matters — Snapshot Overflow

Because LVM snapshots pre-allocate a fixed amount of space for tracking changed blocks, rather than growing dynamically the way Btrfs/ZFS snapshots effectively do, a snapshot that runs out of reserved space while the original keeps changing simply overflows — becoming invalid and unusable. This is a real, practical gotcha that needs active monitoring, not a one-time sizing decision that can be forgotten.

A Real Use Case — Safe Backups of a Live Database

dbsec1-8 covered backup security — encryption, tested restores, backups as a ransomware target. Here's the mechanical problem LVM snapshots solve underneath all of that: backing up a live, actively-written database file directly risks capturing an inconsistent, mid-write state — a backup that looks complete but is actually corrupted, because different parts of the file were captured at different moments while writes kept happening in between.

An LVM snapshot solves this cleanly. The snapshot itself is taken near-instantaneously, freezing the origin volume's exact state at that moment from the snapshot's own point of view — while the original keeps being written to completely normally, with essentially no downtime. The backup then reads from the frozen, unchanging snapshot at leisure, with a fully consistent view throughout, regardless of how long the backup itself takes or how much the live data changes in the meantime.

lvcreate -L 10G -s -n db-snap /dev/dbvg/dblv mount -o ro /dev/dbvg/db-snap /mnt/db-backup tar czf /backup/db-$(date +%Y%m%d).tar.gz /mnt/db-backup umount /mnt/db-backup lvremove /dev/dbvg/db-snap

The archive this workflow produces is exactly the kind of artifact dbsec1-8's own encryption-at-rest guidance should be applied to before it's stored anywhere long-term — this chapter solves the "how do I capture a consistent snapshot of live data" problem; dbsec1-8 already covers what happens to that snapshot once it's a backup file sitting in storage.

Space allocationLayerOverflow risk
Btrfs / ZFS snapshotDynamic, grows with actual changesInside the filesystem itselfNone — bounded only by overall pool space
LVM snapshotFixed, reserved at creation timeBlock layer, below the filesystemReal — exceeding reserved space invalidates the snapshot
Watch usage before it overflows
lvs shows each snapshot's current usage as a percentage of its own reserved space — checking this during a long-running backup or before extending a snapshot's lifetime is the practical way to avoid a silent overflow.
Size for the change volume, not the data volume
The -L size on an LVM snapshot needs to cover the total amount of data expected to change on the origin during the snapshot's entire lifetime — not the origin's total size. A heavily-written database left snapshotted for hours can overflow a snapshot that seemed generously sized, silently invalidating it and losing the point-in-time state it existed to preserve.

Hands-On Exercises

Exercise 1

Explain, using this chapter's own mechanism description, why an LVM snapshot needs a size reserved in advance, while a Btrfs or ZFS snapshot does not.

📄 View solution
Exercise 2

An administrator wants to back up a 200GB live database file that receives roughly 2GB of writes per hour, and plans to run the backup over a 6-hour window using an LVM snapshot. Recommend a reserved snapshot size and explain your reasoning.

📄 View solution
Exercise 3

Explain why backing up a live, actively-written database file directly (without a snapshot) risks producing a corrupted backup, and how the LVM snapshot workflow in this chapter avoids that risk.

📄 View solution

Chapter 6 Quick Reference

  • LVM snapshots implement COW at the block layer, below the filesystem — the filesystem has no idea a snapshot exists
  • A snapshot volume stores only changed blocks (the origin's old content, copied out before being overwritten), not a full copy
  • lvcreate -L <size> -s -n <name> <origin> — create a snapshot with a fixed reserved size
  • lvconvert --merge — roll the origin back to the snapshot's point-in-time state
  • Reserved space is fixed, not dynamic — exceeding it overflows and invalidates the snapshot
  • lvs — monitor snapshot usage percentage before it overflows
  • Real use case: freeze a consistent, point-in-time view of live data for a backup, with no downtime on the original
  • The resulting backup file is exactly what dbsec1-8's own encryption-at-rest guidance applies to