One of the reasons we created a second layer of LVM on top of DRBD was to provide filesystem snapshot capabilities. When we create a snapshot, all the files on a particular volume will appear static on that snapshot until one of the following two things happens:
- We destroy the snapshot.
- The changes to the source volume are larger than the space we reserved for the snapshot.
This is the primary reason we left 5 percent space unused within our PostgreSQL volume group. If we create a snapshot, up to 5 percent of the database can change before we have to remove it. For larger storage devices, this should give us a lot of time to perform emergency restores, create byte-stable backups, or any other operation that requires consistent data.
In this recipe, we'll learn how to properly allocate, use, and remove an LVM snapshot.