Run SMART test on all SATA drives

From Michael's Information Zone
Revision as of 15:44, 7 August 2016 by Michael.mast (talk | contribs) (Created page with "<pre> #!/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 sma...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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