Btrfs Assistant 1.0 is coming, testers needed

So, I felt like an idiot because following the instructions above I rebooted and found NO snapshots available. It turns out you need to run grub-mkconfig -o /boot/grub/grub.cfg to actually added the snapshots to the grub boot menu.

I got this output:

...
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
Found snapshot: 2022-06-13 17:04:36 | @/.snapshots/220/snapshot | single | boot     |
Found snapshot: 2022-06-13 17:00:29 | @/.snapshots/219/snapshot | single | timeline |
Found snapshot: 2022-06-13 16:00:29 | @/.snapshots/218/snapshot | single | timeline |
...

Iā€™ve noticed now that there is a service in the package:

$ yay -Ql grub-btrfs
...
grub-btrfs /usr/lib/systemd/
grub-btrfs /usr/lib/systemd/system/
grub-btrfs /usr/lib/systemd/system/grub-btrfs.path
grub-btrfs /usr/lib/systemd/system/grub-btrfs.service
...

No doubt this stuff adds the entries automatically?

EDIT: Indeed, instructions in /usr/share/doc/grub-btrfs/README.md

$ sudo systemctl enable grub-btrfs.path
Created symlink /etc/systemd/system/\x2esnapshots.mount.wants/grub-btrfs.path ā†’ /usr/lib/systemd/system/grub-btrfs.path.
Unit /usr/lib/systemd/system/grub-btrfs.path is added as a dependency to a non-existent unit \x2esnapshots.mount.

$ sudo systemctl start grub-btrfs.path
Failed to start grub-btrfs.path: Unit \x2esnapshots.mount not found.

Any idea what this ā€œ\x2esnapshots.mountā€ itā€™s complaining about is?

Iā€™m not sure why it canā€™t find my /.snapshots:

$ sudo btrfs sub list /
ID 257 gen 175140 top level 5 path @home
ID 258 gen 175118 top level 5 path @cache
ID 259 gen 175140 top level 5 path @log
ID 260 gen 155924 top level 402 path var/lib/portables
ID 261 gen 155924 top level 402 path var/lib/machines
ID 350 gen 175135 top level 402 path .snapshots
ID 354 gen 156417 top level 350 path .snapshots/3/snapshot
ID 356 gen 155924 top level 5 path @swap
ID 390 gen 158970 top level 350 path .snapshots/37/snapshot
ID 402 gen 175140 top level 5 path @
ID 423 gen 161366 top level 350 path .snapshots/68/snapshot
ID 455 gen 163697 top level 350 path .snapshots/100/snapshot
...

I can see them in:

$ sudo ls /.snapshots/
100  125  149  151  165  178  208  210	212  214  216  218  220  3   68
121  147  150  153  167  202  209  211	213  215  217  219  221  37

Is this not what the default expectation is?

If I remembered correctly, because you do not have the subvolume @snapshots

What is the output of findmnt --fstab?

I think \x2esnapshots.mount requires that you create a new any subvolume then edit /etc/fstab to mount it with /.snapshots.

But you do not have mountpoint of /.snapshots, you can remove all \x2esnapshots.mount in sudo systemctl edit --full grub-btrfs.path:

[Unit]
Description=Monitors for new snapshots
DefaultDependencies=no

[Path]
PathModified=/.snapshots

But Iā€™m not sure if it works.

1 Like

ā€œ\x2esnapshots.mountā€ is automatically generated by systemd-fstab-generator after editing /etc/fstab to add a new mountpoint of /.snapshots

sudo systemctl edit --full \\x2esnapshots.mount 
# Automatically generated by systemd-fstab-generator

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
Before=local-fs.target
After=blockdev@dev-disk-by\x2duuid-4d67a09d\x2d451e\x2d4e0c\x2d9156\x2ddcb0bbdsd3e.target

[Mount]
What=/dev/disk/by-uuid/4d67a09d-451e-4e0c-9156-ddcb0bbdsd3e
Where=/.snapshots
Type=btrfs
Options=subvol=/@snapshots/root,rw,noatime,compress=zstd:1

Try to check sudo systemctl list-units -t mount to show the list of mount

  UNIT                             LOAD   ACTIVE SUB     DESCRIPTION  
  -.mount                          loaded active mounted Root Mount
  \x2esnapshots.mount              loaded active mounted /.snapshots
  boot-efi.mount                   loaded active mounted /boot/efi
...

The default path file is too specific. I recommend using a modified version. I have posted the modified version a few times. If you canā€™t find it let me know.

@dalto btrfs assistant > snapper settings >snapshot retention
those hourly,daily etc settings, i was always under the impression that those were about how many snapshots the cleanup service would leave behind, but it seems its all about automatic creation of snapshots, since they cant be edited without enabling timeline snapshots? i find that confusing. can you clarify? how does the cleanup service know what i want it to do if those settings arent for that?

thanks

It is, but it is specific to timeline snapshots.

In snapper, snapshots have different types that can be cleaned up, timeline - which are taken hourly and then cleaned up according to the retention settings and ā€œnumberā€ which are the snapshots taken as part of things like snap-pac and friends.

If you arenā€™t taking timeline snapshots, there is no reason to have a cleanup schedule for them.

thank you
so manually created snapshots must be manually deleted?

Iā€™ve added the following to fstab:

UUID=10840302-2838-4187-842a-eee8f883ed50 /.snapshots    btrfs   subvol=@/.snapshots,defaults,noatime 0 0

After mounting successfully, I see the systemd unit:

# mount | grep snapshot
/dev/sda2 on /.snapshots type btrfs (rw,noatime,compress=zstd:3,space_cache=v2,subvolid=350,subvol=/@/.snapshots)

# systemctl list-units -t mount | grep snapshot
  \x2esnapshots.mount           loaded active mounted /.snapshots

This made it possible to start the service:

# systemctl status grub-btrfs.path
ā— grub-btrfs.path - Monitors for new snapshots
     Loaded: loaded (/usr/lib/systemd/system/grub-btrfs.path; enabled; vendor preset: disabled)
     Active: active (waiting) since Mon 2022-06-13 19:03:32 BST; 3min 27s ago
      Until: Mon 2022-06-13 19:03:32 BST; 3min 27s ago
   Triggers: ā— grub-btrfs.service

Jun 13 19:03:32 ironyman systemd[1]: Started Monitors for new snapshots.

What I do not understand, is why I see snapshots regardless of whether I mount the subvolume or not. Basically, even before adding the above to fstab, I could list snapshots from command-line, as per my post above.

So now I am confused about BTRFS subvolumes: do they not need to be mounted in order to be visible?

Yes.

Wouldnā€™t it be much more better to change the path unit which is built for a different layout than to add a mount to /etc/fstab?

No, subvolumes are always visible inside their parent. In this case, @ is at the root of the btrfs partition and .snapshots is nested inside of it.

If you mount @ then @/.snapshots will be visible and available even if it isnā€™t explicitly mounted.

The requirement to mount in this case is caused by the path unit and modifying the path unit to match your system will solve the problem.

1 Like

Are you referring to @Zesko 's other suggestion to edit grub-btrfs.path service and remove the reference to the path?

I am thinking that if I ever update the grub-btrfs package, my change would get overwritten and the problem would appear again?

You donā€™t actually edit the file. You put your changes in /etc/systemd/system either by putting an entire copy of the file or by using drop-ins via the systemctl edit command. That will override the one provided by the package.

I have an improved version of the path unit I can find if you want it.

1 Like

Thanks @dalto. I was not aware of this systemctl ability. Learning something new every day since I switched to EOS.

Please do share your path unit when you find some time.

There is a actually not much to it. I think it was the service file I must have modified more heavily.

Anyway just save this file as /etc/systemd/system/grub-btrfs.path

[Unit]
Description=Monitors for new snapshots

[Path]
PathModified=/.snapshots

[Install]
WantedBy=multi-user.target
1 Like

Hi Zesko, by adding the overlayfs,grub-btrfs-overlayfs does it mean that all the snapshots loaded from the GRUB menu, it will be read and write and I wonā€™t have to restore again using the BTRFS Assistant app?

The reason I ask is that letā€™s say the update breaks the the GRUB menu completely and I want to restore using to last snapshot. What is the best way to do this?

When I had Timeshift, I can log into TTY and type timeshift -restore command and restore into the previous snapshot directly.

Is there an ability to do this with snapper snapshots?

Thanks!

No. The overlayfs sits on top of the snapshot you boot. It just makes it so everything works.

Remember, grub never restores anything. It is just a temporary way to get access to your system again.

snapper itself has rollback commands but they really require a very specific scenario for them to work.

Btrfs Assistant has a simple CLI that does support restoring. Although, if you boot off a snapshot, you might as well use the GUI to do the restore.

1 Like

Hi Dalto, agreed and understood that booting off GRUB is always read-only.

what would be the command line for me to restore? Are you saying that BTRFS Assistant has commands to do this or for now its only possible to restore using the GUI App?

btw, I did test restoring and everything works using the app. no issue to report.

Youā€™ve done a fantastic job on developing it. :grinning:

3 Likes

Yes.

>> btrfs-assistant --help                                                                                                              
Usage: btrfs-assistant-bin [options]
An application for managing Btrfs and Snapper

Options:
  -h, --help                      Displays help on commandline options.
  --help-all                      Displays help including Qt specific options.
  -v, --version                   Displays version information.
  -l, --list                      List snapshots
  -r, --restore <subvolume,UUID>  Restore the given subvolume/UUID
2 Likes

aah, I tried man btrfs-assistant earlierā€¦

what am I doing wrong to restore?

I typed sudo btrfs-assistant -r <@, cda3e3f6-4450-455e-9fd8-ae48d27675a8>

image