Skip to content

Instantly share code, notes, and snippets.

@KpuCko
Forked from tommybutler/smartcheck.sh
Last active March 16, 2025 14:49
Show Gist options
  • Save KpuCko/ed2eb3683fc9a7b9bcda68609dd107f4 to your computer and use it in GitHub Desktop.
Save KpuCko/ed2eb3683fc9a7b9bcda68609dd107f4 to your computer and use it in GitHub Desktop.
Script to quickly scan the S.M.A.R.T. health status of all your hard drive devices in Linux (at least all the ones from /dev/sda to /dev/sdzz). You need smartctl installed on your system for this script to work, and your hard drives need to have S.M.A.R.T. capabilities (they probably do).
#!/bin/bash
# install the smartctl package first! (apt-get install smartctl)
UID=$(id -u)
if [ $UID -eq 0 ]
then
true
else
echo 'Root privileges required'
exit 1
fi
for drive in /dev/ada[0-99] /dev/ada[0-99]
do
if [[ ! -e $drive ]]; then continue ; fi
echo -n "$drive "
smart=$(
smartctl -H $drive 2>/dev/null |
grep '^SMART overall' |
awk '{ print $6 }'
)
[[ "$smart" == "" ]] && smart='unavailable'
echo "$smart"
done
@KpuCko
Copy link
Author

KpuCko commented Jan 6, 2021

Adopted to work on BSD systems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment