To protect the data on the SSD/HDD disks, especially with the limited lifespan, the experts recommend keeping a check on its health. The SSD/HDD is not immune to damage and corruption, which leads to data loss. To prevent it, users can test SSD/HDD health after identification of drives using various methods on Linux.
This guide elaborates on the approaches to test SSD/HDD health in Linux effectively.
- View List of Disks
- Method 1: Using Smartctl
- Method 2: Using nvme-cli
- Method 3: Using Disks Application (GUI)
How to View the List of Disks on Linux?
Many tools are available to view the list of disks on Linux, such as lsblk, df, fdisk, hwinfo, and many more, discussed here in detail. Let’s use the lsblk command to view a list of disks:
The output shows disk partitions “sda1”, “sda2” and “sda3” in the operating system and a system can have multiple hard drives.
Note: The above output is from Ubuntu installed on the Vmware Workstation, and the output on your end can be different.
Method 1: Using Smartctl on Linux
The Smartctl comes in the “smartmontools” package. It has a self-monitoring feature to monitor the system’s performance. The Smartctl tool supports ATA/SATA, SCSI/SAD, and NVME. It is not pre-installed in the Linux distro. It can be installed using these commands:
$ sudo apt install smartmontools #Ubuntu/Debian/LinuxMint
$ sudo dnf install smartmontools #Fedora
$ sudo yum install smartmontools # RHEL/CentOS
The above figure confirms that the installation of smartmontools has been done on Ubuntu.
To test the SSD/HDD for health, understand this command before executing it:
- smartctl is there to view the information on storage devices
- -t long specifies that a long self-test is to be performed to check the entire surface of the drive for any potential issues
- -a displays the current status and attributes of the disk
- /dev/sda is the name of the drive to check
$ sudo smartctl -t long -a /dev/sda
The current drive on the system does not support Self Test logging but this
Method 2: Using nvme-cli to Test SSD/HDD Health
Another popular tool named “nvme-cli” can be used to check SSD/HDD health. This is designed especially for the NVME type SSDs, as expected from the name. To install it, use these commands:
$ sudo apt install nvme-cli #Ubuntu/Debian
$ sudo dnf install nvme-cli #Fedora
$ sudo yum install nvme-cli #RHEL/CentOS
The above image confirms the installation of nvme-cli has been done on Ubuntu.
To test the SSD/HDD for health, use this command after understanding it:
- The watch utility is used to continuously monitor the SMART log
- -n 1 tells the watch command to monitor the SMART log every second
- nvme is used to manage the NVMe devices
- smart-log is used with the nvme command to view the SMART logs
- /dev/nvme0n1p is the drive being monitored
$ sudo watch -n 1 nvme smart-log /dev/nvme0n1p6
In the above figure, users can check the percentage_used, which is 3% (good health). While if it is over 50%, you should be worried and consider changing the drive. Additionally, users can visualize the “power_on_hours”, “unsafe_shutdowns”, and many more in the terminal.
Note: The above command is executed in dual-boot, and the drive used is NVME.
To check the temperature of the NVME, use the grep command to filter it like this:
$ sudo nvme smart-log /dev/nvme0n1p6 | grep "^temperature"
As seen in the above image, make sure that the temperature remains between 0 and 70 degrees Celsius. If the temperature exceeds this limit, it could cause serious damage to the drive, which ultimately leads to data loss.
Method 3: Using Disks Application (GUI)
To check the SSD/HDD health via the graphical interface, use the GNOME Disk Application by following these steps:
Step 1: Open Disk Application
To open the disk application, click on “Activities” from the top right corner of the screen and then type “Disks” in the search bar and open it:
After clicking on “Disks,” a new window opens up.
Step 2: Select Disk and do SMART Data & Self-Tests
From the new screen, select the drive you want to test (1). Next, choose disk (2). Now click on three dots and then pick the “SMART Data & Self-Tests” option: The disk on the current system does not support this feature, so the option is greyed out. So use the CLI methods discussed above when this option is unavailable.
Linux offers the “Smartctl” and “nvme-cli” command line tools to test the health of SSD/HDD. These tools are used to visualize the “percentage_used ”, “power_on_hours”, “unsafe_shutdowns”, and many more in the terminal. Users can also utilize the “Disks” application in GUI to test SSD/HDD’s health.
This guide explained the methods to test SSD/HDD health on Linux.