ddrescue

When your disk has crashed and you try to copy it over to another one, standard Unix tools like cp, cat, and dd will abort on every I/O error, dd_rescue does not. It optimizes copying by using large blocks as long as no errors occur and falls back to smaller blocks. It supports reverse direction copying (to approach a bad spot from the top), sparse copying, preallocating space, splice zerocopy, and bypassing the kernel pagecache with O_DIRECT. dd_rescue provides safe deletion of data by overwriting files (or better partitions/disks) multiple times with fast random numbers. With the ddr_hash plugin, it supports calculating a hash value (such as a sha256sum) or an HMAC during copying.

Usage

Usage: ddrescue [options] infile outfile [mapfile]

OptionDescription
-a, --min-read-rate=<bytes>minimum read rate of good areas in bytes/s
-A, --try-againmark non-trimmed, non-scraped as non-tried
-b, --sector-size=<bytes>sector size of input device [default 512]
-B, --binary-prefixesshow binary multipliers in numbers [SI]
-c, --cluster-size=<sectors>sectors to copy at a time [128]
-C, --complete-onlydon’t read new data beyond mapfile limits
-d, --idirectuse direct disc access for input file
-D, --odirectuse direct disc access for output file
-e, --max-bad-areas=[+]<n>maximum number of [new] bad areas allowed
-E, --max-error-rate=<bytes>maximum allowed rate of read errors per second
-f, --forceoverwrite output device or partition
-F, --fill-mode=<types>fill blocks of given types with data (?*/-+l)
-G, --generate-modegenerate approximate mapfile from partial copy
-H, --test-mode=<file>set map of good/bad blocks from given mapfile
-i, --input-position=<bytes>starting position of domain in input file [0]
-I, --check-input-sizecompare input file size with size in mapfile
-J, --check-on-errorreread latest good sector after every error
-K, --skip-size=[<i>][,<max>]initial,maximum size to skip on read error
-L, --loose-domainaccept unordered domain mapfile with gaps
-m, --domain-mapfile=<file>restrict domain to finished blocks in
-M, --retrimmark all failed blocks as non-trimmed
-n, --no-scrapeskip the scraping phase
-N, --no-trimskip the trimming phase
-o, --output-position=<bytes>starting position in output file [ipos]
-O, --reopen-on-errorreopen input file after every read error
-p, --preallocatepreallocate space on disc for output file
-P, --data-preview[=<lines>]show some lines of the latest data read [3]
-q, --quietsuppress all messages
-r, --retry-passes=<n>exit after retry passes (-1=infinity) [0]
-R, --reversereverse the direction of all passes
-s, --size=<bytes>maximum size of input data to be copied
-S, --sparseuse sparse writes for output file
-t, --truncatetruncate output file to zero size
-T, --timeout=<interval>maximum time since last successful read
-u, --unidirectionalrun all passes in the same direction
-v, --verbosebe verbose (a 2nd -v gives more)
-w, --ignore-write-errorsmake fill mode ignore write errors
-W, --compare-before-writeomit superfluous writes in rescue mode
-x, --extend-outfile=<bytes>extend outfile size to be at least this long
-X, --max-read-errors=<n>maximum number of read errors allowed
-y, --synchronoususe synchronous writes for output file
-Z, --max-read-rate=<bytes>maximum read rate in bytes/s
--askask for confirmation before starting the copy
--bad-sector-data=<file>treat sectors with data as read errors
--command-modeexecute commands from standard input
--continue-on-errno=<n>[,<n>]treat errno code as non-fatal
--cpass=<range>select what copying pass(es) to run
--delay-slow=<interval>initial delay before checking slow reads [30]
--log-events=<file>log significant events in
--log-rates=<file>log rates and error sizes in
--log-reads=<file>log all read operations in
--mapfile-interval=[i][,i]save/sync mapfile at given interval [auto]
--max-slow-reads=<n>maximum number of slow reads allowed
--pause-on-error=<interval>time to wait after each read error [0]
--pause-on-pass=<interval>time to wait between passes [0]
--reset-slowreset slow reads if rate rises above min
--same-fileallow infile and outfile to be the same file