Creating Logical Volume Snapshots

To create a snapshot of an existing logical volume, use lvcreate --snapshot, for example:

sudo lvcreate --size 500m --snapshot --name mylv-snapshot myvg/mylv
Logical volume “mylv-snapshot” created

You can mount and modify the contents of the snapshot independently of the original volume. Or, you can preserve the snapshot as a record of the state of the original volume at the time that the snapshot was taken.

The snapshot usually occupies less space than the original volume, depending on how much the contents of the volumes diverge over time. In the example, assume that the snapshot only requires one quarter of the space of the original volume. To calculate how much data is allocated to the snapshot, do the following:

  1. Use the lvs command.

  2. From the command output, check the value under the Snap% column.

    A value approaching 100% indicates that the snapshot is low on storage space.

  3. Use lvresize to either grow the snapshot or reduce its size to save storage space.

To merge a snapshot with its original volume, use the lvconvert --merge command. For example, the following merges the myvg/mylv-snapshot back into myvg/mylv:
sudo lvconvert --merge myvg/mylv-snapshot

To remove a logical volume snapshot from a volume group, use the lvremove command as you would for a logical volume, for example:

sudo lvremove myvg/mylv-snapshot

For more information, see the lvcreate(8) and lvremove (8) manual pages.