Lesson 3.70: LVM snapshots before risky changes
Some changes rewrite data in place: a database migration, a vendor's upgrade script, a bulk edit. If they go wrong, restoring from last night's backup loses today's work and takes time. An LVM snapshot freezes a logical volume's state in seconds, using only the space of the blocks that change afterwards; if the change fails you merge the snapshot back and the volume returns to that moment. In the lab you snapshot /srv/data before a vendor's catalog migration, watch the migration break the catalog and fill the snapshot, and roll back.
16 min
You will learn to
- Explain copy-on-write snapshots
- Create a snapshot with lvcreate -s
- Read snapshot usage (Data%) in lvs
- Roll back with lvconvert --merge
- Know why a snapshot isn't a backup
Key terms
- Snapshot
- A logical volume that preserves another volume's contents at one moment.
- Copy-on-write
- Before a block of the origin is overwritten, its old content is copied into the snapshot.
- Origin
- The volume a snapshot was taken of.
- Data%
- How full a snapshot's space is; at 100% the snapshot becomes invalid.
- Merge
- Writing a snapshot back onto its origin: a rollback.
← Wildcards and path expansion · All lessons · Auditing the PAM stack →