JimPhreak Posted January 5, 2016 Share Posted January 5, 2016 Is there a way to schedule regular scrubs of one's btrfs cache pool? Quote Link to comment
Helmonder Posted January 13, 2017 Share Posted January 13, 2017 Is there a way to schedule regular scrubs of one's btrfs cache pool? +1 Quote Link to comment
NeoDude Posted January 13, 2017 Share Posted January 13, 2017 Yes, the setting is user settings/Scheduler Quote Link to comment
Helmonder Posted January 13, 2017 Share Posted January 13, 2017 Yes, the setting is user settings/Scheduler I've got parity, mover and fixed schedules in there.. Where should I find the btrfs scrub ? Quote Link to comment
trurl Posted January 13, 2017 Share Posted January 13, 2017 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. Quote Link to comment
Helmonder Posted January 13, 2017 Share Posted January 13, 2017 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 ! Quote Link to comment
Helmonder Posted January 13, 2017 Share Posted January 13, 2017 Mmm... major service outage for github in western europe.. i'll try later. Quote Link to comment
NeoDude Posted January 13, 2017 Share Posted January 13, 2017 I thought Trim & Scrub were the same thing? Quote Link to comment
trurl Posted January 13, 2017 Share Posted January 13, 2017 I thought Trim & Scrub were the same thing? Trim is a function of the drive, Scrub is a function of the filesystem. Quote Link to comment
Helmonder Posted January 13, 2017 Share Posted January 13, 2017 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 ? Quote Link to comment
trurl Posted January 13, 2017 Share Posted January 13, 2017 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. Quote Link to comment
Squid Posted January 13, 2017 Share Posted January 13, 2017 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. 1 Quote Link to comment
Helmonder Posted January 14, 2017 Share Posted January 14, 2017 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 Quote Link to comment
Helmonder Posted January 14, 2017 Share Posted January 14, 2017 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. Quote Link to comment
Helmonder Posted January 15, 2017 Share Posted January 15, 2017 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".. Quote Link to comment
Helmonder Posted January 15, 2017 Share Posted January 15, 2017 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 1 1 Quote Link to comment
CarpNCod Posted July 29, 2020 Share Posted July 29, 2020 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: 2 Quote Link to comment
lordbob75 Posted July 29, 2020 Share Posted July 29, 2020 (edited) @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 July 29, 2020 by lordbob75 Quote Link to comment
JorgeB Posted July 29, 2020 Share Posted July 29, 2020 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 1 Quote Link to comment
lordbob75 Posted July 29, 2020 Share Posted July 29, 2020 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. Quote Link to comment
CarpNCod Posted August 1, 2020 Share Posted August 1, 2020 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. Quote Link to comment
BigDaddyMoe Posted December 10, 2020 Share Posted December 10, 2020 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! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.