See user manual here: www.gnu.org/…escue_manual.html
- Install with apt install gddrescue
Example script:
/dev/sdc
is the bad drive which is being recovered to /dev/sdb
# first pass to copy the good sectors and make a log file of the bad
ddrescue -n /dev/sdc /dev/sdb logfile
# second pass keeps retrying the bad sectors
ddrescue -dr3 /dev/sdc /dev/sdb logfile
# have a look at what we have and do some validation
fdisk /dev/sdb
e2fsck -v -f /dev/sdb1
e2fsck -v -f /dev/sdb2
# It might be necessary to manually copy partition table first using:
sfdisk -d /dev/sdc > partition_table-c #dump original table
sfdisk -d /dev/sdb > partition_table-b #to be on the safe side before overwriting
sfdisk /dev/sdb < partition_table-c #copy old to new drive