GNU ddrescue is a command-line tool that copies data from a bad drive to an image or another drive while intelligently skipping and retrying bad sectors, making it much safer and more efficient than using plain dd on failing disks.
Information
gddrescue is one of the preinstalled packages for our r/Techsupport Rescue Media. If you are using this live image, you can skip the installation section.
How to install gddrescue
Refer below for installation instructions if you are not using our live image or want to install it on your own system.
Installing gddrescue
Debian / Ubuntu / Linux Mint:
Terminal window
sudoaptupdate && sudoaptinstallgddrescue
Fedora / RHEL / CentOS / AlmaLinux:
Terminal window
sudodnfinstallddrescue
Arch / Manjaro / CachyOS:
Terminal window
sudopacman-Syuddrescue
Important
The command may point to a ddrescue binary even though the application is called gddrescue. For the rest of the guide, we will refer to the package as ddrescue.
GNU ddrescue (package ddrescue) reads from a source (failing disk or partition) and writes to a destination (image file or another disk) while recording everything in a logfile (mapfile).
Basically, it works like this:
It automatically skips unreadable areas first and copies good data quickly, instead of getting stuck on the first bad sector.
The logfile tracks which blocks were good, bad, or untried so you can stop and resume later without losing progress.
You usually image the failing drive to a file, then work on the image with other tools (fsck, testdisk, photorec, etc.), not on the dying drive.
Important: Identifying the source and destination drives.
Always double-check which drive is source and which is destination before running gddrescue, because mixing them up can destroy your only copy of the data.
Sometimes you want a clone on another physical drive rather than an image file. The command is similar, but the destination is a disk instead of an image:
Example: source failing disk /dev/sdX, destination healthy blank disk /dev/sdY (must be same size or larger):
You must be absolutely sure /dev/sdY is the target you are willing to overwrite completely. This command will destroy any data on /dev/sdY.
Some guides recommend using -f when the destination is a block device to force overwriting; on some systems ddrescue will refuse to write to a block device without -f.
Once again, disk-to-image is generally safer. You can always write the image back to a new disk later if needed.
Once you have an image, you generally stop touching the failing disk and work only on the image. You can mount the image, run filesystem checks, or use recovery tools like testdisk or photorec on the image file to try to recover files.
Typical next steps (examples, not full tutorials):
Try to mount the image read-only (for a whole-disk image):
Create a loop device and maybe use kpartx or losetup to expose partitions, then mount the relevant partition read-only.
Run filesystem checks (fsck) on the cloned disk or on a copy of the image, not on the original.
Use file recovery tools (testdisk or photorec) on the image file to try to recover files.
Basically the pattern to follow is “gddrescue -> image file -> run other recovery tools on that image”.