Venom1991 / refind-btrfs

Generate rEFInd manual boot stanzas from Btrfs snapshots
GNU General Public License v3.0
144 stars 8 forks source link

rw snapshots vs snapper question #53

Closed developer91234 closed 6 months ago

developer91234 commented 7 months ago

A little confused by the readme.

The readme says "seamless integration with snapper" and then says refind-btrfs will create writable snapshots.

But snapper is a tool that actually creates the snapshots and it makes them read only. So how does refind-btrfs actually integrate with snapper?

Venom1991 commented 7 months ago

refind-btrfs isn't tightly coupled with Snapper in any way. In fact, it isn't tightly coupled with any snapshot management tool. It's just that the default config is supposed to help the user get refind-btrfs working quickly if and only if said user also has Snapper configured and running on the same machine.

I believe Timeshift also used to work well with this tool but but ever since they made backward incompatible changes with regards to the snapshot output directory (changes with every boot, AFAIK) it most probably doesn't (the directory watching feature, at the very least). I wouldn't know about btrbk. Anyway, since I'm using Snapper the default config is the way it is but, like I said, this tool isn't coupled with it, not even loosely.

But snapper is a tool that actually creates the snapshots and it makes them read only. So how does refind-btrfs actually integrate with snapper?

Booting into read-only snapshots is tricky business and I chose not to support it, for simplicity's sake. So, you're given a choice - you can either create a writable snapshot from the read-only one (default behavior) or you can change its "read-only" flag to "false", thus making it writable. The latter choice is a bit more dangerous since the boot process can also possibly alter the snapshot in an undesirable way hence why I chose not to make it the default one.

developer91234 commented 7 months ago
# modify_read_only_flag = <bool>
## Whether to change the read-only flag of a snapshot instead of creating
## a new writable snapshot from it. This option has no meaning for those
## snapshots that are already writable.

So what does your software do by default, create a new writable snapshot for every ro snapshot in the /.snapshots directory?

Venom1991 commented 7 months ago
# modify_read_only_flag = <bool>
## Whether to change the read-only flag of a snapshot instead of creating
## a new writable snapshot from it. This option has no meaning for those
## snapshots that are already writable.

So what does your software do by default, create a new writable snapshot for every ro snapshot in the /.snapshots directory?

By default? Yes, it behaves in exactly the same way which you've just described. You can check out this method, if you wish.

developer91234 commented 7 months ago

If an ro snapshot is deleted do the rw snapshot and boot entry get deleted as well, or does the cleanup happen independently for the latter based on [snapshot-manipulation] \ selection_count = n?

Regarding the fstab alignment, does refind-btrfs undo the realignment upon rollback? If not, the / line can just be omitted from fstab entirely to avoid fussing around with alignment and your software won't care, correct?

Sorry if too many questions ;)

Venom1991 commented 7 months ago

If an ro snapshot is deleted do the rw snapshot and boot entry get deleted as well, or does the cleanup happen independently for the latter based on [snapshot-manipulation] \ selection_count = n?

Yes, if the systemd service is running (at the time of deletion) refind-btrfs should figure out whether the deleted snapshot is a parent of any of the previously created writable snapshots and if it is, delete that snapshot as well. In case the service isn't running then a manual cleanup must be performed.

Regarding the fstab alignment, does refind-btrfs undo the realignment upon rollback?

No, the fstab file must be amended manually to reflect the changes made by rollbacking a snapshot with which refind-btrfs has absolutely nothing to do. While you could technically omit the "/" line altogether (kernel parameters are enough, AFAIK) I believe that, for the sake of correctness, it should remain included.

developer91234 commented 7 months ago

But if the fstab line for / is missing, refind-btrfs won't try to add it, right?

Venom1991 commented 7 months ago

But if the fstab line for / is missing, refind-btrfs won't try to add it, right?

No, sorry - what I meant to write was that in general the / line needn't be perfectly aligned with the kernel parameters (AFAIK, again and I'm not so sure about omitting it completely) but of course this tool will complain that it is either misaligned or that it doesn't exist. I could relax those checks but it's a bit more complicated than that, considering the state of the current implementation.

developer91234 commented 7 months ago

I understand that the tool has nothing to do with rollback but the point of snapshots is ultimately rollback so it may not be a bad idea to align fstab back if the snapshot is promoted and/or also relax the checks, since the the root mount in fstab isn't strictly needed anyway.

Venom1991 commented 7 months ago

so it may not be a bad idea to align fstab back

Until this planned (for quite some time now) Btrfs feature is implemented I don't honestly see how I'm supposed to do just that.

or also relax the checks

This, on the other hand, is doable and I just might go down that route since there's no alternative at this time or at least none that I can think of.

developer91234 commented 6 months ago

You could just just watch the fstab file for changes, no?

Venom1991 commented 6 months ago

Once you've booted into a snapshot (the potential rollback scenario), this tool behaves differently and it, by default, simply exits prematurely so as not to create snapshots of it since they're not really needed but this behavior is configurable.

What I mean to say is that watching for fstab changes would bring along even more complexity and is, in my opinion, an out of scope feature from the perspective of what this tool is supposed to do.

developer91234 commented 6 months ago

Could just be a systemd unit separate from the rest of the tool. Makes sense to add the functionality given the importance of rollback and the fact the tool already modifies fstab

Venom1991 commented 6 months ago

First sentence in the description:

This tool is used to automate a few tedious tasks required to boot into Btrfs snapshots from rEFInd.

Like I've said before, this tool is concerned solely with booting into snapshots and anything that comes afterwards (including rollback) isn't relevant to what this tool is supposed to be doing.

That said, I do agree that it would be useful to realign the fstab file with the newly rollbacked subvolume but that feature simply isn't a good fit for this tool.

Do you have anymore questions? If not, I'll close this issue within 24 hours.