SMART is a disk health monitoring and health checking utility. Also, it provides information about various parameters of the hard disk Most of the hard disks supports SMART feature. SMART work with IDE/ATA, SATA and SCSI hard disks.

The Smartctl utility can be installed on Ubuntu server using the following command

sudo apt-get install smartmontools. It can be installed on Centos server using the following command

yum install smartmontools

The following command will enable the smart service on the server.

Use following command for Ubuntu server

$ sudo /etc/init.d/smartmontools start

Use following command for Centos server

#service smartd start ; chkconfig smartd on

Following command will helps to ensure that the hard disk supports SMART and it is enabled on the server

smartctl -i /dev/sdc

sudo smartctl -i /dev/sdc

An example output for the above command is provided below.

smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-531.23.3.lve1.2.66.el6.x86_64] (local build)
Copyright (coffee) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

START OF INFORMATION SECTION
Device Model: INTEL SSDSC2BW240A4
Serial Number: CVDA415206782403GN
LU WWN Device Id: 5 5cd2e4 04bc0c33b
Firmware Version: DC32
User Capacity: 240,057,409,536 bytes [240 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ACS-2 (unknown minor revision code: 0xffff)
Local Time is: Fri Feb 20 12:29:20 2015 SAST
SMART support is: Available – device has SMART capability.
SMART support is: Enabled

The last two lines of the out put which indicates whether SMART support is available and enabled.

Following command can be used to enable smart support for the disk

smartctl -s on /dev/sda

Following command can be used to disable smart capability for the disk

smartctl -s off /dev/sdb

Following command will give detailed smart info for the disk

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

SMART tool have two different tests. Each of these tests can be performed in two modes:

Foreground Mode
Background Mode

Priority of the test is low in the background mode which means the normal instructions continue to be processed by the hard disk and if the disk is busy, the test is paused and then continues at a lower load speed, so there will no interruption of the operation

All commands will be answered during the test with a “CHECK CONDITION” status in the foreground mode and this mode is only recommended when the hard disk is not used. Background mode is the preferred mode for testing the hard disk health

ATA/SCSI Tests:

There are two type of test comes in this category: Fast test and short test

Short Test:

The main purpose of the short test is the rapid identification of a defective hard drive. Its maximum run time is 2 min. The short test will checks the disk by dividing it into three different segments. The following areas are tested in the short test:

Electrical Properties: The controller will test its electronics. However, this is specific to each manufacturer, it can’t be explained exactly what is being checked.

Mechanical Properties: The positioning mechanism and the sequence of the servos will be tested and it is also specific to each manufacturer.

Read/Verify: It will read a perticular area of ??the disk and verify that particular data, the size and position of the region that is read is also specific to each manufacturer.

Long Test

long have two differences with the short test. The first one it that there is no time restriction and the second one is that, in the Read/Verify segment, the entire disk will be checked. So the long test can be used to confirm the results got from the short tests.

ATA specified Tests:

All tests listed below are only apllicable for ATA hard drives.

Conveyance Test:
Conveyance test can be used to find damage during transport of the hard disk within last few minutes.

Select Tests:
Specified range of LBAs will be checked during the select test. The LBAs wchich need to be checked can be specified in the formats shown below:

smartctl -t select,20-30 /dev/sda #LBA 20 to LBA 30 (incl.)
smartctl -t select,10+11 /dev/sda #LBA 10 to LBA 20 (incl.)

We will get an approximate indication of the time duration required for smart tests using the following command:

smartctl -c /dev/sda

Example output for the above command is provided below

[…]
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 48) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
[…]

The following command will start the desired test which you need to perform in Background Mode

smartctl -t <short|long|conveyance|select> /dev/sda

Example output is provided below

smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-531.23.3.lve1.2.66.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION
Sending command: “Execute SMART Short self-test routine immediately in off-line mode”.
Drive command “Execute SMART Short self-test routine immediately in off-line mode” successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Fri Feb 20 14:03:18 2015

Use smartctl -X to abort test

Use the option “-C” with the above command to perform the test in foreground mode

Following command can be used to viewing the test result

smartctl -t -C <short|long|conveyance|select> /dev/sda

Following command will retrieve the log of the selftest

smartctl -l selftest /dev/sdc

Example output of the above command is provided below

smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-531.23.3.lve1.2.66.el6.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

START OF READ SMART DATA SECTION
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 845 –
# 2 Extended offline Completed without error 00% 845 –
# 3 Short offline Completed without error 00% 845 –