nixCraft Poll

Topics

How do I save (recover) data from crashed disks with dd and ddrescue command?

Posted by Vivek Gite [Last updated: September 27, 2007]

dd_rescue (also known as ddrescue) 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.

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.

Install dd_rescue or ddrescue

If you are using Debian / Ubuntu Linux, type the following command to install ddrescue:
# apt-get install ddrescue

If you are using RedHat /Fedora /CentOS Linux, type the following command:
# yum -y install ddrescue

Or directly download ddrescue from official GNU web site.

Please note that Debian install ddrescue binary as /bin/dd_rescue and other distribution as /usr/bin/ddrescue

How do I use dd_rescue (ddrescue)?

To make exact copy of /dev/sda (damaged) to /dev/sdb (make sure sdb is empty) you need to type following command:
# ddrescue /dev/hda /dev/hdb

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 data:
# mount /dev/sdb2 /mnt/data

Next 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 ddrescue
OR
# man dd_rescue
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 dd command.

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. billy Says:

    Fantastic post!!! a massive help. Thanks for saving my ass.

  2. htc Says:

    Thanks, excellent article.

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

  3. nixcraft Says:

    @htc,

    Hmm…

    Try to update apt database and again run same command:

    apt-get update
    apt-get install ddrescue

    HTH.

  4. Anonymous Says:

    Very helpul thanks!

  5. John Says:

    Simple and effective :D good pice of work,IMPO

  6. chadrick Says:

    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.

  7. alt Says:

    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.

  8. Dad Says:

    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!

  9. nixcraft Says:

    Use url for man page

    HTH

  10. Scottux Says:

    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.

  11. Udit Says:

    You guys might want to look at dd_rhelp also
    http://www.kalysto.org/utilities/dd_rhelp/index.en.html

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

  12. nixcraft Says:

    Udit,

    Thanks for sharing link :)

  13. cuvtixo Says:

    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.

  14. Anonymous Says:

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

    Not ddrescue. You have to have the g there.

  15. vivek Says:

    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:
    ddrescue
    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 http://in.archive.ubuntu.com 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) …

  16. fd Says:

    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.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.