How To Check Ssd Health In Linux
Checking the health of your SSD in Linux is crucial for maintaining data integrity and preventing unexpected failures. Here are the detailed steps and tools you can use to monitor your SSD's health effectively.
Getting the Name of Your Drive
Before you can check the health of your SSD, you need to identify the drive name. You can use several commands to list your drives, such as lsblk
, cfdisk
, df
, hwinfo
, fdisk
, sfdisk
, or lshw
. For example, using lsblk
:
lsblk
This command will list all your drives, and you can identify your SSD by its size and type.
Using smartctl
to Check SSD Health
smartctl
is a powerful tool for monitoring the health of SSDs and other storage devices. It is part of the smartmontools
package, which you can install using:
sudo apt install smartmontools
Once installed, you can use smartctl
to gather detailed information about your SSD:
sudo smartctl -a /dev/sdX
Replace /dev/sdX
with the name of your SSD. This command will display various attributes, including:
- Power_On_Hours: The number of hours the drive has been powered on.
- Wear_Leveling_Count: The remaining endurance of the drive, expressed as a percentage.
Running Self-Tests with smartctl
In addition to viewing the SMART attributes, you can run self-tests using smartctl
. There are two types of tests: short and long.
-
Short Test: This test takes approximately two minutes to complete.
sudo smartctl -t short /dev/sdX
-
Long Test: This test can take between 20-60 minutes, depending on your hardware.
sudo smartctl -t long /dev/sdX
After running the test, you can view the results with:
sudo smartctl -l selftest /dev/sdX
Using nvme-cli
for NVMe SSDs
For NVMe SSDs, you can use the nvme-cli
tool, which is part of the nvme-cli
package. Install it using:
sudo apt install nvme-cli
Then, you can check the health of your NVMe SSD with:
sudo nvme smart-log /dev/nvme0n1
Replace /dev/nvme0n1
with the name of your NVMe SSD. This command will display various attributes, including:
- Critical_Warning: Indicates the overall health of the SSD.
- Temperature: The current temperature of the SSD.
- Percentage_Used: The percentage of the SSD's endurance used.
- Media_Errors: The number of media errors, which can indicate issues with the drive.
Using GUI Tools
If you prefer a graphical interface, you can use tools like Disks (also known as GNOME Disks) or GSmartControl.
Using Disks (GNOME Disks)
To use Disks, you may need to install it first:
sudo apt install gnome-disk-utility
- Open the Disks utility.
- Select your SSD from the list.
- Click the three-dot menu at the top right and select SMART Data & Self-Tests.
- Click Start Self-Test at the bottom of the new window and view the results.
Using GSmartControl
GSmartControl is a graphical user interface for smartctl
. You can install it using your distribution's package manager. Once installed, you can launch it and select your SSD to view its health status and run self-tests.
Periodic Health Checks
To ensure your SSD remains healthy, it's a good practice to run periodic health checks. You can set up a timer to run btrfs-scrub
if you're using the Btrfs filesystem, which can help identify and fix issues before they become critical.
For example, you can set up a monthly scrub using systemd
:
sudo systemctl enable btrfs-scrub.timer
This will ensure that your Btrfs filesystem is regularly scrubbed to verify block checksums and detect any hardware issues that might not be caught by smartctl
alone.
Additional Tools and Considerations
skdump
If you find smartctl
output hard to read, you can use skdump
, which provides more guidance on the health status of your SSD:
sudo skdump /dev/sdX
btrfs-scrub
For Btrfs users, running btrfs-scrub
regularly can help detect hardware issues that might not be visible through smartctl
. This involves verifying block checksums and can help in identifying and removing the root cause of issues.
By using these tools and methods, you can effectively monitor and maintain the health of your SSDs in a Linux environment.