Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Scheduled scrubs?

Featured Replies

Is there a way to schedule regular scrubs of one's btrfs cache pool?

  • 1 year later...

Is there a way to schedule regular scrubs of one's btrfs cache pool?

 

+1

Yes, the setting is user settings/Scheduler

Yes, the setting is user settings/Scheduler

 

I've got parity, mover and fixed schedules in there.. Where should I find the btrfs scrub ?

If you install the Dynamix Trim plugin you can schedule Trim, but I am not aware of anything to schedule scrub. You could schedule a script to do it with the User Scripts plugin.

Trim added is actually a good thought.. I will add that..

 

My whole array is setup of btrfs drives so scheduled scrub would be nice, I will check out your suggestion !

Mmm... major service outage for github in western europe.. i'll try later.

I thought Trim & Scrub were the same thing?

I thought Trim & Scrub were the same thing?

Trim is a function of the drive, Scrub is a function of the filesystem.

If you install the Dynamix Trim plugin you can schedule Trim, but I am not aware of anything to schedule scrub. You could schedule a script to do it with the User Scripts plugin.

 

Github is back, I installed trim (which is a gread addon, I missed that one).

 

I also installed user scripts and have created a very crude little script to do a btrfs scrub of the cache drive:

 

btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log

 

When this is run in the background it works.. It is kind of crude in the sense that the fact that logfile is written does not mean that I will see it...

 

Anyone any idea what I could look at to make this thing use the web browser notification system to report starting and finishing the scrub ?

Anyone any idea what I could look at to make this thing use the web browser notification system to report starting and finishing the scrub ?

Search for "scripts/notify" for examples of using the notifications. There are lots.

btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log

If you don't redirect the output, user scripts will be able to display the output from the script (ie: log) with a simple button press

Anyone any idea what I could look at to make this thing use the web browser notification system to report starting and finishing the scrub ?

Search for "scripts/notify" for examples of using the notifications. There are lots.

/usr/local/emhttp/plugins/dynamix/scripts/notify

will bring up all the options available.

 

btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log

If you don't redirect the output, user scripts will be able to display the output from the script (ie: log) with a simple button press

Anyone any idea what I could look at to make this thing use the web browser notification system to report starting and finishing the scrub ?

Search for "scripts/notify" for examples of using the notifications. There are lots.

/usr/local/emhttp/plugins/dynamix/scripts/notify

will bring up all the options available.

 

Woo.. that is really nicely done.. I wasn't aware the notification system was so easy to use... I am now testing with the following setup:

 

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive started" -i "normal" -m "Scrubbing message"

btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive finished" -i "normal" -m /boot/logs/scrub_cache.log

I am now actually trying to get some finished logfiles so I can see the structure of what is comming back.. With some grep's I think I will be able to assess a possible error condition and change the color of the notification based on that... Should not be very difficult I think..

 

Without actually trying the following should work I guess:

 

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive started" -i "normal" -m "Scrubbing message"
btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log
if grep -q error /boot/logs/scrub_cache.log; then
   /usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Error in scrub of cache drive !" -i "alert" -m /boot/logs/scrub_cache.log
fi
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive finished" -i "normal" -m /boot/logs/scrub_cache.log

Mmm.. was testing with this yesterday and the scrub status looks weird... I have a few preclears running so cannot reset the system at this time.

 

Knipsel.PNG.17cb31373a03f1bbd8c8f596fef5eb5b.PNG

Tested it and it works.. Now what I would need is an example of the btrfs output so I can tailer the notification.. I now did that bases on the text "error" and that failed since the positive outcome tells us there are "0 errrors"..

Found a possible solution... Using the exitcodes..

 

I am now testing the following:

 

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive started" -i "normal" -m "Scrubbing message"
btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log
if [ $? -eq 0 ]
then
   /usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive finished" -i "normal" -m /boot/logs/scrub_cache.log
else
   /usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Error in scrub of cache drive !" -i "alert" -m /boot/logs/scrub_cache.log
fi

  • 3 years later...

I stumbled across this thread after running into a btrfs csum issue, and started looking for a way to schedule a scrub of all the btrfs disks in my system.  Big kudos to Constructor for the idea, Helmonder for the script, and Squid for adding the notify part.  You guys got me there!

 

I figured I summarize what I did to save folks from bouncing around.

 

I basically used Helmonder's script as a starting point.

  • I don't have notify set up to email me, I rely only on GUI notifications, so I dropped the -m part of the notifiy
  • I copied the script to have one for each disk  on my system (i.e. cache, disk1, disk2, etc.), making appropriate changes
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Scrub of cache drive started" -i "normal"
btrfs scrub start -Bdr /mnt/cache > /var/log/scrub_array.log
if [ $? -eq 0 ]
then
  /usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Scrub of cache drive finished" -i "normal"
else
  /usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Error in scrub of cache drive!" -i "alert"
fi
  • I used crontab -e and added entries at the bottom to run each script at 10 pm starting on the 15th of every month, one disk per day.
#
# Run monthly cron jobs at 20:00 on the 15th day of the month:
00 20 15 * * /usr/local/emhttp/plugins/dynamix/scripts/scrub_cache &>/dev/null
#
# Run monthly cron jobs at 20:00 on the 16th day of the month:
00 20 16 * * /usr/local/emhttp/plugins/dynamix/scripts/scrub_disk1 &>/dev/null
...

Notifications look like:

1097272105_ScreenShot2020-07-28at7_43_00PM.jpg.b4153e75844c8eecfe8831028726c32e.jpg

 

@CarpNCod thank you so much for posting that.  I can't believe it was just before I started looking for this, and I only just found out you need to regularly balance the btrfs pool...

 

Thanks to @Helmonder for the original as well.

 

I've taken that and used it to schedule a weekly scrub as well as a monthly balance (same script but running a balance).

I do have a question about the log file though, where do you find that?  I haven't run it yet, but wanted to do a test run and then check out the log file to make sure it works.

I'm also curious since you aren't correcting errors, if it does need to be corrected will it throw and error and alert you in the notification?  I'm not sure if that's the point of the error handling or if it's just if the script/command fails.

 

Edit: Oh and now that I know how to create a notification like that, I'm totally going to go back over my scripts and add more!

Edit2: oh I really don't have any scripts that need notifications, oh well.

Edited by lordbob75

2 hours ago, lordbob75 said:

and I only just found out you need to regularly balance the btrfs pool...

It shouldn't need regular balancing on current kernel, since kernel 4.15 IIRC

49 minutes ago, johnnie.black said:

It shouldn't need regular balancing on current kernel, since kernel 4.15 IIRC

Ok, that's good to know.  I thought mine needed balancing but maybe not now that I look again.  Well for now I won't turn on the balance script and I'll keep a closer eye on it to see if it ever needs it.  Hopefully not, in which case I'll just keep the scrub one.

On 7/28/2020 at 11:46 PM, lordbob75 said:

@CarpNCod

I do have a question about the log file though, where do you find that?  I haven't run it yet, but wanted to do a test run and then check out the log file to make sure it works.

I'm also curious since you aren't correcting errors, if it does need to be corrected will it throw and error and alert you in the notification?  I'm not sure if that's the point of the error handling or if it's just if the script/command fails.

 

Edit: Oh and now that I know how to create a notification like that, I'm totally going to go back over my scripts and add more!

Edit2: oh I really don't have any scripts that need notifications, oh well.

I redirect the output of the scrub command to /var/log/scrub_array.log.  You can call it whatever you want, it will be overwritten each time the script runs.  If you just want to check the status of the last scrub run from the command line use btrfs scrub status /mnt/cache  Substitute for the drive you want the status of.  It will give you pretty much what is in the log file.  

 

You are correct, the point of this is just to let me know there is a problem.  If I get a notification that an error has been found, I check the Unraid syslog in the GUI -- Tools --> System Log.  Look for errors that look like this:  

 

Jul 11 13:10:32 Tower kernel: BTRFS warning (device md3): csum failed root 5 ino 9417 off 0 csum 0xff2f6c6e expected csum 0xfbf6a901 mirror 1

 

This is showing I had a check sum error on my data disk3 inode 9417.  You can then use ls or btrfs to correlate the inode to a file name.  I rename the file, and replace it from backup.  Then I run a scrub on the disk with the repair option.  Finally I go back and remove the renamed file.

  • 4 months later...

Could any of you techno wizards make the script an app or docker add in for idiots like me that just know how to use the the web GUI? 

Please?

Thanks!

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.