Marcio Cunha

How to clone corrupted NVMe drives on Linux with ddrescue

Learn how to recover data from corrupted NVMe SSDs with damaged sectors on Linux using the ddrescue utility to maximize block extraction safely.

Marcio Cunha•4 min
Also available in:PortuguêsEspañol
Summary
  • Corrupted NVMe drives require low-level tools that bypass read errors without freezing the operating system kernel.
  • The ddrescue utility performs reads in strategic phases, prioritizing healthy blocks before insisting on damaged sectors.
  • Log file mapping allows pausing and resuming the cloning process without losing any previously acquired progress.
  • Monitoring media temperature and prior wear prevents additional catastrophic losses during the rescue operation.
  • Converting readable blocks into an intact image enables subsequent analysis of damaged file systems.

Why ddrescue is essential for saving corrupted NVMe SSDs

When a high-speed NVMe solid-state drive connected directly to the PCIe bus begins to corrupt data or experience severe read failures, the operating system typically freezes when attempting to access it. Traditional copying tools simply abort the operation at the very first bad sector encountered. In practice, this means you lose access to gigabytes of valuable information just because a few specific blocks failed. This is precisely where ddrescue steps in as the premier market solution.

Unlike the traditional dd command, which is designed for flawless linear copies, ddrescue was built from the ground up to handle damaged media. It uses an intelligent saving algorithm that divides the recovery process into fast rescue and deep scraping stages. Before starting the emergency procedure, keep in mind that monitoring physical integrity with specialized tools, as detailed in our guide on how to monitor NVMe SSD temperature on Linux, helps determine whether the issue stems from overheating or natural flash memory wear.

Understanding hardware risks and operational limits

NVMe drives operate at blazing speeds, communicating via PCIe lanes directly with the processor. When internal controller corruption or NAND storage cell degradation occurs, the internal controller may enter an infinite error-correction loop that locks the bus and freezes Linux. In practice, forcing continuous reads without a back-off strategy can destroy the remaining lifespan of the unit.

Therefore, the first step before running any rescue command is to connect the affected NVMe drive to a stable controller, preferably on a bench machine or using a well-cooled USB-NVMe adapter. If you also handle electronic component maintenance, checking diagnostic guidelines in how to test power MOSFETs on the bench with a multimeter ensures your motherboard power supply remains perfectly stable and free from voltage fluctuations.

Setting up the rescue environment on Linux

Before diving in, make sure you are running a Linux live environment or an intact secondary partition, as you should never attempt data recovery by writing to the corrupted drive itself. The ddrescue utility is typically available in the official repositories of major distributions and can be installed quickly using your package manager.

Open your terminal and execute the appropriate command for your distribution to install the package. Next, use hardware listing commands to identify the exact block identifier assigned to your damaged NVMe SSD, such as /dev/nvme0n1. Precise identification prevents catastrophic overwriting errors on healthy disks connected to the same recovery machine.

Executing the phased cloning process

The cloning process with ddrescue operates in two fundamental stages: direct rescue scraping and difficult read retries. In the first stage, the program copies everything it can read easily. In the second stage, it focuses exclusively on blocks that returned read errors, attempting to extract any useful fragment.

To start the process safely and generate a map log file essential for resuming cloning in case of power loss, use the structured command below in your Linux terminal:

ddrescue -d -r3 /dev/nvme0n1 /mnt/backup/nvme_image.img /mnt/backup/mapfile.log

In this command, the -d flag enables direct read mode, bypassing the kernel cache to prevent the operating system from guessing blocks and locking the controller. The -r3 flag indicates that the utility will attempt to read problematic sectors three times before permanently giving up on that specific region.

Validating the cloned image and recovering files

Once ddrescue finishes the scraping passes and the map log indicates that all possible blocks have been extracted, the next step is to verify the integrity of the generated image. Since the original SSD had damaged sectors, it is highly likely that the final image file contains gaps of corrupted or zeroed data.

You can mount this image in a virtual read-only directory to inspect the file system and rescue saved documents. If the internal file system was also affected by corruption, complementary deep scan tools can be applied directly to the mounted image file, ensuring that vital files are successfully recovered with maximum efficiency.

Final thoughts on NVMe data recovery operations

Recovering data from corrupted NVMe drives requires patience, technical insight, and low-level tools that respect the physical limitations of damaged hardware. Using ddrescue combined with a careful bus isolation strategy ensures the highest possible number of readable blocks is extracted before the SSD stops responding entirely. Maintaining strict backup routines and proactively monitoring storage device health remains the best defense against catastrophic data loss in modern infrastructure.