0

I want to be able to rollback BTRFS snapshots on Debian 12.

I have installed my root file system on BTRFS.

enter image description here

My /etc/fstab looks like this:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=ea4000b8-0ee1-4fa6-bd0b-0870b24de7d8 /               btrfs   defaults,subvol=@rootfs 0       0
# swap was on /dev/sda5 during installation
UUID=7307b68b-629b-48d9-b692-5e1c9371f09e none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

First I install snapper.

apt update
apt install btrfs-progs snapper

Next I create snapper configuration, create snapper snapshot and then try reverting to that stanpshot:

root@debian-btrfs:~# snapper -c myconfig create-config /
root@debian-btrfs:~# snapper list-configs
Config   | Subvolume
---------+----------
myconfig | /
root@debian-btrfs:~# echo "before snapshot" > test.txt
root@debian-btrfs:~# snapper -c myconfig create
root@debian-btrfs:~# echo "after snapshot" > test.txt
root@debian-btrfs:~# snapper -c myconfig list
 # | Type   | Pre # | Date                             | User | Cleanup | Description | Userdata
---+--------+-------+----------------------------------+------+---------+-------------+---------
0  | single |       |                                  | root |         | current     |
1  | single |       | Sat 03 May 2025 04:03:11 PM EEST | root |         |             |
root@debian-btrfs:~# snapper -c myconfig rollback 1
Cannot detect ambit since default subvolume is unknown.
This can happen if the system was not set up for rollback.
The ambit can be specified manually using the --ambit option.

I tried --ambit as it suggested:

root@debian-btrfs:~# snapper --ambit classic -c myconfig rollback 1
Ambit is classic.
Creating read-only snapshot of current system. (Snapshot 2.)
Creating read-write snapshot of snapshot 1. (Snapshot 3.)
Setting default subvolume to snapshot 3.

That seemed to have worked but when I check my test file I can see that it did sill not rollback since it says after snapshot:

root@debian-btrfs:~# cat test.txt
after snapshot

But I expect it to say before snapshot because that is what is inside snapshot 1:

root@debian-btrfs:~# cat /.snapshots/1/snapshot/root/test.txt
before snapshot

Questions:

  1. What do I do wrong that I need --ambit classic option?
  2. Why wasn't test.txt reverted to previous version?
2
  • I don't know snapper but I do know Btrfs a little and I think whatever snapper does, you need to mount / anew to see it has been reverted. Probably not (easily) possible from the running OS, but if snapper does its job right then a reboot should do this. Have you rebooted? Commented May 3 at 14:42
  • Turns out that rolling back root file systems is a bit more complicated that I thought it would be at first. Here is a tutorial with screenshots how to do it: github.com/david-cortes/snapper-in-debian-guide. One thing to remember is that creating subvolumes is important to be able to restore snapshots therefore do not skip creating subvolumes that this tutorial asks you to create or you may run into difficulties later when restoring snapshots. Also keep in mind that Debian likes to name root @rootfs but Snapper or Timeshift expect just @ Commented May 10 at 17:37

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.