Smartctl on Linux

SMART (Self-Monitoring, Analysis, and Reporting Technology) allows you to see the status or overall health of a hard drive. This information is instumental in providing warning signs of problems with a hard drive.

All Linux distributions provide the smartmontools package, which contain the smartctl program used to display SMART information from attached drives. This package also provides the smartd daemon which periodically polls the drives to obtain SMART information.

Using smartd is essential as it can let you know immediately when a SMART attribute fails.

With the -i option, you can view the type of drive, its serial number, and so forth. In a system with a lot of drives, having this information recorded can assist in knowing which drive device (i.e., /dev/sda) corresponds with which physical drive.

Install:

# yum install smartmontools

Now start the service of Smartctl.


#service smartd start 
# chkconfig smartd on

To enable Smart Capability for the disk run below command.

#smartctl -s on /dev/sdb

To disable Smart Capability for the disk run below command.


#smartctl -s off  /dev/sdb

To display details Smart info for the disk run below command.


#smartctl -a /dev/sdb              // For IDE drive
#smartctl -a -d ata /dev/sdb       // For SATA drive

To begin, see what the drive details are:


[root@austin ~]# fdisk -l

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          62      497983+  83  Linux
/dev/sda2              64         584     4184932+  82  Linux swap / Solaris
/dev/sda3             585       30390   239416695   82  Linux swap / Solaris

Now we know the single drive is sda. Also, you can usually identify which hard disks are on your system by
looking in /proc/ide and in /proc/scsi.

# smartctl -i /dev/sda
root@austin ~]# smartctl -i /dev/sda
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital RE3 Serial ATA
Device Model:     WDC WD2502ABYS-18B7A0
Serial Number:    WD-WCAT19910234
LU WWN Device Id: 5 0014ee 157014252
Firmware Version: 02.03B04
User Capacity:    250,000,000,000 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Thu Nov 27 16:10:20 2014 MST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

[root@austin ~]# smartctl -i /dev/sda
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital RE3 Serial ATA
Device Model:     WDC WD2502ABYS-18B7A0
Serial Number:    WD-WCAT19910234
LU WWN Device Id: 5 0014ee 157014252
Firmware Version: 02.03B04
User Capacity:    250,000,000,000 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Thu Nov 27 16:14:54 2014 MST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Now, edit /etc/smartd.conf and add entries for your drives:


/dev/sda -d ata -H -m root
/dev/sdb -d ata -H -m root

Turn the service on:


# chkconfig smartd on
# service smartd start

The smartctl program also allows for you to view and test SMART attributes of a drive. You can quickly check the overall health of a drive by using:

# smartctl -H /dev/sda

smartctl can be used to initiate long and short tests for the drive. These should be run periodically to do quick, or full, self-tests of the drive:


# smartctl --test=short /dev/sda
# smartctl --test=long /dev/sda
# smartctl -a /dev/sda

More info : https://wiki.archlinux.org/index.php/S.M.A.R.T.