2

The btrfs-scrub manpage says:

The user is supposed to run it manually or via a periodic system service. The recommended period is a month but could be less.

For systemd users how is this automated, capturing all output in the journal?

I am running Manjaro based on Arch Linux.

3

Arch Linux supplies btrfs-progs with a .timer unit file for btrfs-scrub that can be activated with:

systemctl enable btrfs-scrub@-.timer

The dash ("-") after the @ symbol is used to indicate the root directory, see the ArchWiki page for more on this:

https://wiki.archlinux.org/index.php/Btrfs#Start_with_a_service_or_timer

To check the status, use:

systemctl list-timers

Or:

journalctl -u btrfs-scrub@-.{timer,service}

  • Thanks - can't believe I missed that part in the wiki. Perhaps others will too. – Tom Hale Feb 6 '17 at 13:27
1

Being a virtuously lazy sysadmin, I came up with the following which will start and enable the btrfs-scrub@XXX.timer on all currently mounted btrfs filesystems:

awk '$3=="btrfs" { system("systemd-escape " $2 "| cut -c2-") }' /etc/fstab | while read -r fs; do
    [[ -z $fs ]] && fs=- # Set to '-' for the root FS
    sudo systemctl enable btrfs-scrub@"$fs".timer
    sudo systemctl start btrfs-scrub@"$fs".timer
done

Credit to @Head_on_a_Stick for pointing me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.