How to fix btrfsmaintenance

On boot version 0.4.2 runs btrfsmaintenance-refresh.service during processing of /etc/fstab. This results in systemd unmounting already mounted partitions.

https://en.opensuse.org/SDB:Fix_btrfsmaintenance-refresh

Seems to be OK.

Which/what “boot version 0.4.2” is meant here?

On boot [btrfsmaintenance] version 0.4.2 runs btrfsmaintenance-refresh.service during processing of /etc/fstab.

Found on https://en.opensuse.org/SDB:Fix_btrfsmaintenance-refresh that the way to check this is checking the journal so I did so:


> sudo journalctl -b -u btrfs* -o short-monotonic
    6.231133] systemd[1]: Started Watch /etc/sysconfig/btrfsmaintenance.
    6.240089] systemd[1]: Starting Update cron periods from /etc/sysconfig/btrfsmaintenance...
    6.329473] btrfsmaintenance-refresh-cron.sh[1135]: Refresh script btrfs-scrub.sh for uninstall
    6.329473] btrfsmaintenance-refresh-cron.sh[1135]: Refresh script btrfs-defrag.sh for uninstall
    6.332106] btrfsmaintenance-refresh-cron.sh[1135]: Refresh script btrfs-balance.sh for uninstall
    6.339249] btrfsmaintenance-refresh-cron.sh[1135]: Refresh script btrfs-trim.sh for uninstall
    6.349608] btrfsmaintenance-refresh-cron.sh[1135]: Refresh timer btrfs-scrub for monthly
    6.948747] systemd[1]: Started Balance block groups on a btrfs filesystem.
    6.948880] systemd[1]: Started Scrub btrfs filesystem, verify block checksums.
    6.950764] btrfsmaintenance-refresh-cron.sh[1135]: Refresh timer btrfs-defrag for none
    7.258546] btrfsmaintenance-refresh-cron.sh[1135]: Refresh timer btrfs-balance for weekly
    7.588677] btrfsmaintenance-refresh-cron.sh[1135]: Refresh timer btrfs-trim for none
    7.873002] systemd[1]: btrfsmaintenance-refresh.service: Succeeded.
    7.873784] systemd[1]: Started Update cron periods from /etc/sysconfig/btrfsmaintenance.

So, btrfsmaintenance-refresh.service is running during the boot (one but last line)

Good to know how to fix this, but isn’t it better to create a bug report so that it can be fixed for everybody with an new update.

I am trying hard:

https://bugzilla.suse.com/show_bug.cgi?id=1165780
https://bugzilla.suse.com/show_bug.cgi?id=1145650
https://bugzilla.suse.com/show_bug.cgi?id=1124823

Thanks, quite some effort spend already to get a patch in, but no traction yet it seems.

There is a problem with conceptions how units btrfsmaintenance-refresh.path and btrfsmaintenance-refresh.service should work. So I added more detail to SDB:Fix btrfsmaintenance-refresh - openSUSE Wiki

See also: Update btrfsmaintenance-refresh.service by karlmistelberger · Pull Request #80 · kdave/btrfsmaintenance · GitHub

Users affected by failing mounts are kindly asked to give feedback here and to report to the maintainers: https://bugzilla.suse.com/show_bug.cgi?id=1165780#c25

Sorry for asking but what kind of feedback is “needed”.

I just updated and see basically the same output of “sudo journalctl -b -u btrfs* -o short-monotonic” as above, is that what can help the maintainers?

If you experience systemd unmounting partitions report at: 1165780 – Reduce the number of PID1 reloading triggered by btrfsmaintenance

Presumably you have btrfsmaintenance-refresh.service enabled and the unit runs during boot without /etc/sysconfig/btrfsmaintenance being changed. Follow SDB:Fix btrfsmaintenance-refresh - openSUSE Wiki and double check. Feedback welcome here.

I had experienced this issue of partitions getting unmounted during boot since two months ago, cf. https://forums.opensuse.org/showthread.php/539125-TW-after-update-to-20200211-My-user-hard-drive-partitions-do-not-get-mounted-at-boot-any-longer. Very similar to e.g. https://forums.opensuse.org/showthread.php/539503-boot-efi-is-not-mounted among the more recent reports on such issue.

In the meantime, I have been following the recipe by Andre Werlang https://forums.opensuse.org/showthread.php/539428-BTRFS-maintenance-on-SSD to go for a fully manual (i.e. scripted) btrfs maintenance. It works very well, but it leaves me with the little burden of keeping track of when I ran it last and when to run it again.

Discovering this thread here and in particular Karl Mistelberger’s SDB post https://en.opensuse.org/SDB:Fix_btrfsmaintenance-refresh, I switched to Karl Mistelberger’s solution some days ago. Up to now, it worked really well. All status outputs show things to be the way they are supposed to.

However, looking at the associated openSUSE bugzilla discussion at https://bugzilla.suse.com/show_bug.cgi?id=1165780 between Karl Mistelberger and Franck Bui, I for now do unfortunately feel like being in some unhappy state. Seems like the diagnoses and/or the proposed fixes haven’t really settled yet. Guess I will have to wait until an “official” fix is agreed upon and will have found its way into the Tumbleweed repositories.

In the meantime, can I do anything to help with the bugzilla report?

But then, at that point in the future, I do have a request and a question for you, Karl Mistelberger: The request is that I am asking you to post a note here and on your SDB when and how things are ultimately fixed, i.e. when a Tumbleweed zypper dup brings the solution to the TW installations. And the question is: Please post a recipe here how to revert the changes that I and others made when following your SDB, i.e. (1) how to get rid of the

/etc/systemd/system/btrfsmaintenance-refresh.path.d/override.conf

file (hmm, just guessing, is it systemctl rm that_file?), and (2) how to bring all relevant service units and timers to their “correct” state.

Thank you, Karl Mistelberger and Andre Werlang, for all your efforts, and thanks in advance, Karl, for answering the two things raised in the last paragraph right above this one.

  1. Don’t delete the changes if you experience umounting during boot. Otherwise you may delete the file: ‘rm /etc/systemd/system/btrfsmaintenance-refresh.path.d/override.conf’ and run: ‘systemctl daemon-reload’ for changes to take effect.
  2. Run the following: ‘systemctl enable btrfsmaintenance-refresh.path’ and ‘systemctl disable btrfsmaintenance-refresh.service’ Verify the changes made: SDB:Fix btrfsmaintenance-refresh - openSUSE Wiki

If you use systemctl edit service-name to override a service, the reversion of that is:

systemctl revert btrfsmaintenance-refresh.path   

It removes the override file and directory from /etc/* and reloads systemd.

Yes, see ‘systemctl --help’: revert UNIT… Revert one or more unit files to vendor version. You always have 2 options: use built-in command or edit manually and reload. You may want to verify the result with ‘systemctl cat’.

Hey, Karl,
Thanks for posting this. I was today hit by /opt not mounting during boot, and having followed this thread, it was easily solved. I disabled the …refresh.service, enabled the …refresh.path and the issues ( of course everything in /opt was affected ) are indeed gone after a reboot. IMNSHO this should be fixed in TW a.s.a.p. People are using Chrome ( whether we like it or not ) and docker ( containerd puts stuff there ).

You can help: https://forums.opensuse.org/showthread.php/539905-How-to-fix-btrfsmaintenance?p=2933726#post2933726

systemd 245 is fixed. If your version still exhibits the bug consider reporting.

Version 0.5 fixes some bugs and implements improvements:


* Wed Aug 19 2020 Callum Farmer <callumjfarmer13@gmail.com>
- Fixes for %_libexecdir changing to /usr/libexec (bsc#1174075)

* Wed Jul 29 2020 dsterba@suse.cz
- update to version 0.5
  - sysconfig:
  - change defaults of MUSAGE and DUSAGE for balance task to do less work,
    with a script to switch from existing unmodified defaults to new ones
  - document systemd.timer syntax
  - make balance, scrub, and trim mutually exclusive tasks
  - service file updates:
  **- delete Install section**
  - defrag-plugin:
  - switch to python3
  - add alternative shell implementation of the plugin
  - installation docs update
- Removed patches (upstream):
  - 0001-README-document-impact-of-balance-quota-groups.patch
  - 0002-sysconfig-reduce-default-balance-usage-thresholds-fa.patch
  - 0003-sysconfig-document-using-systemd.time-7-for-frequenc.patch
  - 0004-btrfsmaintenance-refresh-cron.sh-validate-periods-fo.patch
  - 0005-btrfs-defrag-plugin-remove-dependency-on-zypp-plugin.patch

Presets are fixed too: https://bugzilla.opensuse.org/show_bug.cgi?id=1165780#c49

Thus btrfsmaintenance should now work as expected out of box.

The tools run on a Samsung model: SSD 950 PRO 512GB. System partition is:

erlangen:~ # df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2   52G   22G   30G  43% /
erlangen:~ # 

For testing the impact on normal operation the routines are running daily:

erlangen:~ # grep PERIOD /etc/sysconfig/btrfsmaintenance 
BTRFS_DEFRAG_PERIOD="daily"
BTRFS_BALANCE_PERIOD="daily"
BTRFS_SCRUB_PERIOD="daily"
BTRFS_TRIM_PERIOD="daily"
erlangen:~ # 

Journal:

erlangen:~ # journalctl --since 00:00 -u 'btrfs*'
-- Logs begin at Sat 2020-11-14 06:05:06 CET, end at Fri 2020-12-04 08:08:32 CET. --
Dec 04 04:57:37 erlangen systemd[1]: Started Discard unused blocks on a mounted filesystem.
Dec 04 04:57:37 erlangen systemd[1]: Started Scrub btrfs filesystem, verify block checksums.
Dec 04 04:57:37 erlangen systemd[1]: Started Balance block groups on a btrfs filesystem.
Dec 04 04:57:37 erlangen systemd[1]: Started Defragment file data on a mounted filesystem.
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: Before balance of /
Dec 04 04:57:37 erlangen btrfs-scrub.sh[17907]: Running scrub on /
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: Data, single: total=27.01GiB, used=19.77GiB
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: System, single: total=32.00MiB, used=16.00KiB
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: Metadata, single: total=2.01GiB, used=1.13GiB
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: GlobalReserve, single: total=69.11MiB, used=0.00B
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
Dec 04 04:57:37 erlangen btrfs-balance.sh[17890]: /dev/nvme0n1p2   56G     23G   33G   42% /
Dec 04 04:57:37 erlangen btrfs-trim.sh[17925]: Running fstrim on /
Dec 04 04:57:39 erlangen systemd[1]: btrfs-defrag.service: Succeeded.
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Scrub device /dev/nvme0n1p2 (id 1) done
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Scrub started:    Fri Dec  4 04:57:37 2020
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Status:           finished
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Duration:         0:00:12
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Total to scrub:   29.05GiB
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Rate:             1.74GiB/s
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: Error summary:    no errors found
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: flock: es dauerte 0.000002 Sekunden, um die Sperre zu bekommen
Dec 04 04:57:49 erlangen btrfs-scrub.sh[17907]: flock: btrfs wird ausgeführt
Dec 04 04:57:49 erlangen systemd[1]: btrfs-scrub.service: Succeeded.
Dec 04 04:58:49 erlangen btrfs-trim.sh[17925]: /: 8,1 GiB (8685576192 Bytes) getrimmt
Dec 04 04:58:49 erlangen btrfs-trim.sh[17925]: flock: es dauerte 11.798961 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-trim.sh[17925]: flock: fstrim wird ausgeführt
Dec 04 04:58:49 erlangen systemd[1]: btrfs-trim.service: Succeeded.
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Done, had to relocate 0 out of 32 chunks
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: es dauerte 71.461247 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: btrfs wird ausgeführt
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Dumping filters: flags 0x1, state 0x0, force is off
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]:   DATA (flags 0x2): balancing, usage=5
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Done, had to relocate 0 out of 32 chunks
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: es dauerte 0.000002 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: btrfs wird ausgeführt
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Dumping filters: flags 0x1, state 0x0, force is off
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]:   DATA (flags 0x2): balancing, usage=10
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Done, had to relocate 0 out of 32 chunks
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: es dauerte 0.000002 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: btrfs wird ausgeführt
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Done, had to relocate 0 out of 32 chunks
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: es dauerte 0.000003 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: btrfs wird ausgeführt
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Dumping filters: flags 0x6, state 0x0, force is off
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]:   METADATA (flags 0x2): balancing, usage=3
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]:   SYSTEM (flags 0x2): balancing, usage=3
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Done, had to relocate 1 out of 32 chunks
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: es dauerte 0.000006 Sekunden, um die Sperre zu bekommen
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: flock: btrfs wird ausgeführt
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: After balance of /
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Data, single: total=27.01GiB, used=19.78GiB
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: System, single: total=32.00MiB, used=16.00KiB
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Metadata, single: total=2.01GiB, used=1.19GiB
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: GlobalReserve, single: total=69.34MiB, used=0.00B
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
Dec 04 04:58:49 erlangen btrfs-balance.sh[17890]: /dev/nvme0n1p2   56G     23G   33G   42% /
Dec 04 04:58:49 erlangen systemd[1]: btrfs-balance.service: Succeeded.
erlangen:~ # 

**Operation of procedures is completely unobtrusive. **