How to Test SSD/HDD Health in Linux?
Published: 2023-06-20 06:22:50

The health of your SSD (Solid State Drive) or HDD (Hard Disc Drive) is important for the overall performance and reliability of your system. Monitoring the health of your storage devices allows you to spot potential problems early and take the required steps to prevent data loss. In this post, we’ll look at various techniques for test SSD/HDD health in Linux and ensuring that your storage devices are in excellent condition.

## Test SSD/HDD Health in Linux

Monitoring your storage devices with SMART (Self-Monitoring, Analysis, and Reporting Technology) is one of the most effective techniques to analyse their health. SMART has a number of features that provide detailed information about the present situation of your SSD or HDD. SMART monitoring requires the installation of SMART monitoring software on your Linux system.

To install the required packages, open a terminal and enter the following command:

`sudo apt install smartmontools
`
Once the installation is complete, you can use the smartctl command-line utility to access SMART data.

The smartctl tool allows you to get precise information about the health of your SSD or HDD. Run the following command in the terminal to verify the health of a specific device:

$ sudo smartctl -a /dev/sdX
        or
$ sudo smartctl -t long -a /dev/sda

## Use nvme-cli to Test SSD/HDD Health 

Another popular programme called “nvme-cli” can be used for checking the health of SSDs and HDDs. As the name implies, this is intended specifically for NVME-type SSDs. Use the following commands to install it:

$ sudo apt install nvme-cli               #Ubuntu/Debian
$ sudo dnf install nvme-cli                #Fedora
After you’ve learned the command, use it to check the SSD/HDD’s health:

The watch is used to continuously check the SMART log 
-n 1 instructs the watch command to monitor the SMART log every second
nvme is used to manage the NVMe devices
smart-log is used in conjunction with the nvme command to read the SMART logs. 

/dev/nvme0n1p is the drive being monitored

$ sudo watch -n 1 nvme smart-log /dev/nvme0n1p6

## Test SSD/HDD Health in Linux

Users can see the percentage_used in the preceding figure, which is 3% (excellent health). If it exceeds 50%, you should be concerned and consider replacing the drive. Users can also view the “power_on_hours,” “unsafe_shutdowns,” and other statistics in the terminal.

## How to View a List of Discs in Linux

On Linux, various tools are available to display the list of discs, including lsblk, df, fdisk, hwinfo, and many others. To view a list of discs, we use the lsblk command:

$ `lsblk`

The result shows the operating system disc partitions “sda1”, “sda2”, and “sda3”, and a system can have many hard drives.

## GUI Tools for Disk Health Analysis

There are various graphical interface utilities for checking disc health available for Linux. GNOME Discs and GSmartControl are popular options for accessing SMART data and doing disc health diagnostics through a user-friendly interface.

`sudo apt-get install gnome-disk-utility
`
For GSmartControl, run the following command:

`sudo apt install gsmartcontrol
`
Once installed, you may access these tools from the application’s menu and visually examine disc health information.