GNU ddrescue is a program that copies data from one file or block device (hard disk, cd/dvd-rom, etc) to another, it is a tool to help you to save data from crashed partition i.e. it is a data recovery tool. It tries to read and if it fails it will go on with the next sectors, where tools like dd will fail. If the copying process is interrupted by the user it is possible to continue at any position later. It can copy backwards.

This program is useful to rescue data in case of I/O errors, because it does not necessarily abort or truncate the output. This is why you need to use this program and not the dd command. I have recovered much data from many disks (CD/hard disk/software raid) over the years using GNU ddrescue on Linux. I highly recommend this tool to Linux sysadmins.

Install ddrescue on a Debian/Ubuntu Linux

Type the following apt-get command to install ddrescue:
# apt-get install gddrescue
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 49.6 kB of archives.
After this operation, 152 kB of additional disk space will be used.
Get:1 precise/universe gddrescue amd64 1.14-1 [49.6 kB]
Fetched 49.6 kB in 0s (1,952 kB/s)
Selecting previously unselected package gddrescue.
(Reading database ... 114969 files and directories currently installed.)
Unpacking gddrescue (from .../gddrescue_1.14-1_amd64.deb) ...
Processing triggers for install-info ...
Processing triggers for man-db ...
Setting up gddrescue (1.14-1) ...

Install ddrescue on a RHEL/Fedora/CentOS Linux

First turn on EPEL repo on a RHEL/CentOS/Fedora Linux. Type the following yum command:
# yum install ddrescue
Sample outputs:

Loaded plugins: product-id, rhnplugin, security, subscription-manager,
              : versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is receiving updates from RHN Classic or RHN Satellite.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ddrescue.x86_64 0:1.16-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package            Arch             Version               Repository      Size
 ddrescue           x86_64           1.16-1.el6            epel            81 k
Transaction Summary
Install       1 Package(s)
Total download size: 81 k
Installed size: 189 k
Is this ok [y/N]: y
Downloading Packages:
ddrescue-1.16-1.el6.x86_64.rpm                           |  81 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ddrescue-1.16-1.el6.x86_64                                   1/1
  Verifying  : ddrescue-1.16-1.el6.x86_64                                   1/1
  ddrescue.x86_64 0:1.16-1.el6

You can directly download ddrescue from the official GNU project web site and compile it on Linux or Unix-like systems.

A note about using ddrescue safely

  1. You need to use a logfile to resume a rescue.
  2. Never ever run ddrescue on a read/write mounted partition.
  3. Do not try to repair a file system on a drive with I/O errors.
  4. Be careful about destination partition/device, any data stored there will be overwritten.

How do I use ddrescue command?

In this example rescue a /dev/sda to /dev/sdb

     ## No need to partition /dev/sdb beforehand, but if the partition table on /dev/sda ##
     ## is damaged, you will need to recreate it somehow on /dev/sdb. ##
     ddrescue -f -n /dev/sda /dev/sdb logfile
     ddrescue -d -f -r3 /dev/sda /dev/sdb logfile
     ## get list of partitions on a /dev/sdb ##
     fdisk /dev/sdb
     ## check for errors ##
     fsck -v -f /dev/sdb1
     fsck -v -f /dev/sdb2

Understanding ddrescue command options

  • -f : Overwrite output device or partition.
  • -n : Do not try to split or retry failed blocks.
  • -d : Use direct disc access for input file.
  • -r3 : Exit after given three (3) retries (use -1 as infinity retries).
  • -b2048 : Sector size of input device [default is set to 512].

Example: Rescue a partition in /dev/sda3 to /dev/sdb3 in Linux

 ## You need to create the sdb2 partition with fdisk first. sdb2 should be of appropriate type and size ##
     ddrescue -f -n /dev/sda2 /dev/sdb2 logfile
     ddrescue -d -f -r3 /dev/sda2 /dev/sdb2 logfile
     e2fsck -v -f /dev/sdb2
     mount -o ro /dev/sdb2 /mnt
## Rread rescued files from /mnt ##
     cd /mnt
     ls -l
## Copy files using rsync ##
     rsync -avr .

Example: Rescue/recover a DVD-ROM in /dev/dvdom on a Linux

The syntax is:

     ddrescue -n -b2048 /dev/dvdrom dvd-image logfile
     ddrescue -d -b2048 /dev/dvdrom dvd-image logfile

Please note that if there are no errors (errsize is zero), dvd-image now contains a complete image of the DVD-ROM and you can write it to a blank DVD-ROM on a Linux based system:
# growisofs -Z /dev/dvdrom=/path/to/dvd-image

Example: Resume failed rescue

In this example, while rescuing the whole drive /dev/sda to /dev/sdb, /dev/sda freezes up at position XYZFOOBAR (troubled sector # 7575757542):

 ## /dev/sda freezes here ##
 ddrescue -f /dev/hda /dev/hdb logfile
 ## So restart /dev/sda or reboot the server ##
 ## Restart copy at a safe distance from the troubled sector # 7575757542 ##
 ddrescue -f -i 7575757542 /dev/sda /dev/sdb logfile
 ## Copy backwards down to the troubled sector # 7575757542 ##
 ddrescue -f -R /dev/sda /dev/sdb logfile

A note about dd_rescue command and syntax

On Debian / Ubuntu and a few other distro you end up installing other utility called dd_rescue. dd_rescue is a program that copies data from one file or block device to another, it is a tool to help you to save data from crashed partition.

Examples: dd_rescue

To make exact copy of /dev/sda (damaged) to /dev/sdb (make sure sdb is empty) you need to type following command:
# ddrescue /dev/sda /dev/sdb
Naturally, next step is to run fsck on /dev/sdb partition to recover/save data. Remember do not touch originally damaged /dev/sda. If this procedure fails you can send your disk to professional data recovery service. For example if /home (user data) is on /dev/sda2, you need to run a command on /dev/sdb2:
# fsck /dev/sdb2

Once fsck run, mount /dev/sdb2 somewhere and see if you can access the data:
# mount /dev/sdb2 /mnt/data
Finally, take backup using tar or any other command of your own choice. ddrescue command supports tons of options, read man page for more information:
# man dd_rescue
OR see gnu/ddrescue command man page:
# man ddrescue

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 30 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
30 comments… add one
  • chadrick Jun 13, 2006 @ 18:00

    My personal experience is dd is slow and dd will never display any progress (which makes me more nervous about my data … LOL). I love ddrescue – one perfect tool for data recovery.

    • mukesh kumar Aug 9, 2015 @ 17:18

      dd command with progress bar (worked in centos6)

      #pv -pvert | dd of= bs=512

      Ensure pv command is installed in centos.

  • Anonymous May 23, 2006 @ 0:04

    Very helpul thanks!

  • htc May 18, 2006 @ 21:02

    Thanks, excellent article.

    I have a couple of doubts, though. I haven’t able to install it using apt-get command 🙁 Any hint?

    • Sir_Mr_Bman Oct 7, 2014 @ 12:13

      Try this command instead:

      $ apt-get update && apt-get install ddrescue

      That should do it.

  • 🐧 nixCraft May 19, 2006 @ 13:13



    Try to update apt database and again run same command:

    apt-get update
    apt-get install ddrescue


  • John Jun 1, 2006 @ 8:23

    Simple and effective 😀 good pice of work,IMPO

  • alt Aug 21, 2006 @ 22:05

    I have on hd with NTFS file system which has important data to backed up and I have one more computer which has Readhat linux installed on it. How I can use dd_rescue to retrive data out from that hd having NTFS file system.

  • Dad Sep 14, 2006 @ 13:47

    Does anyone have a link to a ddrescue man page that is something more than that the program itself puts on screen when the user enters parameters incorrectly? It would be nice to know more about ddrescue than just what the options list is!

  • Scottux Oct 2, 2006 @ 23:25

    Is there any other tool to recover files? I have a hard drive with bad sectors. It is an NTFS filesystem and has some importnat data on it. I have tried dd and now ddrescue, to no avail. I was trying to use autopsy/sleuthkit – but it requires an image. I am pulling my hair out trying to recover the files from this thing. I don’t care about the drive, just the data. All RAID from now on.

  • Udit Jan 20, 2007 @ 9:34

    You guys might want to look at dd_rhelp also

    I haven’t used it but it seems to shorten the amount of time dd_rescue takes.

  • 🐧 nixCraft Jan 22, 2007 @ 15:16


    Thanks for sharing link 🙂

  • cuvtixo Oct 2, 2007 @ 1:55

    The Linux tool called GNU ddrescue written by Antonio Diaz Diaz should not be confused with dd_rescue written by Kurt Garloff
    They are two different utilities.

  • Anonymous Dec 23, 2007 @ 18:35

    Actually, the command on Ubuntu should be
    apt-get install gddrescue.

    Not ddrescue. You have to have the g there.

  • 🐧 nixCraft Dec 23, 2007 @ 18:44

    On my Ubuntu 7.10, I can install the tool ddrescue
    sudo apt-get install ddrescue

    And it got installed:
    [sudo] password for vivek:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed:
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 17.6kB of archives.
    After unpacking 77.8kB of additional disk space will be used.
    Get:1 gutsy/universe ddrescue 1.13-3 [17.6kB]
    Fetched 17.6kB in 2s (8220B/s)
    Selecting previously deselected package ddrescue.
    (Reading database ... 123654 files and directories currently installed.)
    Unpacking ddrescue (from .../ddrescue_1.13-3_i386.deb) ...
    Setting up ddrescue (1.13-3) ...

  • fd Feb 12, 2008 @ 10:39

    you write: “dd_rescue (also known as ddrescue)”. they are not at all the same software.

    ddrescue and dd_rescue are completely different programs which share no development between them. the two projects are not related in any way except that they both attempt to enhance the standard dd tool and coincidentally chose similar names for their new programs.

    ddrescue is the one to get.

  • noodle Jan 14, 2009 @ 10:40

    actually gddrescue is the one you want, its updated more frequently and incorporates the functions of the original dd_rescue and dd_rhelp.

  • webmaster screenshotscores Jul 14, 2009 @ 13:08

    nice one, very helpful!

  • Rich Aug 16, 2009 @ 13:23

    for clarity,
    * the PACKAGE “gddrescue” provides the COMMAND ddrescue
    * the PACKAGE “ddrescue” provides the COMMAND dd_rescue

    GNU ddrescue is the first one, and seems IMHO better/more flexible than dd_rescue.

  • wav Aug 13, 2010 @ 11:34

    Damn, i can’t get it to work!!

    when I use the given command to start copying the img file, i get told that the destination is not a directory!

    I created a directory called backup.img but still get the stupid error

    so do you all are so very happy that it works

  • brain Oct 6, 2010 @ 2:38

    well said wav…

    Look forward to a resolution posting.

    Thanks in advance to all.


  • nodonttakethose Jan 18, 2011 @ 9:02

    ddrescue dose not equal dd_rescue!!! The apt database is confusing in this regard.
    “ddrescue” (gddrescue in apt) is a GNU app that is _far_ superior to dd_rescue (ddrescue in apt). Check synaptic. Check man page and info for GNU ddrescue at the linked site below. As I said it’s far superior to dd_rescue (faster, more sensible output).

  • nathan Dec 6, 2011 @ 13:26

    hai there. befpre i run these commands, do need to download any software? if yes, how to do it?? im a newbie:-)

    • Derpatron Oct 8, 2014 @ 10:51

      Had you bothered to read the article you wouldn’t have to ask this question, it’s all explained there.

  • gardenman Apr 5, 2012 @ 1:28

    just start the terminal and type sudo apt-get install gddrescue and hit enter

  • ybanafa Oct 12, 2014 @ 18:50

    how can I boot /dev/sdb1 & /dev/sdb2 in new HD ( the old dead /dev/sda1 &2) ?
    Note : RouterOS Lic.Level 6

  • davekimble Feb 11, 2015 @ 0:37

    I am trying to rescue an audio CD.
    $ ddrescue –n –b2048 /dev/cdrom cd.iso ddrescue.log
    ddrescue: Too many files.
    no output files produced.
    Is the file system corrupt or what?

  • Peter Jun 14, 2016 @ 9:04

    I’ve been given a dodgy old XP box to fix, apparently running our accounting system on some ghastly old COBOL system. The OS would show the initial post screens, then go black. I tried another video card, before suspecting the drive was going. I jammed in a new drive, and installed XP SP3 on it (yes I know, but the COBOL guy would have preferred W 98).

    I’m now trying to recover whatever is on the old drive. I plugged it in, and booted knoppix (6.4) off a cd. No ddrescue, but found dd & dd_rescue. So obviously I’m a noob, and don’t particularly want to copy an image, just whatever files I can grab. Again obviously, I’m ADD, impatient, and a bit stupid, and these tools are super cryptic. So now I’m booting into XP to see how XCopy manages. Yeesh.

    Not to troll or anything, but linux needs a tool for tools who don’t really much care if they recover the data or not.

    • Peter Jun 14, 2016 @ 10:28

      Having been reminded why no-one ever says ‘to recover corrupt files, just boot into XP’, I’ve had another go with dd_rescue. To be clear, because I’m running from a boot cd, I can’t (?) install either ddrescue or gddrescue. I eventually got it to run by mixing the lower level /dev/ for the source with the higher level /media/ for the destination:

      dd_rescue -l /media/sdb2/rescue.log /dev/sda1 /media/sdb2/old.img

      It’s still running, and note even though they’re only using 3% of this 80Gb drive, I still need room for an 80Gb image on sdb2.

  • Peter Jun 20, 2016 @ 7:57

    Sorry, me again, feel free to consolidate these three posts into one, or delete the lot.

    Anyway, all of my usage problems originated because my destination partition was only 40Gb. As soon as I swapped in a blank 80Gb drive, dd_rescue works great. I settled on dd_rescue /dev/sda1 /dev/sda2. Also it turned out the drive was physically OK, so putting it in my new XP installation and running scandisk sorted it out. I think I even recovered all files, the only thing missing was the ENTIRE Windows folder. So installing a different virus scanner.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum