New Disk Stress Test6 min read

I bought a few new disks and wanted a better way to weed out marginal disks before I deployed them.

I don’t use UnRAID at home, but I liked the idea of their preclear script. I have modified it to remove a number of unnecessary options, but it works at this point, so I thought I would post it. How does it work?

The script:
* gets a SMART report
* pre-reads the entire disk
* writes zeros to the entire disk
* sets the special signature recognized by unRAID
* verifies the signature
* post-reads the entire disk
* optionally repeats the process for additional cycles (if you specified the “-c NN” option, where NN = a number from 1 to 20, default is to run 1 cycle)
* gets a final SMART report
* compares the SMART reports alerting you of differences.

It also has the option to run a (4) pass destructive write pass with badblocks. If a disk can make it through this, I can confidently use it in my fileserver. I’m still working on getting the options to work correctly, but it does run with the basic options at this point. By default, this option is on. This option can add 30 hours to the runtime on a large disk. If you want to turn it off, change the use_badblocks=1 at the beginning to say use_badblocks=0.

**WARNING: This will completely overwrite your disk!!!**
This does perform some sanity tests to make sure your disk is available, isn’t in use, or mounted before it runs.

You use it like this.

Here is the script.



I love learning new things and trying out the latest technology.

You may also like...

6 Responses

  1. srnoob says:

    Thanks for the script.

    I think WordPress has messed up the formatting though, eg the last line:

    echo -e “$report_out ” > /root/disk_test_results.txt

    I’m sure the “>” is meant to be a “>” symbol. There’s a lot more examples in the script as well.

  2. srnoob says:

    Wow, that’s funny, it came out correct in my comment. Anyway the ampersands and greater than symbols are being mangled. I took a screenshot at

  3. harpz1907 says:

    Thought i would give your script a try as usually run badblocks manually on a new drive.

    Started the script and can see in the tmp directory the first smart report but after the first run of bad blocks and where it gets the next (mid) smart report i get a file called “smart_mid__” and when i look in this file i whats below, looks like the disk name isn’t passed along?

    smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-131-generic] (local build)
    Copyright (C) 2002-16, Bruce Allen, Christian Franke,

    ERROR: smartctl requires a device name as the final command-line argument.

    Use smartctl -h to get a usage summary

    Tried to have a look for the problem but this is beyond my knowledge which is basic.

    Thanks and keep up the great work.

    • Zack Zack says:

      I’d have to dive back through this whole script to troubleshoot it for you. Honestly, I don’t even use this myself anymore. I just check the SMART attributes before I start. Run badblocks with the -wsv options (only on empty disks!!), in a tmux or screen session, and then check the SMART attributes at the end when it’s done. It’s simple, but it works very reliably 🙂

    • Zack Zack says:

      Also, here is a great script off the servethehome forums that can automate the process for you as well.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.