1

I'm learning to do backup database with LVM snapshot. While on it, I found some behavior of snapshot that I can't get it.

Here is my setup: 1 Physical Volume and Volume Group from it with size 1.95T (cl). 3 Logical Volume from vg-cl. LV root: 70G LV home: 1.5T LV swap: 8G lvs-setup

Then I create a snapshot volume, origin is LV home with this command: lvcreate --size 100M --snapshot --name snap /dev/cl/home

After that, I mount the snapshot volume to a directory. mount -o nouuid /dev/cl/snap /snap

Then df -h, showing both /dev/mapper/cl-home & /dev/mapper/cl-snap have size 1.5T.

I'm assuming cl-snap have same size with cl-home is normal. But wonder why it able to mount, since my physical volume max only 2T? Where is extra 1T come from? df-h

1 Answer 1

0

Snapshots are "copy-on-write", i.e. they share initial data with the original. (Not just on LVM, but also on most other systems that have snapshots or "shadow copies".)

This means that the original 1.5T data seen in "cl-snap" is still taken from your original "cl-home" volume – only the changes are stored by the snapshot. If you snapshot a 1.5T logical volume on a 2.0T physical volume, you would probably run out of space after making ~0.5T worth of changes.

2
  • After making ~0.5T worth of changes on "cl-snap", then will have an error? Commented Apr 26, 2023 at 23:28
  • @SamuelZhen: For LVM specifically, according to what posts I've found, the system would just automatically discard the snapshot when that happened. LVM snapshots are supposed to be very temporary – make a snapshot, run the backup job, drop the snapshot. (In contrast, e.g. with Btrfs or ZFS file-level snapshots, you would receive a regular "file system full" error.) Commented Apr 27, 2023 at 5:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .