Check HDD status with smartmontools
The recent demise of a server because of a hard drive failure inspired me to brush up my knowledge of command-line monitoring tools. I have used smartmontools
in the past, and I needed a refresher on smartctl
.
Given a /dev/sdX
device, you can get a quick health report as follows:
$ smartctl -H /dev/sdX
For a full report, do this:
$ smartctl -a /dev/sdX
The values to be worried about are in the WHEN_FAILED
column of the SMART Attributes
table. To see this table only, run the following command:
$ smartctl -A /dev/sdX
What I didn't remember, and I relearned today, is that you can run tests (both short and long) in the background:
$ smartctl -t short /dev/sdX
(or -t long
)
Most importantly, you can poll the test progress with the following:
$ smartctl -a /dev/sdX | grep -A 1 "Self-test execution"