I was going to try ddrescue to recover data from a faulty (beeping) laptop drive and a primary ext4 partition.

Reducing the number of reads from the disk should reduce the recovery time and increase the chances of successful recovery, so I would like to only recover /home, and exclude all the non-critical subfolders, like /tmp or /home/guest/Downloads.

I can`t find any option to only recover subfolders in the ddrescue manual, though. Maybe there are other better suited tools for selective data recovery which could maybe display the file system structure, and let me check/uncheck what to recover before starting?

I had used a similar tool in the MSDOS era, so I`m not sure about the best tool for ext4 nowadays.

Open source tools for Linux would be preferred, if possible.

1 Answer 1


You should mount the volume read-only and then make a list of all directories in /home:

find /home -xdev -type d -print0 >dirlist-0.txt

Then you can search for directories you think need not be restored (which saves drive accesses). Then you can make a list of all files and a second list (without additional accesses) with the file sizes. Maybe there are big files which need not be restored:

find /home -xdev -type f \
  \( -print0 -size +512k -fprintf filesizelist-0.txt '\n%6b %p\0' \) \

This file call could contain some -prune statements for directories to be skipped.

After maybe deleting some entries from the file list you can call dd once for each file (instead of cp because cp doesn't handle read errors). You need a wrapper script for this (AFAIK):

#! /bin/bash
test $# -ne 1 && exit 2
dd if="${source_root}/${1}" of="${target_root}/${1}" conv=noerror bs=1M

Start the wrapper script with xargs:

xargs -0 --max-args=1 /wrapper/script <filelist-0.txt

This is easier if you do not want to check for the file size and just copy all files:

find /home -xdev -type f -exec \
  dd if="${source_root}/"{} of="${target_root}/"{} conv=noerror bs=1M \;

It may be useful to add printing of the dd result to the wrapper script and the find call so that you know which files could not be successfully copied.

You must log in to answer this question.