What is a snapshot?
snapshots are a facility which makes us able to create a new block device (like /dev/My-vg/snapshot_home ) which presents an exact copy of a logical volume frozen at some point in time. After we are done with what we are doing, we can simply remove the snapshot device.
Important to note while creating a snapshot:
While creating a snapshot we should consider enough disk space for our changes, if our changes makes snapshot device space full then it will be dropped and becomes unusable.
When to use it?
Some times we need to install an application or run a program we don't know what it's going to happens or in any situations that makes any changes to our files we can setup a snapshot device, if we were not happy with the change we can simply make everything same as the time we created our snapshot.
How to create a snapshot
To create a snapshot we can use a command like:
lvcreate -s -n home_snap -L 1G /dev/My-vg/home
-s
is for snapshot
-n home_snap
is the name of our new logical volume (snapshot device)
L 1G
is the size of our snapshot, so it supports to 1GB of changes (remember the above important note).
/dev/mapper/my--vg-home
is the logical volume that I want to create a snapshot of.
then use sudo lvs
to get a list of your logical volumes you should see your newly created snapshot device.
Note that you should have enough free space on your volume group to create a new snapshot.
sources: 1, 2