Linux Commands and Scripts

Steps to install Smartctl Utility On CentOS 7

S.M.A.R.T. is a system in modern hard drives designed to report conditions that may indicate impending failure. smartmontools is a free software package that can monitor S.M.A.R.T. attributes and run hard drive self-tests. Although smartmontools runs on a number of platforms, I will only cover installing and configuring it on Linux.

Smartctl (Self-Monitoring, Analysis and Reporting Technology) is a command line utility or a tool in UNIX like operating system that perform SMART tasks such as printing the SMART self-test and error logs, enabling and disabling SMART automatic testing, and initiating device self-tests.

Installation of Smartcl

# yum install smartmontools

Start and enable the Smartctl Service

# systemctl start smartd ; systemctl enable smartd

Check Whether Smart Capability is enabled or not for the disk

# firewall-cmd –zone=public –remove-port=80/tcp

# smartctl -i /dev/sda

If above command fails, you may need to tell smartctl that what type of hard drive interface you are using:

# firewall-cmd –zone=public –list-ports

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

Replace /dev/sda with your hard drive’s device file. The output of the command:

=== START OF INFORMATION SECTION ===
 Model Family:     SAMSUNG SpinPoint T133 series
 Device Model:     SAMSUNG HD300LJ
 Serial Number:    S0D7J1UL303628
 Firmware Version: ZT100-12
 User Capacity:    300,067,970,560 bytes
 Device is:        In smartctl database [for details use: -P show]
 ATA Version is:   7
 ATA Standard is:  ATA/ATAPI-7 T13 1532D revision 4a
 Local Time is:    Fri Jan  2 03:08:20 2009 EST
 SMART support is: Available - device has SMART capability.
 SMART support is: Enabled

Enable Smart Capability for the disk

# smartctl -s on -o on -S on /dev/sda

Output of the command:

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
 SMART Enabled.
 SMART Attribute Autosave Enabled.
 SMART Automatic Offline Testing Enabled every four hours.

Disable Smart Capability for the disk

# smartctl -s off /dev/sdb

Display Overall health of the Disk

# smartctl -H /dev/sdb

Output of the command:

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

Let’s make sure that the drive supports self-tests.

# smartctl -c /dev/sda

Output of the command:

Short self-test routine
recommended polling time:      (   2) minutes.
Extended self-test routine
recommended polling time:      ( 127) minutes.

Test Hard drive using long option.

# smartctl –test=long /dev/sdb

Test Hard drive using short option.

# smartctl –test=short /dev/sdb

You can run to check results.

# smartctl -l selftest /dev/sda

=== 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%     21472         -

Display Error logs of the disk

# smartctl -l error /dev/sdb

Manpages

man 8 smartctl
man 8 smartd
man 8 update-smart-drivedb
man 5 smartd.conf

Related Articles