# System snapshots

LVM snapshots | archwiki. So you might wonder, why even bother with snapshots? Well, think of it as a system backup. There are few reasons for that:

~> rm -rf        # sometimes it happens by accident, you can delete the wrong file or folders recursively
~> chmod         # there is a chance that you will mess with root permissions
~> pacman -Syu   # arch has rolling releases and updating a kernel with all other 3d party libraries that you have installed, this could break your system despite this happens very rarely and on some machines it never happens at all; nevertheless there is still a chance that the next system update will break your system, so I warned you ;)

For all this cases and others, you can make preserve your system state as a snapshot, it uses CoW Copy-on-Write method that will save you system state when something changed. Its also possible to use a cron job: every day, every hour, etc.

WARNING

Problems with it will arise once you're dual-booting, because Windows does not support LVM. And keep in mind that you will be unable to access any LVM partitions from Windows. Nevertheless we can solve this disadvantage in other way.

# Setup

root@archiso ~ # vim /etc/systemd/system/mk-lvm-snapshots.service

TIP

vim could be substituted with nano

Create this service and adjust your VGs:

[Unit]
Description=make LVM snapshots
Requires=local-fs-pre.target
Wants=local-fs.target
DefaultDependencies=no
Conflicts=shutdown.target
After=local-fs-pre.target
Before=local-fs.target

[Install]
WantedBy=make-snapshots.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/lvcreate -L 10G -n snap-root -s /dev/vg0/root

TIP

You can create multiple ExecStart= , if you need to snapshot other partitions separated with ; and spaces.

sudo systemctl enable mk-lvm-snapshots.service