Sometimes you need to check the health status of a SSD or HDD. For instance, when you buy a second hand one. Or when you are preparing a RAID array and you want to make sure there is no disk close to its end-of-life. In Linux you can do so with a few commands.
Modern drives are SMART
Sometimes you put your hands on some SSD or HDD where you don’t really know their history – for instance when you buy a second hand one. It’s important to get a grasp about the expected lifespan once you start using it.
Luckily modern SSD and HDD are equipped with a monitoring system called SMART, from the initials of Self-Monitoring, Analysis and Reporting Technology. Its function is to measure various disk parameters to anticipate expected hardware failures. The important metrics will vary depending on whether you are checking a SSD or a traditional spinning HDD.
In order to get a manual report, you can use the handy Smartmontools package on a Linux computer. We are going to use a Ubuntu environment for the following commands.
Check your drive in a few steps
The first step is to install Smartmontool on your Linux computer. If you use Ubuntu or any other Debian-based distribution you can so so with:
sudo apt update sudo apt install smartmontools
This will take care of installing the right tools and their dependencies.
Find your disk
The second step will be to connect your disk to your computer. You can use a USB converter, or just install it in any free slot you may have.
Once you are done with the mechanical side, you need to find out how Linux is mapping that disk. The command to do so is:
The output of this command will list all physical and logical drives connected to your computer. If you connected your disk via USB you can expect something like
sdX as address (with X being a lowercase letter like
b or other). In my case, it’s
sda, and the full address will be
Check the health of your SSD or HDD.
Now we are almost there! There are a few more commands you need to issue to finally know the health status of your SSD or HDD. In order to confirm your disk has SMART capabilities you need to issue:
sudo smartctl -i /dev/sda
This is the output I got:
The last two lines confirm that the disk has SMART support and it’s enabled. We can go ahead and perform a quick test with:
sudo smartctl -t short -a /dev/sda
This will perform a quick test and give us the results on the health status of our SSD or HDD. The first thing to check is if the
"SMART overall-health self-assessment test result" line is marked as
PASSED (if not, our disk has serious issues).
If you want to see the output of a previously run test, the command is:
sudo smartctl -a /dev/sda
There is a table with a set of attributes and their specific score. You can find more information about interpreting each line and its value here. Your specific disk may have further attributes, you will need to check with your specific vendor about them.
- Wikipedia page on SMART drives technology link
- List of SMART attributes on Wikipedia link
- Smartmontools homepage
Do you like our content? Check more of our posts in our blog!