How to clone corrupted boot drive on Linux with ddrescue
Learn step by step how to rescue data from a corrupted or bad sector drive on Linux using the robust ddrescue tool.
Summary
- The ddrescue utility performs multiple passes while temporarily skipping unreadable sectors to extract healthy data before focusing on damaged areas.
- Connecting the failing drive as a secondary device via USB or SATA prevents writing new data to the corrupted storage during recovery.
- The log file generated by ddrescue allows you to pause and resume the cloning process at any time without losing previous progress.
- Prioritizing valid blocks reduces mechanical and electrical wear on the failing disk, increasing the chances of a successful rescue.
- Replacing the corrupted drive with a new one and restoring the cloned image ensures full recovery of the operating system and personal files.
What happens when a boot drive fails and corrupts data
When a hard drive or SSD begins to experience physical failure, the operating system typically freezes suddenly or refuses to boot up. In practice, this means parts of the logic board or memory cells have lost the ability to respond to electrical kernel commands. Unlike simple file deletion, physical damage creates invisible barriers called bad sectors, where any standard read attempt results in Input/Output errors. Before attempting any aggressive repairs, it is essential to analyze storage health using diagnostic utilities to understand the severity of the issue.
Why traditional copy commands fail on damaged drives
Classic copying tools like the cp command or even the traditional dd utility have a major limitation when encountering corrupted sectors: they hang or abort the entire operation upon the first read error. In practice, the kernel tries to read the damaged block repeatedly until timing out, which can permanently fry a mechanical drive's motor or wear out the silicon cells of a failing SSD even further. Furthermore, these tools keep no track of what has already been copied, forcing the entire process to start from scratch if an abrupt interruption occurs midway.
How to prepare the rescue environment with a Linux Live USB
To clone a corrupted drive that contained the main boot system, never run the procedure with the operating system running from it. The correct approach requires booting the machine using a USB flash drive running a Linux distribution directly in memory, known as a Live USB. This strategy ensures the damaged drive remains completely unmounted and idle, with no background processes writing data over the files you want to save. With the system running in complete isolation, open the terminal and use listing commands to correctly identify the device identifier assigned to the faulty disk, such as /dev/sdb.
Step-by-step guide to cloning damaged blocks with ddrescue
The ddrescue utility was specifically designed to rescue data from problematic media, dividing the process into two intelligent phases: first it copies everything that is healthy and fast, and only then tries to extract what remains from the troublesome sectors. To run this procedure safely on your workbench, follow the sequence below using a destination drive with equal or greater capacity than the original.
- Open the terminal and install the rescue package if it is not present in your Live USB distribution by typing the package manager command.
sudo apt update && sudo apt install gddrescue - Locate the names of connected devices using the partition listing command to ensure you do not overwrite the wrong disk.
lsblk - Start the cloning process by directing reads from the source disk to the destination disk while simultaneously providing a log file to save progress.
sudo ddrescue -d -r3 /dev/sdb /dev/sdc /home/ubuntu/rescue.log
Interpreting the progress map and log file
As ddrescue runs in the terminal, it displays a real-time dashboard detailing the volume of copied data, current speed, and exact count of failed sectors. In practice, the generated log file acts as a detailed coordinate map indicating which blocks were successfully saved and which will require additional passes. If the machine shuts down or you need to interrupt the process by pressing shortcut keys, simply run the exact same cloning command and the utility will resume work right where it left off, saving precious time and preventing useless strain on the damaged media.
Validating integrity and restoring the cloned system
Upon successful completion of the cloning process, the destination file will contain an exact bit-by-bit copy of the corrupted drive, including boot partitions and the file table. However, due to the original physical damage, it is highly likely that some specific files were corrupted or left incomplete. In practice, you should connect the new cloned disk to a safe environment and run file system checks to fix structural inconsistencies before attempting a definitive boot. This step ensures the system boots back up with minimal loss, allowing you to recover vital documents and settings without major surprises. To complement this implementation in production environments, see our related technical analyses on How to test network circuit and PHY chip with multimeter and How to configure VLANs on switches to isolate network traffic.
Final considerations on data recovery and failure prevention
Proper use of ddrescue turns a total data loss situation into a surgical and highly controlled rescue of critical information. While the tool maximizes recovery chances in dramatic scenarios, it does not replace the discipline of keeping up-to-date backups in external locations or the cloud. Proactively monitoring hardware health and acting quickly upon the first signs of slowdown or system log errors ensures data longevity and avoids the need for drastic rescue interventions in the future.