smartctl
Linux interface to SMART data for hard disks.
Examples
Show identifying information about a device
smartctl -i /dev/sda
Show drive attributes
This shows a bunch of recorded information that is updated over the life of the drive.
smartctl -A /dev/sda
Show the same information with better output showing vendor flags
smartctl -A -f brief /dev/sda
Show all data
smartctl -x /dev/sda
Perform a self test
smartctl -t short /dev/sda
View the results of a self test
Make sure to check for the presence of a "Self-test routine in progress" line.
smartctl -l selftest /dev/sda
Show how many hours each drive has been powered on
$ lsblk -I8 -pdo NAME,SIZE,MODEL,SERIAL -n |
while read -r drive size extras ; do
echo "$drive|$(sudo smartctl -A "$drive" | awk '/Power_On_Hours/ {print $NF}')|$size|$extras"
done | column -s'|' -t
/dev/sda 35265 238.5G Samsung SSD 850 S33KNX0JB59421F
/dev/sdb 41261 7.3T HGST HUH728080AL VKHAVT1X
/dev/sdc 41305 7.3T HGST HUH728080AL VKH46K7X
/dev/sdd 41320 7.3T HGST HUH728080AL VKH82NNX
/dev/sdf 73 10.9T HGST HUH721212AL 8CK26DWK