Yes, there is a very good way to make restore points using btrfs in Ubuntu.
Standard Ubuntu installation with btrfs
uses subvolumes @
for /
and @home
for /home
.
If you have installed Ubuntu in the default way with these subvolumes, then you can easily make restore points for /
and /home
separately.
You can check if you have these subvolumes by running
sudo btrfs list /
Let's assume that the partition with Ubuntu is /dev/sda1
.
Make a snapshot of your /
by running.
sudo mount /dev/sda1 /mnt
sudo btrfs sub snap /mnt/@ /mnt/@_backup
sudo umount /mnt
Now you can safely amend your data on /
(not including /home
). You can install or delete any packages, or do whatever you want.
To restore to the previous state you will need to boot from a LiveUSB and rename subvolumes.
sudo mount /dev/sda1 /mnt
sudo mv /mnt/@ /mnt/@_broken
sudo mv /mnt/@_backup /mnt/@
sudo umount /mnt
Now you can boot into the original system state.
If you are sure that you do not need the "broken" subvolume any more, you can delete it this way:
sudo mount /dev/sda1 /mnt
sudo btrfs sub del /mnt/@_broken
sudo umount /mnt
The same way you can make restore points for /home
.
You can have some other subvolumes if you installed not a default way. But you can always make snapshots of any subvolumes the same way.
A useful example:
Before you upgrade Ubuntu to a newer release, make snapshots of /
and probably /home
. The latter is not very important in most cases.
If something goes wrong during or after the upgrade you can always return to the old release.
You can keep old snapshots for any time if you have enough disk space.
I upgraded this way some computers from 14.04 to 16.04 and keep the 14.04 snapshots in case there are some problems with 16.04. It takes a minute to boot into 14.04 this way.
You can also setup grub a way that you can boot into one or another snapshot using grub menu. But it is probably a topic for another question.