SMART – Take the control

Sometimes, you’re hard drive isn’t working as you expect. Or sometimes, you wonder if your hard drive is in good health. Since 2003, manufacturers integrate a system to monitor predictable failures directly on hard drive.It helps companies, but also individuals to be alerted when the hard disk goes to death! A good guide to understand what is predictable or not : PC Tech Guide.

This technology, S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) is embedded on the device. We’ll explain how to get enable S.M.A.R.T. on hard drives, then check the disk to get errors.

In the following example, let assume the device we need to check is /dev/sda

  • Install – if you don’t have it

# apt-get install smartmontools 
  • Check the status

# smartctl -i /dev/sda 
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Model Family: Maxtor DiamondMax Plus 9 family
Device Model: Maxtor 6Y080M0

Serial Number:    Y213233E
Firmware Version: YAR51EW0
User Capacity: 81 964 302 336 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 0
Local Time is: Mon Jan 5 22:58:26 2009 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

The important lines are the two last. Lucky us, the drive support SMART technology. As SMART has been widely spreed, most of current hard drive should support this technology. But some old drives don’t support it : to check health, search with ‘testdisk’.

  • Activate or deactivate the SMART utility

# smartctl -s on -d ata /dev/sda
# smartctl -s off -d ata /dev/sda
  • Update information

There is three basic categories of testing. Quoting the man : 

  • The first category, called « online » testing, has no effect on the performance of the device.
  • The second category of testing is called « offline » testing. This type of test can, in principle, degrade the device performance.
  • The third category of testing (and the only category for which the word ´testing´ is really an appropriate choice) is « self » testing.

The difference among these categories will be the behavior to update information. Check the man, with option -o to know what you prefer. In our case, we want to run a test NOW, so we use the option -t, or –test. We use the value « offline » to update the data, but we could have put « short » to run a short test, or another value. Again, the best resource is the man.
The offline test will proceed inspection of the hard drive, and report errors in log we will display later. Finally, this command indicates how many times we have to wait before inspection end.

#smartctl -t offline /dev/sda
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART off-line routine immediately in off-line mode".
Drive command "Execute SMART off-line routine immediately in off-line mode" successful.
Testing has begun.
Please wait 241 seconds for test to complete.
Test will complete after Mon Jan 5 22:51:54 2009

In our case, the test was on 241 seconds. You can interrupt the SMART offline test with the option -X (smartctl -X). 

  • Get back disk status

To make simple, we just display all information with the -a option. But you could determine what is really important by trying the option -l (or –log). See the manpages if you need more information.

 #smartctl -a /dev/sda 

The result is really verbose, so we won’t show it.

  • I’m in hurry, give me the test result, quick!

 To know if your disk status is well, just run the command below

#smartctl -H /dev/sda
 smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

And in one line it will tell you if the test succeed or not.

  •  A daemon?

To be alerted in errors, or for your status, the package smartmontools include a daemon : smartd. 

You can edit the configuration file to manage what kind of alert you want to receive, Edit the file /etc/smartd.conf which is really verbose. 

I hope it will help someone to manage your hd status quickly.

Gabriel {jcomments on}

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *