Btrfs rollback error : Cannot detect ambit

hi

I wanted to rollback yesterday so in grub selected the option to boot readonly from a previous snapshot and in tty1 as root did a snapper rollback.
however I got the message :

Cannot detect ambit since default volume is unknown.
This can happen is the system was not set up for rollback.
The ambit can be specified manually using the --ambit option.

I got my previous situation back using snapper -v undochange 391 so no big worry.

I would however like to get it working as it should.

system was installed about half a year ago, clean install and I did select btrfs from the installer.
once into the system I checked and snapper list showed nothing, so I followed this guide: System recovery and snapshot management with Snapper | Reference | openSUSE Leap 15.5

snapper -c root create-config /
snapper -c root set-config "TIMELINE_CREATE=yes"

USE_SNAPPER to yes in /etc/sysconfig/yast2

and that has worked, hourly snaps and when zypper starts/ends snaps.

So I am not sure what is missing here.

fstab at this moment:

UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /                       btrfs  defaults                      0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /var                    btrfs  subvol=/@/var                 0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /usr/local              btrfs  subvol=/@/usr/local           0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /srv                    btrfs  subvol=/@/srv                 0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /root                   btrfs  subvol=/@/root                0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /opt                    btrfs  subvol=/@/opt                 0  0
/dev/mapper/cr_home                        /home                   ext4   data=ordered                  0  2
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /boot/grub2/x86_64-efi  btrfs  subvol=/@/boot/grub2/x86_64-efi  0  0
UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /boot/grub2/i386-pc     btrfs  subvol=/@/boot/grub2/i386-pc  0  0
UUID=6B77-6EDC                             /boot/efi               vfat   utf8                          0  2
UUID=e314b847-ef08-4b39-b238-815adf8f8177  swap                    swap   defaults                      0  0

findmnt --real at this moment

TARGET                                 SOURCE                              FSTYPE      OPTIONS
/                                      /dev/sda3[/@]                       btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@
β”œβ”€/run/user/1000/doc                   portal                              fuse.portal rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
β”œβ”€/boot/grub2/i386-pc                  /dev/sda3[/@/boot/grub2/i386-pc]    btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=263,subvol=/@/boot/grub2/i386-pc
β”œβ”€/boot/grub2/x86_64-efi               /dev/sda3[/@/boot/grub2/x86_64-efi] btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/@/boot/grub2/x86_64-efi
β”œβ”€/opt                                 /dev/sda3[/@/opt]                   btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=261,subvol=/@/opt
β”œβ”€/root                                /dev/sda3[/@/root]                  btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@/root
β”œβ”€/srv                                 /dev/sda3[/@/srv]                   btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@/srv
β”œβ”€/usr/local                           /dev/sda3[/@/usr/local]             btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@/usr/local
β”œβ”€/boot/efi                            /dev/sda1                           vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
β”œβ”€/home                                /dev/mapper/cr_home                 ext4        rw,relatime,data=ordered
└─/var                                 /dev/sda3[/@/var]                   btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@/var

snapper list at this moment

   # | Type   | Pre # | Date                     | User | Cleanup  | Description        | Userdata     
-----+--------+-------+--------------------------+------+----------+--------------------+--------------
  0  | single |       |                          | root |          | current            |              
  5  | single |       | Sat Aug 19 13:00:21 2023 | root | timeline | timeline           |              
 27  | single |       | Sun Oct  1 06:00:05 2023 | root | timeline | timeline           |              
100  | single |       | Wed Nov  1 16:00:21 2023 | root | timeline | timeline           |              
170  | single |       | Sat Dec  2 13:00:33 2023 | root | timeline | timeline           |              
214  | single |       | Sat Feb  3 14:00:03 2024 | root | timeline | timeline           |              
294  | single |       | Thu Feb 29 06:00:47 2024 | root | timeline | timeline           |              
309  | single |       | Fri Mar  1 06:00:00 2024 | root | timeline | timeline           |              
323  | single |       | Sun Mar  3 07:00:03 2024 | root | timeline | timeline           |              
...
406  | pre    |       | Sat Mar 16 12:36:34 2024 | root | number   | yast sw_single     |              
407  | post   |   406 | Sat Mar 16 12:40:33 2024 | root | number   |                    |              
412  | single |       | Sat Mar 16 13:00:11 2024 | root | timeline | timeline           |              

findmnt --real when in the snapshot

TARGET                   SOURCE                                FSTYPE      OPTIONS
/                        /dev/sda3[/@/.snapshots/412/snapshot] btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=678,subvol=/@/.snapshots/412/snapshot
β”œβ”€/run/user/461/doc      portal                                fuse.portal rw,nosuid,nodev,relatime,user_id=461,group_id=461
β”œβ”€/usr/local             /dev/sda3[/@/usr/local]               btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@/usr/local
β”œβ”€/root                  /dev/sda3[/@/root]                    btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@/root
β”œβ”€/boot/grub2/i386-pc    /dev/sda3[/@/boot/grub2/i386-pc]      btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=263,subvol=/@/boot/grub2/i386-pc
β”œβ”€/opt                   /dev/sda3[/@/opt]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=261,subvol=/@/opt
β”œβ”€/boot/grub2/x86_64-efi /dev/sda3[/@/boot/grub2/x86_64-efi]   btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/@/boot/grub2/x86_64-efi
β”œβ”€/srv                   /dev/sda3[/@/srv]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@/srv
β”œβ”€/var                   /dev/sda3[/@/var]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@/var
β”œβ”€/boot/efi              /dev/sda1                             vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
└─/home                  /dev/mapper/cr_home                   ext4        rw,relatime,data=ordered

snapper list when in the snapshot

# | Type   | Pre # | Date | User | Cleanup | Description | Userdata
---+--------+-------+------+------+---------+-------------+---------
0  | single |       |      | root |         | current     |         

obviously something did not get setup correctly during install and I must have missed something when doing it manually.

As I said snapper -v undochange worked fine so it’s no big issues but having the official rollback working would be nice.

Regards, Xil

Either this is very ancient installation or you initially installed this system without snapshot support. In the latter case you may be missing other parts of configuration required to do it.

You need explicit /.snapshots mount point for the subvolume where snapshots are created (@/.snapshots) and snapshots support in grub has to be enabled.

/etc/fstab:
`UUID=fe78f3af-d72b-47d7-a1f6-6f703637b957  /.snapshots            btrfs  subvol=/@/.snapshots         0  0
/etc/default/grub:
SUSE_BTRFS_SNAPSHOT_BOOTING="true"

If SUSE_BTRFS_SNAPSHOT_BOOTING is not set, you need to add it and reinstall bootloader using

update-bootloader --reinit

hi Arvidjaar

thank you for your answer.

no, it’s not ancient, its of august last year as the 1st entry in the snap list confirms.
I selected btrfs and snapshot support from the installer.

the grub entry was there and it works else I would not have been able to select a snapshot to boot from.

I have added the fstab entry as you suggested as it was not there, will wait 2 snaps to try again as it won’t be there if I boot right now from a previous snap :wink:

Will let you know.

Regards, Xil

There is no way you could get this subvolume layout if snapshot support was enabled during installation, at least when using automatic default partitioning. And your own post confirms it.

If snapshots were enabled during installation, snapper configuration would exist.

that might be the issue then, I adjust the configuration to use a separate /home, so went with the initial suggestion and then adjusted it, I must have made a mistake there.

A working default installation has all of the following:

erlangen:~ # findmnt --types btrfs 
TARGET                   SOURCE                                      FSTYPE OPTIONS
/                        /dev/nvme1n1p2[/@/.snapshots/3241/snapshot] btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=5786,subvol=/@/.snapshots/3241/snapshot
β”œβ”€/home                  /dev/nvme1n1p2[/@/home]                     btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=262,subvol=/@/home
β”œβ”€/.snapshots            /dev/nvme1n1p2[/@/.snapshots]               btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=265,subvol=/@/.snapshots
β”œβ”€/boot/grub2/i386-pc    /dev/nvme1n1p2[/@/boot/grub2/i386-pc]       btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=264,subvol=/@/boot/grub2/i386-pc
β”œβ”€/boot/grub2/x86_64-efi /dev/nvme1n1p2[/@/boot/grub2/x86_64-efi]    btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=263,subvol=/@/boot/grub2/x86_64-efi
β”œβ”€/srv                   /dev/nvme1n1p2[/@/srv]                      btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=259,subvol=/@/srv
β”œβ”€/var                   /dev/nvme1n1p2[/@/var]                      btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=257,subvol=/@/var
β”œβ”€/root                  /dev/nvme1n1p2[/@/root]                     btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=260,subvol=/@/root
β”œβ”€/opt                   /dev/nvme1n1p2[/@/opt]                      btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=261,subvol=/@/opt
└─/usr/local             /dev/nvme1n1p2[/@/usr/local]                btrfs  rw,relatime,ssd,discard=async,nospace_cache,subvolid=258,subvol=/@/usr/local
erlangen:~ # 

I know, but as you can see I added an existing encrypted ext4

Yep. However: Full disk encryption vs home folder encryption - why should the former be chosen over the latter - Information Security Stack Exchange

added the fstab entry like a minute before 7.
did a zypper so it created a pre/post entry

414  | post   |   413 | Sun Mar 17 06:35:37 2024 | root | number   |                    |              
415  | single |       | Sun Mar 17 07:00:35 2024 | root | timeline | timeline           |              
416  | pre    |       | Sun Mar 17 07:18:28 2024 | root | number   | yast sw_single     |              
417  | post   |   416 | Sun Mar 17 07:18:42 2024 | root | number   |                    |              

rebooted, selected to boot from snap, select the 415 one.

TARGET                   SOURCE                                FSTYPE      OPTIONS
/                        /dev/sda3[/@/.snapshots/415/snapshot] btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=681,subvol=/@/.snapshots/415/snapshot
β”œβ”€/run/user/461/doc      portal                                fuse.portal rw,nosuid,nodev,relatime,user_id=461,group_id=461
β”œβ”€/opt                   /dev/sda3[/@/opt]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=261,subvol=/@/opt
β”œβ”€/.snapshots            /dev/sda3[/@/.snapshots]              btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=264,subvol=/@/.snapshots
β”œβ”€/root                  /dev/sda3[/@/root]                    btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@/root
β”œβ”€/boot/grub2/i386-pc    /dev/sda3[/@/boot/grub2/i386-pc]      btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=263,subvol=/@/boot/grub2/i386-pc
β”œβ”€/var                   /dev/sda3[/@/var]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@/var
β”œβ”€/boot/grub2/x86_64-efi /dev/sda3[/@/boot/grub2/x86_64-efi]   btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/@/boot/grub2/x86_64-efi
β”œβ”€/srv                   /dev/sda3[/@/srv]                     btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@/srv
β”œβ”€/usr/local             /dev/sda3[/@/usr/local]               btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@/usr/local
β”œβ”€/boot/efi              /dev/sda1                             vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
└─/home                  /dev/mapper/cr_home                   ext4        rw,relatime,data=ordered

so ./snapper is there now, and snapper list now shows all the possible snapshot with 415 having a - behind it

   # | Type   | Pre # | Date                     | User | Cleanup  | Description        | Userdata     
-----+--------+-------+--------------------------+------+----------+--------------------+--------------
  0  | single |       |                          | root |          | current            |              
  5  | single |       | Sat Aug 19 13:00:21 2023 | root | timeline | timeline           |              
 27  | single |       | Sun Oct  1 06:00:05 2023 | root | timeline | timeline           |              
...           
414  | post   |   413 | Sun Mar 17 06:35:37 2024 | root | number   |                    |              
415- | single |       | Sun Mar 17 07:00:35 2024 | root | timeline | timeline           |              
416  | pre    |       | Sun Mar 17 07:18:28 2024 | root | number   | yast sw_single     |              
417  | post   |   416 | Sun Mar 17 07:18:42 2024 | root | number   |                    |    

double checked touch /etc/test and yes FS was read-only, so was in the snap.

did the snapper rollback and got the exact same error.

maybe just should do a clean install, but then again it should be possible to set this up correctly.

Regards, Xil

You may fix your issue without clean install as done here: snapper rollback works only with --ambit classic option

Quoting myself

snapper expects that previous default subvolume is one of snapshots. So yes, you need to manually tell it how to do rollback the first time you switch from the legacy to the new subvolume layout.

am reading through that post, but it is a lot :slight_smile:

so after going though it, seems I need to do (using 415 as my test snapshot)

snapper --ambit classic rollback  415

though not sure where the

btrfs subvolume set-default /.snapshots/415/snapshot /

comes in… anyways of to try the ambit first

Nowhere. You should never have read-only snapshot as your root in the normal installation and snapper handles default subvolume for you.

reboot into 415

snapper --ambit classic rollback 415
Ambit is classic.
Created read-only snapshot of currect system. (Snapshot 419.)
Created read-write snapshot of snapshot 415 (Snapshot 420.)
Setting default subvolume to snapshot 420.
reboot

which now gives me:

415  | single |       | 2024-03-17T07:00:35 CET  | root | timeline | timeline              |              
416  | pre    |       | 2024-03-17T07:18:28 CET  | root | number   | yast sw_single        |              
417  | post   |   416 | 2024-03-17T07:18:42 CET  | root | number   |                       |              
418  | single |       | 2024-03-17T08:00:09 CET  | root | timeline | timeline              |              
419  | single |       | 2024-03-17T08:14:10 CET  | root | number   | rollback backup       | important=yes
420* | single |       | 2024-03-17T08:14:13 CET  | root |          | writable copy of #415 |              

the * is new.

btrfs subvolume list -t / now shows @/var etc. while before it was just /var

btrfs subvolume list -t /    
ID      gen     top level       path
--      ---     ---------       ----
256     32462   5               @
257     32482   256             @/var
258     32271   256             @/usr/local
259     32271   256             @/srv
260     32475   256             @/root
261     32482   256             @/opt
262     32271   256             @/boot/grub2/x86_64-efi
263     32271   256             @/boot/grub2/i386-pc
264     32475   256             @/.snapshots

is there anything I should do with the previous < 420 snaps (including 0) or just let time handle it ?

thanks again for your patiance and help

-Xil

Now your previous legacy root content in the subvolume /@ is out of snapper control and is invisible. It will never be cleaned up automatically and will stay there forever. If this space is of concern to you, you need to manually delete everything under /@ that is not subvolume used in /etc/fstab. As you see, some subvolumes are nested inside directories, so be careful.

Other regular snapper snapshots will be removed by snapper as long as you enabled automatic cleanup.

You cannot use snapper to revert to your original state, only to switch between snapper snapshots.

I ran into that issue with an install last summer.

My install reused an existing partition, which was originally using β€œext4”. I told it to use β€œbtrfs”, which it did but without snapshot support. Apparently there was some box I should have checked to allow snapshot support, but I missed it.

I reinstalled, and this time it did default to snapper support.

Apparently: β€œext4” β†’ β€œbtrfs” the default install behavior is to not enable snapshots. But with β€œbtrfs” β†’ β€œbtrfs” the default is to enable, even if the original did not use snapshots.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.