Last active
April 15, 2022 11:05
-
-
Save killerbees19/332553fc18be2fcb089c07682079a9d7 to your computer and use it in GitHub Desktop.
TrueNAS CORE: Weekly selective S.M.A.R.T. test of 1/4 of all LBAs on all HDDs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
week=$((($(date +%-d) + 6) / 7)) | |
status=0 | |
if [ "$week" -lt 5 ] | |
then | |
for disk in /dev/ada? | |
do | |
if [ -e "$disk" ] | |
then | |
lba=$(($(camcontrol identify "$disk" | grep '^LBA48' | grep -Eo '[0-9]+ sectors' | cut -d ' ' -f 1) / 4)) | |
smartctl -t "select,$((lba * (week - 1)))-$((lba * week - 1))" "$disk" || status=1 | |
fi | |
done | |
fi | |
if [ "$status" -ne 0 ] | |
then | |
echo "ERROR: smartctl failed!" >&2 | |
fi | |
exit "$status" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment