Smartctl is basically a Self-Monitoring, Analysis and Reporting Technology which is an effective 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.
Most Website Administrators monitor the current status and health of hard drives via the SMART attributes.
Getting smartctl installed on your Linux server can be done easily as will be seen in this guide.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks.
In this context, we shall look into how to install and set up smartctl on Linux.
To install SmartCTL, execute the following command;
yum install smartmontools
As soon as the installation is completed, you need to enable it and enable it to start on boot by running the command below;
systemctl enable smartd
To start smartd service and to check its status, run the following commands;
systemctl start smartd
systemctl status smartd
The process of installing SmartCTL on Ubuntu Server is similar to that of CentOS. To install it, execute the following command;
apt-get install smartmontools
Likewise, enable and start SmartCTL the same way we did for CentOS in the previous step.
Smartctl can be used to perform various hard drive tests.
You can analyze a faulty drive or perform an ATA/SCSI test based on our HDD type.
To check if smartctl is enabled, simply execute the following command;
smartctl -i /dev/vda
Here, replace "/dev/vda" with the correct disk label which can be obtained from the output of "df -h" command.
A sample output when you run the above command will look like this;
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.19.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: QEMU
Product: Vz HARDDISK0
Revision: 2.5+
Compliance: SPC-3
User Capacity: 42,949,672,960 bytes [42.9 GB]
Logical block size: 512 bytes
LU is thin provisioned, LBPRZ=0
Serial number: e603b97ac34343e582bb
Device type: disk
Local Time is: Tue Oct 6 15:37:02 2020 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
The last two lines of the above output signifies that smartctl is enabled for the drive.
If the output indicates that SMART support is available, but not enabled, we can run this command to enable it.
smartctl -s on -o on -S on /dev/vda
To disable SMART capabilities on the hard drive, simply execute the command below;
smartctl -s off /dev/vda
To display the overall health of the hard drive, simply run the following command;
smartctl -H /dev/vda
The output will look like this:
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.19.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK
To make sure that the drive is capable of running tests on its own, run the following command;
smartctl -H /dev/vda
When running Long/Short Test
To run a short or long test on the HDD, execute the commands below:
smartctl –test=short /dev/vda
smartctl –test=long /dev/vda
This article will guide you on how to install and configure Smartctl which is a Monitoring and Analysis tool for Hard drive which helps to detect any potential problems with the hardware.