First, ensure the smartmontools package is installed. Run the appropriate command for your distribution:
sudo apt update
sudo apt install smartmontoolssudo yum install smartmontoolssudo dnf install smartmontoolsCheck if your disk supports SMART (Self-Monitoring, Analysis, and Reporting Technology):
sudo smartctl -i /dev/sdXReplace /dev/sdX with the appropriate disk (e.g., /dev/sda).
Look for a line that says SMART support is: Enabled. If it’s not enabled, you can activate it with:
sudo smartctl -s on /dev/sdX
sudo smartctl --scan | grep busRun the following command to get an overview of the disk's health:
sudo smartctl -H /dev/sdXThis will return a simple health status (PASSED or FAILED).
To see detailed SMART attributes and statistics, use:
sudo smartctl -A /dev/sdX
sudo smartctl -a -d megaraid,9 /dev/bus/0Look for attributes like Reallocated_Sector_Ct, Current_Pending_Sector, and Temperature_Celsius.
To initiate a self-test, you can choose either a short or long test:
- Short Test (takes a few minutes):
sudo smartctl -t short /dev/sdX- Long Test (can take several hours depending on disk size):
sudo smartctl -t long /dev/sdXYou can check the progress or results of the self-test with:
sudo smartctl -l selftest /dev/sdXFor detailed logs of disk events, use:
sudo smartctl -l error /dev/sdX- Replace /dev/sdX with the actual device identifier of your disk (e.g., /dev/sda, /dev/nvme0n1).
- Running SMART commands on disks in a RAID array may require using specific utilities or bypassing the RAID controller.