LVM Snapshots / Reverting
If you have your system partitioned using LVM, and you have a bit of space left on the volume group, you can create a copy on write snapshot of the filesystem. This lets you do potentially dangerous operations without worrying about your data: for instance, you can take a snapshot, install a package from an unstable release (possibly upgrading many of your system libraries at the same time), and then verify whether things are working properly or not. If they are working, you are good to go, and can just delete your snapshot. If they are not working, you can revert to the pre-snapshot state of the filesystem. If you have worked with virtual machines, you are probably already familiar with the concept of snapshots: this is the same idea, but applied to your real machine!
While there is a lot of options around LVM, this page only discusses the bare minimum needed to create, apply, and revert snapshots. For this, we assume you have a single volume group called 'vgsystem', on which your root file system is mounted on a logical volume called 'lvroot'.
To create a snapshot of your root partition, use the command
sudo lvcreate --size 10G -s -n lvroot_snapshot /dev/vgsystem/lvroot
The --size argument is how large the snapshot should be. This must be large enough to fully contain the difference of whatever file operations you are doing. For instance, if you are planning on downloading 1GB of files, extracting, and installing them, you should allocate at least 3 - 4 GB of space (1 GB for the download, plus room for the expanded files). It is better to be generous with this space: since in this use case we are not going to be keeping the snapshot long term, it is better to allocate 10GB to what ends up only needing 1GB, than the reverse.
Once you have performed the dangerous operations, if everything was successful and you want to keep your changes, you just need to remove the snapshot:
sudo lvremove /dev/vgsystem/lvroot_snapshot
The snapshot is removed, and the space you had allocated for it goes back to your volume group.
If you want to revert to how things were before the dangerout operations, you need to revert to the snapshot:
sudo lvconvert --merge /dev/vgsystem/lvroot_snapshot
Since we are doing this on the root filesystem, you will need to reboot to finish reverting.