Script for a daily SMART short self-test and a weekly SMART extended self-test


Recommended Posts

Being an Unraid newbie because I've been running TrueNAS servers for 4-5 years now, please correct me if I'm wrong: 

In the last years I avoided some critical data loss because of failing HDDs: as a kind of an early warning system I ran a script on my (TrueNAS) servers that ran a a daily SMART short self-test and a weekly SMART extended self-test. 

I'm not sure wether Unraid:
 

  1. does run SMART tests out of the box on a regularly basis?
     
  2. if it's possible there is a script that can achieve this? (e.g. via user scripts plugin?)
     
  3. if this is necessary with Unraid or does Unraid provide some other kind of automated early warning system regarding HDD/SSD damage/erros?

 

Thank you very much for your input, I did not find anything like this script in the forum or CA.

 

Link to comment

Unraid does not currently have a way to scheduled SMART tests, this was less important in the past since for the array a parity check is basically the same as an extended SMART test, but now with more users using pools it would be important to have them, in them meantime you can create a user script to do that for any pools, note that you must disable spin down or the test will be interrupted.

  • Upvote 1
Link to comment
  • 2 weeks later...

Quick solution 17.01.2024: 

 

Since I have no script/programming skills but I really want this "safety net of SMART tests" for my array I looked around what I could achieve myself, this is what I found...

And believe it or not it's working successfully 😉

 

Step 1: install "User Scripts" via the CA plugin/app store
 

Step 2: go to the "User Scripts" plugin and set up a new script (please find screenshots attached) 
 

Step 3: find the correct /dev/sdX (X stands for the letter of your array HDD, look under "MAIN" in your Unraid GUI) of all your array HDDs you want to test and then paste commands in your new script you find in the second screenshot attached. As I have 6 HDDs in my array atm my letters run from b, c, d, e, f to g (parity HDD included) 

Step 4: save the script and let it test run in the background

 

Step 5: check your logs. If everything went smoothly you can now add a cron schedule at which the script should run. For me (see screenhot 1) I run the script daily at 1 minute past 1 o'clock ( 01.01 am)

 

The script only runs a daily SMART short selftest, for adding a weekly SMART long/extend test you can write "smartctl  -d  ata  -tlong  /dev/sdX" (X stands for the letter of your array HDD)

Hope that was helpful for all of you with no scripting skills like myself and please feel free and comment this. Constructive criticism very welcome since I have no script/programming skills. 


 

2024-01-17_18-12.png

2024-01-17_18-13.png

Edited by Mr.Slumber
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.