Skip to content

Instantly share code, notes, and snippets.

@killerbees19
Last active April 15, 2022 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerbees19/332553fc18be2fcb089c07682079a9d7 to your computer and use it in GitHub Desktop.
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
#!/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