BTRFS: how to create a sheduled scrub job?

  • Hey,


    I'm pretty happy so far with my Odroid HC2 and OpenMediaVault.


    However I've read that when using BTRFS as a file system you should do regular scrub jobs. I was swayed by the idea of a self-heling file system, so I thought I wouldn't have to do anything.
    Now I feel rather scared and I would like to automate the scrub. But I can't find any tutorial or example on how to do it.


    So how do I create an automatic scrub in the gui for btrfs on 4.1.14-1 every 14 days?


    Best regards

    • Offizieller Beitrag

    You might find what you need -> here.


    In basic terms, you can set the command line btrfs scrub , in the GUI under System, Scheduled Jobs, +Add and schedule it to run as you like. (While it's a matter of preference, once a month should do it. The 15th day of the month?)


    Again, while it's preference, I'd consider setting a second automated command btrfs status to run the day after the scrub. If you have contact information set under System, Notification, you could get the output of "btrfs status" e-mailed to you.

  • Thank you.


    I was wondering about all those additional options and I don't really know this means for example: " [-BdqrRf] [-c <ioprio_class> -n <ioprio_classdata>] <path>|<device> "


    I've set it up to just do btrfs scrub on the first day of each month at 10 o'clock, with btrfs status following the next day. It's just a single wd red with 4tb and 2 partitions, so I hope it'll be fast.


    I was playing around with the btrfs tool under ssh before, but it just always returned btrfs scrub start with "too few parameters" and since I had no idea I thought it might be better to ask.


    However, if btrfs scrub works in the gui I'm happy. :)

    • Offizieller Beitrag

    The options are explained on the btrfs man page.


    The command to start a scrub job looks like this
    btrfs scrub start /srv/dev-disk-by-label....


    You need to adjust the path (/srv/dev-disk-by....) according to your system.


    This is a good and short description.
    https://www.thegeekdiary.com/h…ng-on-btrfs-file-systems/

    • Offizieller Beitrag

    As @macom demo'ed a few extra details are required. :)
    ________________________________________________


    You can also use Scheduled Jobs to set up helper commands for convenience, such as btrfs scrub cancel , without enabling them. You can run them manually, using the run button. The run button is also a good way of determining if a command line is working correctly.

    • Offizieller Beitrag

    If you're not going to physically move your drives (in a hot plug chassis for example) I'd go with btrfs scrub start /dev/sda1


    Otherwise, the command that uses dev-disk-by-id-ata-WDC_WD40EFRX will follow the drive, if it's moved to another SATA/SAS port.
    Either way works fine. It's a matter of preference.
    _________________________________________________________


    You mentioned self-healing files earlier. I''ll take it that you're aware that actual self healing files, as in auto correcting bit-rot, a corrupt file, etc., requires 2 file copies which comes from the BTRFS equivalent of RAID1. With a "RAID1 like" BTRFS array, a scrub will repair a file that don't match its checksum, by overwriting it with the second copy of the file that does match its checksum.


    That's not to say that running scrubs on a single disk is a bad thing because, if errors are noted, you'd get a heads up that's something is going on with your drive. I.E. a closer look and/or corrective action is called for.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!