Linux provides the ‘ddrescue’ command, which can be used to
recover data from damaged ‘block-based’ media such as hard
disk drives, solid-state drives, CDs, DVDs, etc.
It understands many different formats, including Windows file systems,
such as
FAT
and
NTFS.
The ‘ddrescue’ command can be run multiple times, gradually
recovering more and more data each time.
Every time you run ‘ddrescue’ as part of the same data
recovery job, you specify the same map file, which effectively
keeps track of which areas containing data have been read, and
which areas have caused difficulty and are still to be
recovered.
Remember that you can find out more information from a Linux command
prompt by typing ‘man ddrescue’ or read a detailed guide
by typing ‘info ddrescue’.
Here are some instructions for running multiple passes of
‘ddrescue’:
- During the first pass ‘ddrescue’ copies as much data as
possible, without retrying hard-to-read data or splitting sectors.
ddrescue --no-split /dev/hda1 imagefile mapfile - The second pass of ‘ddrescue’ retries reading areas of
data that proved hard to read on the first pass, using uncached
reads:
ddrescue --idirect --max-retries=3 /dev/hda1 imagefile mapfile - A third pass of ‘ddrescue’ can be used to try again, but
retrimmed so the program tries to re-read full sectors (the
--retrim
option marks all failed blocks as non-trimmed):
ddrescue --idirect --retrim --max-retries=3 /dev/hda1 imagefile mapfile - You can also replace the device /dev/hda1 with the specific partition
that you are trying to recover.
Once you do this, you can mount the imagefile like this:
sudo mount -t ntfs-3g -o loop,ro imagefile /mnt
This mounts the image read-only at the directory ‘/mnt’. - Another thing you can try is cloning the whole source hard drive to a
target hard drive using a command like:
ddrescue --no-split /dev/hda /dev/sdb mapfile