Fix bad sectors on SSD? How to use smartctl on Linux
Learn how to diagnose and isolate corrupted blocks on NVMe and SATA storage drives using direct smartctl commands in Linux without data loss.
Summary
- Solid-state drives rely on flash memory cells that undergo natural wear and tear with every write and erase cycle
- The smartctl utility interacts directly with the storage subsystem to extract deep telemetry and health reports
- Logical bad sectors can be forcibly rewritten, while dead physical blocks are permanently isolated by the controller
- Real-time error log analysis prevents catastrophic surprises in high-demand servers and workstations
- Proactive hardware replacement remains the only safe alternative when the spare block reserve reaches exhaustion
What happens when an SSD develops corrupted blocks?
When discussing traditional mechanical hard drives, the notion of bad sectors usually brings to mind read-write heads scratching magnetic platters and the famous chkdsk tool attempting to recover lost data. However, the world of modern flash-based solid-state drives operates entirely differently. In these devices, there are no moving parts; instead, millions of silicon cells store electrical charges. Over time, continuous use and natural degradation wear down these cells, causing some of them to lose their ability to retain data accurately, generating dreaded read or write errors.
In practice, this means the operating system may begin experiencing extreme slowdowns when accessing specific files, sudden freezes, or mysterious file system failure messages. Before discarding the component, it is crucial to understand that modern controllers feature a reserve area known as over-provisioning space. When a cell fails permanently, the controller retires that defective block and replaces it with a healthy sector from this reserve. To closely monitor this process, we use advanced diagnostic utilities in the terminal, as we will explore throughout this guide. Furthermore, for those managing complex infrastructures, it is worth checking out our article on how to monitor NVMe SSD health on Linux with smartctl to maintain continuous oversight of server fleets.
How to install and check general storage health
The first step to auditing the health status of an NVMe or SATA SSD on Linux is ensuring that the package responsible for intelligent monitoring is properly installed on the operating system. This package, generally called smartmontools, provides command-line tools capable of communicating directly with the storage unit's firmware, extracting vital data that rarely appears in conventional graphical interfaces. In practice, the installation command varies depending on the distribution used, whether it is based on Debian, Ubuntu, Fedora, or Arch Linux.
To quickly install it in your environment, open the terminal and execute the command corresponding to your package manager. On Debian and Ubuntu systems, for example, the standard command will resolve dependencies in a few seconds. After completion, the next step is identifying the technical name assigned to your disk by the Linux kernel using commands like lsblk. This proper identification prevents you from running diagnostics on the wrong drive, ensuring complete safety during the hardware technical audit process.
sudo apt update && sudo apt install smartmontools -y
lsblkHow to run detailed diagnostics with smartctl
With the tools properly installed and the storage unit correctly identified in the system, we can begin extracting telemetry reports. The smartctl utility allows for a deep scan of the disk's internal behavior, revealing vital metrics such as operating hours, total data written, and especially the presence of pending or reallocated sectors. In practice, these numbers act like an automotive dashboard warning when the engine is about to fail.
To check all health information for a connected SATA disk, we use the information flag combined with the device identifier, usually named /dev/sda or /dev/sdb. In the case of modern NVMe drives, the command structure changes slightly to accommodate the specific standards of this high-speed protocol, but the logic for interpreting parameters remains intuitive for system administrators and tech enthusiasts.
sudo smartctl -i /dev/sda
sudo smartctl -a /dev/sdaWhen analyzing the detailed output generated by the previous command, pay special attention to essential metrics such as the reallocated sector count and the manufacturer's estimated remaining lifespan percentage. If you notice that the number of defective blocks grows exponentially with each new check, the component has entered a terminal stage of physical degradation. If you wish to further deepen your thermal and electrical diagnostics, we recommend reading our complementary guide on how to monitor NVMe temperature on Linux with smartctl, as excessive heat drastically accelerates the appearance of failures in flash cells.
When and how to run self-diagnostic disk tests
Beyond reading static reports provided by the firmware, smartctl allows you to command the SSD itself to run internal test routines, known as S.M.A.R.T. tests. These tests can be executed in two main modes: the short test, which takes a few minutes and checks critical controller and cache memory components, and the long test, which scans the entire storage surface sector by sector in search of latent inconsistencies.
In practice, the long test should be avoided if the disk is already exhibiting catastrophic read failures, as prolonged mechanical or electrical stress can accelerate the definitive loss of data access before you can perform a secure backup. To safely start a short test in your Linux terminal, simply execute the appropriate command specifying your desired routine type.
sudo smartctl -t short /dev/sda
sudo smartctl -t long /dev/sdaAfter triggering the test command, you can monitor execution progress and review past results by checking the device's log history. The specific command to display results recorded by the firmware will reveal whether the drive passed all integrity tests or encountered corrupted blocks during the scanning process. If persistent sector read failures occur, the only definitive solution to prevent important file loss is to migrate the system to a new drive as quickly as possible. To explore these architectural concepts further in production, see our related technical analysis on How to test USB-C connector with a multimeter.
Final considerations on lifespan and fault prevention
Managing the health of solid-state drives through the Linux terminal using smartctl is an indispensable skill for any technology professional or infrastructure enthusiast who values data stability. While it is possible to temporarily isolate corrupted sectors and rely on the controller's automatic replacement mechanism, no miraculous software can physically regenerate silicon cells that have reached the maximum write limit supported by the manufacturer.
Therefore, the best risk mitigation strategy remains combining automated preventive monitoring with rigorous external backup routines. By keeping your verification scripts running in the background and closely tracking metrics like temperature and write wear, you transform a potential operational disaster into a planned, stress-free replacement for end users.