2024-12-12
Before diving into specific commands, ensure smartctl
is installed on your system. The package name might vary slightly depending on your distribution. For Debian/Ubuntu based systems, use:
sudo apt update
sudo apt install smartmontools
For Fedora/CentOS/RHEL:
sudo dnf install smartmontools
After installation, you can verify the installation by running:
smartctl --version
This will display the version number and other relevant information.
The first step is identifying the storage devices connected to your system. You can achieve this using lsblk
:
lsblk
This command will list all block devices, including hard drives, SSDs, and partitions. Note the device names (e.g., /dev/sda
, /dev/sdb
). These names are for targeting specific drives with smartctl
.
To obtain a basic overview of a drive’s SMART attributes, use the following command, replacing /dev/sda
with the appropriate device name from lsblk
:
sudo smartctl -a /dev/sda
The -a
option provides a detailed report including SMART attributes, self-test results, and device information. The output is extensive and provides information on the drive’s health. Look for attributes with “Failing” or “Warning” status.
Instead of the full report, you might want to focus on specific SMART attributes. For instance, to check the reallocated sector count (attribute 5):
sudo smartctl -a -A /dev/sda | grep -i "5 Reallocated Sector Count"
This command uses grep
to filter the output of smartctl -a -A
(which provides attributes in a more concise numerical format), displaying only the line related to reallocated sector count. A high value here indicates potential problems.
smartctl
allows initiating self-tests. A short self-test is typically quick, while an extended test is more thorough but takes considerably longer.
To run a short self-test:
sudo smartctl -t short /dev/sda
To run an extended self-test:
sudo smartctl -t long /dev/sda
After initiating a self-test, monitor its progress using:
sudo smartctl -g /dev/sda
This command shows the test’s status.
Many SMART attributes have pre-defined thresholds. Exceeding these thresholds often signifies impending failure. While the exact thresholds vary depending on the drive model, smartctl
displays these values in its output, aiding in interpretation.
smartctl
offers numerous other options for advanced usage. For example, you can retrieve error logs, manage drive settings (where applicable), and more. Consult the smartctl
manual page (man smartctl
) for a complete list of options and their functionalities. The manual provides in-depth explanations for every option and parameter available, for effectively using this powerful tool.