Skip to content

LVM thin-pool snapshots for backup

Using LVM thin snapshots to take consistent, low-overhead point-in-time copies of mounted filesystems for backup tools to read, and the pitfalls of the thin-pool model in production.

LVM thin-pool snapshots are the standard way to get a consistent, mountable point-in-time copy of an ext4 or xfs filesystem on Linux without taking the source filesystem offline. They are the underlying primitive a lot of backup tools use when they need a stable view of a running database directory: take a snapshot, mount it read-only, run the backup against the snapshot, drop the snapshot. This article covers the thin-pool model, the snapshot lifecycle, and the operational care thin pools require — the difference between LVM thick and thin snapshots is one of the easier ways to corrupt data on a production server.

How to verify

A working thin-pool setup looks like:

lvs -o name,vg_name,attr,size,data_percent,metadata_percent
vgs
lvdisplay /dev/<vg>/<thin-pool>
dmsetup status | grep thin
mount | grep <lv>

The attr column for a thin LV starts with V (Vwi-...) and for a thin pool starts with t (twi-...). If you see s (snapshot of a thick LV), you are looking at the classic LVM snapshot — different beast, very different operational properties.

What’s happening

LVM thin provisioning works at the device-mapper layer. A “thin pool” is a block device that holds data and metadata for multiple “thin volumes” (TLVs). Each TLV is a sparse block device whose extents are allocated from the pool on first write. Snapshots in this model are just additional TLVs that share extents with their origin until either side is written to — copy-on-write at the block layer.

The mechanics:

  • A snapshot LV is created from a thin LV with lvcreate -s. Initially it shares 100% of its blocks with the source.
  • Reads from the snapshot go to the shared blocks. Writes (to either side) allocate new blocks from the pool, divergence begins.
  • Multiple snapshots can exist simultaneously; they all share blocks until they diverge.
  • Dropping a snapshot frees only the blocks unique to it.

Contrast with classic LVM snapshots (thick): those allocate a fixed-size CoW area at creation; if writes to the origin exceed that area, the snapshot is invalidated. Thin snapshots have no fixed size — they consume pool space dynamically.

The risk: the pool can fill. If the pool runs out of data space, all thin LVs go read-only. If the pool runs out of metadata space, the pool itself goes offline. This is the single most important operational fact about thin provisioning.

The procedure

  1. Take a snapshot of the data filesystem. The source LV must be a thin LV (in a thin pool), not a thick LV.

    lvcreate -s -n data-snap-2026-06-01 vg0/data
    lvs vg0
  2. Mount the snapshot read-only. The snapshot is a separate block device with the same filesystem contents.

    mkdir -p /mnt/snap
    mount -o ro,nouuid /dev/vg0/data-snap-2026-06-01 /mnt/snap
    # xfs requires -o nouuid because the UUID matches the original
  3. Run the backup against the snapshot mount.

    restic -r s3:... backup --exclude-caches /mnt/snap
    # or borg, rsync, tar — anything that reads files
  4. Unmount and drop the snapshot.

    umount /mnt/snap
    lvremove -f vg0/data-snap-2026-06-01
  5. Wrap in a script:

    #!/usr/bin/env bash
    set -euo pipefail
    ts=$(date +%Y%m%dT%H%M%S)
    snap=vg0/data-snap-$ts
    lvcreate -s -n data-snap-$ts vg0/data
    mkdir -p /mnt/snap-$ts
    trap "umount /mnt/snap-$ts 2>/dev/null; lvremove -f $snap; rmdir /mnt/snap-$ts" EXIT
    mount -o ro,nouuid /dev/$snap /mnt/snap-$ts
    restic -r s3:... backup /mnt/snap-$ts
  6. Monitor pool space. This is non-optional.

    # Alert when data % > 80
    lvs -o name,data_percent,metadata_percent --noheadings --units B | \
      awk '$2+0 > 80 || $3+0 > 80 { print }'

Common pitfalls

  • Pool full. The single worst failure mode. Configure lvm.conf’s thin_pool_autoextend_threshold = 70 and thin_pool_autoextend_percent = 20 so the pool grows automatically. Even better, monitor it and alert before you hit the threshold.
  • Metadata full. Less common but catastrophic — the pool itself goes offline. Size metadata generously at pool creation (--poolmetadatasize 1G for pools larger than 200 GB).
  • xfs UUID collision. mount -o nouuid is required to mount the snapshot of an xfs filesystem while the original is also mounted. Without it the mount fails with “filesystem already mounted”.
  • Database consistency. A snapshot is crash-consistent, not application-consistent. For MySQL/PostgreSQL backups via LVM snapshot, you must FLUSH TABLES WITH READ LOCK (MySQL) or pg_start_backup() (PostgreSQL) around the lvcreate -s call — see MySQL snapshot consistency and PostgreSQL snapshot consistency.
  • Snapshot lifetime. Long-lived snapshots accumulate divergence and consume pool space. Use snapshots as a brief read window for the backup tool, not as a long-term retention mechanism.
  • Boot from a snapshot LV. Possible with the right initramfs config but fragile. Treat snapshots as backup-time artifacts, not bootable rollback points (use snapper + btrfs for that pattern).

In the engagements we run, LVM thin snapshots are the consistency primitive under file-level backup tools when the data directory is on ext4 or xfs. We pair them with the database quiesce hooks and a backup tool (restic, BorgBackup, pgBackRest) that reads from the snapshot mount. The thin pool itself becomes a monitored resource alongside CPU, memory, and disk — because a forgotten 100%-full thin pool is one of the worst outages we’ve seen. The way we operate this kind of stack is in Managed Operations.