hard disk data recovery

Recently, I had to recover data on a defective hard drive.

Informations on this page helped me : https://help.ubuntu.com/community/DataRecovery

So, this is a memo (in case the source page disappear) :

  • if your partition table is broken, try to fix it with tools like : testdisk, ntfsfix (ntfsprogs package)
  • install ddrescue (on Debian based) :
    apt-get install gddrescue

    ddrescue is able to build an image file of your disk/partition

  • try to recover maximum data, the fastest way possible :
    ddrescue —no-split /dev/hda1 imagefile logfile

  • you can ask ddrescue to retry (3 times here) :
    ddrescue —direct —max-retries=3 /dev/hda1 imagefile logfile

  • you want more (retrim = reread full sector) ?
    ddrescue —direct —retrim —max-retries=3 /dev/hda1 imagefile logfile

  • now, you can install foremost
    This tool will be able to read your image file to recover files and store them by mime-types (extensions) : pdf, xls, xlsx, doc, docx…
    foremost can do partition to partition recovery, partition to directory
    Equivalent to foremost : magicrescue, photorec, scalpel

  • ask foremost to rebuild files :
    mkdir -p /mnt/recovery/foremost
    foremost -i image -o /mnt/recovery/foremost

    of course, the destination of recovered files must not be on the junk drive !