Skip to content

Instantly share code, notes, and snippets.

@maesoser
Created April 20, 2025 23:08
Show Gist options
  • Save maesoser/d54239dcebeefbc6cf010e38e1739ee8 to your computer and use it in GitHub Desktop.
Save maesoser/d54239dcebeefbc6cf010e38e1739ee8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# install the smartctl package first! (apt-get install smartctl)
if sudo true
then
true
else
echo 'Root privileges required'
exit 1
fi
for drive in /dev/sd[a-z] /dev/sd[a-z][a-z]
do
if [[ ! -e $drive ]]; then continue ; fi
echo -n "$drive "
smart=$(
sudo smartctl -H $drive 2>/dev/null |
grep '^SMART overall' |
awk '{ print $6 }'
)
[[ "$smart" == "" ]] && smart='unavailable'
echo "$smart"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment