Skip to content

Consistent Backups with LVM Snapshots

How to freeze a logical volume with lvcreate --snapshot, mount it read-only, back it up with rsync or tar, size the copy-on-write area correctly, and remove the snapshot — plus why a snapshot is not a backup.

An LVM snapshot freezes a logical volume at a single instant so you can back up its contents while the application keeps writing. You create the snapshot with lvcreate --size 5G --snapshot --name db_snap /dev/vg0/db, which gives you a new block device that presents the origin exactly as it looked at that moment. You mount that device read-only, copy it with rsync or tar, then delete it with lvremove. The catch is that a classic snapshot is copy-on-write: it only stores the blocks the origin overwrites while the snapshot exists, so it has a fixed size budget and gets dropped if the origin changes more than the snapshot can hold. And a snapshot is not a backup — it lives in the same volume group, on the same disks, and dies with them. This guide covers sizing, the filesystem-freeze question, thin versus thick snapshots on current Linux, and how to end up with a copy you can actually restore.

What you’ll accomplish

  • Create a point-in-time LVM snapshot of a live logical volume without stopping the application.
  • Size the copy-on-write area so the snapshot survives the whole backup window.
  • Mount the snapshot read-only and copy it with rsync or tar to a real backup destination.
  • Remove the snapshot cleanly and monitor its fill percentage while it exists.
  • Tell crash-consistent from application-consistent, and know when a snapshot is the wrong tool.

Prerequisites

  • A volume group with free extents. A classic snapshot needs unused space in the same VG as the origin. Confirm free space with vgs before you start — the snapshot cannot borrow from the origin.
  • The logical volume you want to snapshot, and its device path, usually /dev/vg0/<lv> or /dev/mapper/vg0-<lv>.
  • Root or sudo. All the lvcreate, mount, and lvremove commands need it.
  • Knowing whether you are on a thin pool or a classic (thick) LV. Thin snapshots are allocated from a shared thin pool and behave differently — no fixed COW size, but the pool itself can fill. lvs -o name,pool_lv shows which LVs belong to a pool.
  • A way to quiesce the application if it is a database. A raw snapshot of open database files is only crash-consistent. For an application-consistent copy you flush and briefly lock the app, or use its own hot-backup tool, before the snapshot.

How it works

A classic LVM snapshot is copy-on-write. At the instant you run lvcreate --snapshot, the origin LV is untouched and the snapshot is nearly empty. The snapshot device presents the same data as the origin, because it reads through to the origin for every block that has not changed. The moment the origin is about to overwrite a block, LVM first copies the original block into the snapshot’s own space, then lets the write proceed on the origin. That is the copy-on-write step: the snapshot accumulates only the pre-change versions of blocks that the origin modifies while the snapshot exists.

LVM copy-on-write snapshot showing the origin LV, a snapshot store that captures only changed blocks, and the backup read path

Two consequences follow directly. First, the snapshot fills as the origin changes, not as the origin’s total size. A busy origin can burn through a small snapshot in minutes; a quiet one can run for hours on the same allocation. If the snapshot fills to 100 percent, LVM marks it Invalid and drops it — every read of the snapshot device then fails, and any in-progress backup is ruined. So you size the COW area for the volume of writes expected during the backup window, not for the size of the data.

Second, a snapshot taken without coordinating the application is only crash-consistent: it captures the on-disk state as if the machine had lost power at that instant. A journalled filesystem replays cleanly from that, and many applications recover, but a database mid-transaction may need its own recovery, and application-level buffers that were never flushed to disk are simply absent. An application-consistent snapshot means you flushed and quiesced the app first, so the frozen state is one the application agrees is coherent. See application-consistent vs crash-consistent backups for where that line sits.

Step-by-step

1. Check free space in the volume group. The snapshot’s COW area is allocated from free extents in the same VG. Confirm you have room.

sudo vgs

Expected output — VFree shows enough space for the snapshot you plan to create:

  VG    #PV #LV #SN Attr   VSize    VFree
  vg0     1   3   0 wz--n- <200.00g  40.00g

2. Quiesce or flush the application (databases only). For a plain filesystem you can usually skip this. For a database, put it into a consistent state first — for example flush and lock a MySQL instance, or briefly stop the service. If you cannot quiesce the app, at minimum freeze the filesystem so the snapshot lands on a clean boundary:

sudo fsfreeze --freeze /var/lib/mysql

Freeze only for the seconds it takes to create the snapshot in the next step, then thaw immediately with sudo fsfreeze --unfreeze /var/lib/mysql. A frozen filesystem blocks all writes to it, so never leave it frozen.

3. Create the snapshot. Give it a size (the COW budget), the --snapshot flag, a name, and the origin device.

sudo lvcreate --size 5G --snapshot --name db_snap /dev/vg0/db

Expected output:

  Logical volume "db_snap" created.

If you froze the filesystem in step 2, thaw it now — the snapshot already captured the frozen state.

4. Verify the snapshot exists. lvs lists it with its origin and current data usage.

sudo lvs

Expected output — db_snap shows its Origin as db and a low Data%:

  LV      VG   Attr       LSize   Pool Origin Data%
  db      vg0  owi-aos--- 100.00g
  db_snap vg0  swi-a-s---   5.00g      db     0.41

5. Mount the snapshot read-only. Back up from the snapshot, never from the origin. Read-only mounting also avoids any filesystem replay writing into the snapshot.

sudo mkdir -p /mnt/snap
sudo mount -o ro /dev/vg0/db_snap /mnt/snap

There is no output on success. Confirm with mountpoint /mnt/snap, which prints /mnt/snap is a mountpoint. On XFS you may need mount -o ro,nouuid because the snapshot carries the same filesystem UUID as the origin.

6. Back up the snapshot contents. Copy the mounted data to a real destination — another host, an object store, or a separate disk. With rsync:

sudo rsync -aAX --numeric-ids /mnt/snap/ backup@storage:/backups/db/

Or as a single compressed archive with tar:

sudo tar -czf /backups/db-2026-07-21.tar.gz -C /mnt/snap .

Both read the frozen point-in-time view while the origin keeps serving live traffic.

7. Unmount the snapshot. Once the copy is complete and verified, unmount it.

sudo umount /mnt/snap

8. Remove the snapshot. Delete it as soon as the backup is done. A lingering snapshot keeps paying the copy-on-write cost on every origin write and will eventually fill.

sudo lvremove -f /dev/vg0/db_snap

Expected output:

  Logical volume "db_snap" successfully removed.

9. Monitor fill percentage while a snapshot is live. For long backups, watch how full the COW area is getting. If it climbs toward 100 percent you need a bigger snapshot next time.

sudo lvs -o +snap_percent

Expected output — Snap% well under 100 means the snapshot is healthy:

  LV      VG   Attr       LSize  Origin Data%  Snap%
  db_snap vg0  swi-aos---  5.00g db     12.30  12.30

Validate it works

  • The snapshot stayed under 100 percent. During and after the backup, sudo lvs -o +snap_percent should show Snap% comfortably below 100. If it hit 100 the snapshot went Invalid (Attr shows an I) and the backup is not trustworthy — enlarge the COW area and rerun.
  • The archive is intact. Verify the copy, not just its existence. For a tar archive, tar -tzf /backups/db-2026-07-21.tar.gz >/dev/null && echo ok reads every entry and reports ok if the archive is not truncated. For an rsync copy, a second rsync -aAXn --numeric-ids dry run against the snapshot should report no differences.
  • The origin is unaffected. The application never saw the snapshot; sudo lvs should show the origin db unchanged in size and still active (Attr beginning owi-a). Removing the snapshot leaves the origin exactly as it was.
  • A restore actually works. The only real proof is restoring the copy elsewhere and starting the application against it. See database backup verification for a repeatable check.

Troubleshooting

Snapshot went Invalid and reads fail. The COW area filled to 100 percent and LVM dropped the snapshot; lvs shows an I in the Attr field and every read errors. The backup captured before the drop is incomplete. Recreate the snapshot with a larger --size sized for the writes during your backup window, and consider running the backup at a quieter hour.

No free extents in the volume group. lvcreate fails with a message about insufficient free space. A classic snapshot cannot allocate from the origin — it needs free extents in the same VG. Check with vgs; free space by extending the VG with another physical volume, shrinking another LV, or removing an old snapshot.

Database backup is inconsistent. You snapshotted a live database without flushing it, so the copy is only crash-consistent and the database needs recovery on restore — or worse, unflushed writes are missing. Quiesce the database (flush and lock, or stop it) or use its own hot-backup tool for the seconds around lvcreate, and fsfreeze the filesystem if you cannot pause the app.

Thin snapshot behaves differently than expected. A thin snapshot has no --size and no fixed COW area — it draws from the shared thin pool. It will not go Invalid on its own, but if the pool fills, every volume in that pool stalls or errors, which is worse. Monitor the pool with lvs -o name,data_percent,metadata_percent and set thin_pool_autoextend_threshold so the pool grows before it fills.

Heavy write load slows down during the snapshot. Every origin write while a snapshot exists triggers a copy-on-write of the old block first, so write latency rises. This is expected; keep the snapshot’s lifetime short — create it, back it up, remove it — rather than leaving it around, and schedule backups off peak.

Leftover snapshot is filling the disk. A snapshot that was never removed keeps accumulating changed blocks and will eventually go Invalid or exhaust the VG. List snapshots with sudo lvs -o +snap_percent, confirm nothing is still reading from it, and remove it with lvremove -f.

When this is the wrong approach

If your filesystem already does copy-on-write snapshots natively — ZFS or Btrfs — use those instead of layering LVM underneath. They snapshot at the filesystem level, integrate with the data’s own consistency, and do not carry a separate fixed COW area to size. The Btrfs snapshot strategy for production servers covers that model.

If you are backing up a database, prefer its own hot-backup tool — pg_basebackup, mysqldump, mariabackup, mongodump — which produces an application-consistent copy without freezing the whole filesystem. An LVM snapshot is a good foundation underneath such a tool, but it is not a substitute for one.

Most importantly, a snapshot is not a backup destination. It sits in the same volume group, on the same disks, and disappears if that storage fails, is deleted, or is corrupted. The snapshot only buys you a consistent instant to copy from; the copy must land somewhere else — ideally offsite and immutable — to count as a backup. Use the snapshot to read from, and rsync or tar to a separate location.

The authoritative reference is the lvcreate(8) manual page, which documents the --snapshot, --size, and thin-pool options in full.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.