Should I deactivate my own btrfs scrub systemd timer after updating to 6.3.5.7 ?

  • Hello, this is just a quick question, on which I need confirmation.
    I already long time use btrfs and also scrub it every week using the systemd btrfs-scrub.service and btrfs-scrub.timer.


    ● btrfs-scrub.service - Scrub btrfs filesystem, verify block checksums

    Loaded: loaded (/etc/systemd/system/btrfs-scrub.service; static)

    Active: inactive (dead)

    TriggeredBy: ● btrfs-scrub.timer

    Docs: man:fstrim


    Now in changelog, it says that it was added that there will be a btrfs scrub.


    Code
      * Perform a daily scheduled cron task that checks Btrfs file    systems for errors. An email will be sent when errors are    detected. Use the OMV_BTRFS_ERROR_CHECK_ENABLED environment    variable to disable this check.  * Perform a weekly scheduled cron task that scrubs all mounted    Btrfs file systems. A report will be emailed afterwards.    Use the OMV_BTRFS_SCRUB_ENABLED environment variable to disable    this task. Use the additional variables OMV_BTRFS_SCRUB_PRIORITY    and OMV_BTRFS_SCRUB_READONLY to customize the scrub task.

    I guess this is what was activated through the update? Or do I need to deactivate this now because it will scrub 2 times otherwise per week?


    I also see the following:

    Code
      * Perform automatic scrubbing of all Btrfs file systems    monthly instead weekly.


    How could I set it to make it weekly again? Is omv using a the systemd timer or a cronjob?

  • oopenmediavault

    Changed the title of the thread from “Should I deactivate my own btrfs scrub cronjob after updating to 6.3.5.7 ?” to “Should I deactivate my own btrfs scrub systemd timer after updating to 6.3.5.7 ?”.
  • 1) Why if there is the systemd-timer, is it using a cronjob?
    2) Why can the cronjob not be deactivated or customized to do tasks on an interval that the user would like?

    My question, if my systemd-timer runs weekly, will it do scrubbing twice in the week where the omv cron job runs still stands

    • Official Post

    1) Why if there is the systemd-timer, is it using a cronjob?
    2) Why can the cronjob not be deactivated or customized to do tasks on an interval that the user would like?

    1) Because OMV does not know about your custom scripts and adding a cron job is simply putting a file into the /etc/cron.weekly or /etc/cron.monthly. Anacron is taking care it is executed even if the system is not running 24/7.

    2) You can deactivate the scrub job by setting the environment variable OMV_BTRFS_SCRUB_ENABLED as mentioned in the changelog. The interval can not be customized because the execution depends on in which directory the script resides.

    My question, if my systemd-timer runs weekly, will it do scrubbing twice in the week where the omv cron job runs still stands

    Yes

  • 1) Because OMV does not know about your custom scripts and adding a cron job is simply putting a file into the /etc/cron.weekly or /etc/cron.monthly. Anacron is taking care it is executed even if the system is not running 24/7.

    2) You can deactivate the scrub job by setting the environment variable OMV_BTRFS_SCRUB_ENABLED as mentioned in the changelog. The interval can not be customized because the execution depends on in which directory the script resides.

    Yes

    I understand, that Openmediavault cannot know about my custom scripts. My scripts are preceding the openmediavault integration though and were needed, since omv didnt do it itself. So now I need to make sure it doesnt conflict with this new integration or deactivate my own scripts.

    I still would like to run these scrubs weekly and not monthly, so there is no option in the OMV GUI that lets me set this time? If not, I would suggest to add this, as it is also done for backups and other things.

    If it is not implemented yet, is it possible for me to just add a custom script on OMV startup that moves the openmediavault-scrub_btrfs file from cron.monthly to cron.weekly without breaking things?

    • Official Post

    I still would like to run these scrubs weekly and not monthly, so there is no option in the OMV GUI that lets me set this time? If not, I would suggest to add this, as it is also done for backups and other things.

    As already mentioned, there is an environment variable that can be used to disable the OMV monthly Btrfs scrub job. Please check the blog entry and the documentation how to use environment variables. In your case you can skip the Apply changes section in the documentation.

    • Official Post

    so there is no option in the OMV GUI that lets me set this time? If not, I would suggest to add this

    No, this is not the philosophy of OMV. There is no knob in the UI for every possible feature, setting, ....

    OMV is designed for users that don't care about the technology and simply need a NAS to store their data. But OMV provides so called environment variables (like the registry for Windows) to allow more experienced users to customize the behaviour of OMV.

  • No, this is not the philosophy of OMV. There is no knob in the UI for every possible feature, setting, ....

    OMV is designed for users that don't care about the technology and simply need a NAS to store their data. But OMV provides so called environment variables (like the registry for Windows) to allow more experienced users to customize the behaviour of OMV.


    I understand. Thank you for your time and explaining the hows and whys.
    As a last question, I was just curious if the scrub period could not be set via adding one more environment variable for exactly this purpose?

    • Official Post

    As a last question, I was just curious if the scrub period could not be set via adding one more environment variable for exactly this purpose?

    OK, while writing this post i'd an idea how to customize that. The problem is that the file has to be created in a special directory to let it execute by Cron. If it exists in /etc/cron.monthly, then it will be executed once per month. Due the fact that this cron script is installed via the package, it is under control of APT and will cause troubles if you modify or move it.

  • Not sure how to exactly solve this, but maybe the apt script would just check where to place the file depending on the environment variable? Not sure how it is possible, just an idea.

    Anyway, the scope of this post is achieved with your answers. Thank you for that. If there will at some point be such a thing to set the period, it would be cool. If it is not possible, it is okay too.

    Anyway, thanks for the help!

  • No, this is not the philosophy of OMV. There is no knob in the UI for every possible feature, setting, ....

    There is already "Storage | S.M.A.R.T. | Scheduled Tasks" - which serves a similar function like scrubbing


    I stumbled over this thread as I noticed a slow SMB ...etc.. and found out that btrfs scrubbing was added.

    I appreciate the effort to improve btrfs support, but I was surprised that OMV doesn't use the existing debian "btrfsmaintenance" package (which also provides a weekly balance!)


    I think I'll use the OMV_BTRFS_SCRUB_ENABLED hack for now

    edit: yes, i'm using debian's btrfsmaintenance

    • Official Post

    but I was surprised that OMV doesn't use the existing debian "btrfsmaintenance" package

    I see no benefit in this. The OMV scripts are doing the exact same thing and can be customized the OMV way using the environment variables OMV_BTRFS_SCRUB_PRIORITY or OMV_BTRFS_SCRUB_READONLY. Second, having own scripts means i have all under my control and can decide how things are implemented.


  • The environment variable OMV_BTRFS_SCRUB_PERIOD will be available with openmediavault 6.3.9, check https://github.com/openmediavault/openmediavault/pull/1529.

    Awesome! Thank you!

    I see no benefit in this. The OMV scripts are doing the exact same thing and can be customized the OMV way using the environment variables OMV_BTRFS_SCRUB_PRIORITY or OMV_BTRFS_SCRUB_READONLY. Second, having own scripts means i have all under my control and can decide how things are implemented.

    I also agree on that!

    I was surprised that OMV doesn't use the existing debian "btrfsmaintenance" package (which also provides a weekly balance!)

    As I was a while ago very active in the BTRFS libera chat IRC channel with btrfs related questions, I can tell you that balancing is not necessarily improving things on your btrfs-filesystem, and can in the worst case even make things worse (space usage etc).
    Please, if someone knows better than me, correct me, but as I understood, the nature of the COW-Filesystem BTRFS usually uses "cp -reflink=auto" which doesnt really copy, but just references the places on the disk, on which the file is saved. So you can have a structure like /path1/file /path2/file and the space used is only the size of the file ONCE. Only when changing parts of a file, it will be added somewhere lse on disk. This saves a lot of space, since only the changed extents of the file are saved. It is also why snapshots are possible and do not consume as much space on the disk.

    Now as you balance in specific scenarios, those reflinks can get broken, and suddenly you will really have 2 copies, therefore you will use much more space what you would use if you didnt balance. Im not sure if this was only the case if you do a btrfs raid or also when using a single one, but I really dont think that openmediavault should suddenly balance your disks.

  • Second, having own scripts means i have all under my control and can decide how things are implemented.

    Sometimes I tend to reinvent the wheel. When I started using btrfs I wanted to write a maintenance script for regularly scrubbing but noticed someone else already did the work (see /usr/share/doc/btrfsmaintenance/README.Debian + /etc/default/btrfsmaintenance).

    If you think it doesn't fit the current architecture, please be kind and ignore my ranting :)


    @ /etc/cron.daily/openmediavault-check_btrfs_errors

    BTW, the stats won't reset automatically even after fixing. Maybe add "--reset" to "btrfs device stats" or instructions in the notification how to reset them?


    @oopenmediavault it actually helps to reclaim free space. I think BTRFS_BALANCE_DUSAGE="1 5 10 20" is default which should only affect almost empty chunks anyway (most of the time it relocates only very few chunks here)

    IIRC only defrag breaks reflinks - Found it! https://btrfs.readthedocs.io/en/latest/btrfs-balance.html "[...] Extent sharing is preserved and reflinks are not broken. [...]"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!