smartd
is a daemon (a helper program) that monitors the health of physical hard disk drives that are “Self-Monitoring, Analysis, and Reporting Technology” (S.M.A.R.T.) capable. By using the S.M.A.R.T. monitoring tool, we can avoid premature drive failures by detecting potential problems early on.
Installing smartd
Run the following command to install the S.M.A.R.T.
tool as it is not installed by default:
On CentOS/RedHat/Fedora
# yum install smartmontools
On Ubuntu
# apt-get install smartmontools
The smartd daemon is usually started at boot time and is configured by editing the file /etc/smartd.conf
.
Verifying if disks are S.M.A.R.T. capable
To determine if the disks available on the system are SMART capable, issue the below command.
# smartctl -i /dev/sda
If got output as: “SMART support is: Available – device has SMART capability" indicates that the HDD is SMART capable, and “SMART support is: Enabled” indicates that it is enabled.
Configuring smartd to run only on selective disks
The file /etc/smartd.conf can be edited to configure smartd to monitor only the devices you want. Assuming only /dev/hda needs to be monitored and that one wants a message sent to root if a warning is issued, /etc/smartd.conf will contain:
# cat /etc/smartd.conf
/dev/hda -a -m root@localhost.localdomain ...
Restart the ‘smartd’ daemon after editing /etc/smartd.conf:
# /sbin/service smartd restart Shutting down smartd: [ OK ] Starting smartd: [ OK ]
To set smartd to start at boot time, issue the command chkconfig smartd on as a root user.
# chkconfig on smartd
To start/enable the service in CentOS/RHEL 7:
# systemctl enable smartd # systemctl start smartd
Note:
Configuration file’s in CentOS/RHEL 7 are located under /etc/smartmontools/smartd.conf
To check for bad blocks or disk errors
The smartctl command provides many disk statistics and tests the drives. Below are few examples to quickly check for bad blocks or disk errors.
The command below will check the overall health of the disk.
# smartctl -H /dev/sdd
Running smartctl in the background
To start a background test run the following as root:
# smartctl -t long /dev/sdd
To access the results, use the following command:
# smartctl -a /dev/sdd
To learn more about various options that can be used with smartctl view the man page of the command:
# man smartctl