Run SMART test on all SATA drives

From Michael's Information Zone
Jump to navigation Jump to search
#!/bin/bash
##Create list of all possible sata block devices
for i in {a..z}
do
echo sd$i >> /tmp/drivelist
done
##Check if the drive exists, if it does run the long smart test.
while read line
do
smartctl -H /dev/$line > /tmp/asdasd
if grep -q "No such device" /tmp/asdasd; then
rm -f /tmp/asdasd
else
rm -f /tmp/asdasd
smartctl -t long /dev/$line &> /dev/null
fi
done < /tmp/drivelist
rm /tmp/drivelist