How to Run smartctl
Test to Check Disk Status on a Linux Server
Follow these steps to check the status of a disk using smartctl
:
1. Install smartmontools
Ensure the smartmontools
package is installed. This tool includes smartctl
.
- On Debian/Ubuntu:
sudo apt update sudo apt install smartmontools
- On RHEL/CentOS/AlmaLinux/Rocky:
sudo yum install smartmontools
2. Identify the Disk
List your disks to find the target device name (e.g., /dev/sda
):
lsblk
3. Check SMART Support
Verify if the disk supports SMART:
sudo smartctl -i /dev/sda
Look for the line:
SMART support is: Enabled
If it’s not enabled, you can enable it:
sudo smartctl -s on /dev/sda
4. Run a SMART Test
Run the desired SMART test depending on the situation:
- Short Test (Quick check, takes a few minutes):
sudo smartctl -t short /dev/sda
- Long Test (Thorough check, can take hours):
sudo smartctl -t long /dev/sda
- Conveyance Test (Detects damage during transport):
sudo smartctl -t conveyance /dev/sda
5. Check Test Progress
While the test is running, check its status:
sudo smartctl -c /dev/sda
6. View Test Results
Once the test is complete, view the results:
sudo smartctl -a /dev/sda
Key Sections in Output:
- SMART overall-health self-assessment test result: Should indicate
PASSED
. - Reallocated Sector Count: Should ideally be
0
. High numbers indicate potential disk failure. - Current Pending Sector Count: Any non-zero value suggests bad sectors.
- Errors in the SMART log: Review error counts.
7. Automate Monitoring (Optional)
You can schedule periodic SMART checks using cron
or system monitoring tools.