manpagez: man pages & more
info ddrescue
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5 Invoking ddrescue

The format for running ddrescue is:

ddrescue [options] infile outfile [logfile]

ddrescue supports the following options:


Print an informative help message describing the options and exit.


Print the version number of ddrescue on the standard output and exit.

-a bytes

Minimum read rate of good non-tried areas, in bytes per second. If the read rate falls below this value, ddrescue will skip ahead a variable amount depending on rate and error histories. The skipped blocks are tried in additional passes (before trimming) where the minimum read rate is divided by ten before each pass, until there are no more non-tried blocks left.

If bytes is 0 (auto), the minimum read rate is recalculated for each block as (average_rate / 10). Values above device capabilities are ignored.


Mark all non-split and non-trimmed blocks inside the rescue domain as non-tried before beginning the rescue. Try this if the drive stops responding and ddrescue immediately starts splitting failed blocks when restarted. If ‘--retrim’ is also specified, mark all failed blocks inside the rescue domain as non-tried.

-b bytes

Sector (hardware block) size of input device in bytes (usually 512 for hard discs and 3.5" floppies, 1024 for 5.25" floppies, and 2048 for cdroms). Defaults to 512.


Show units with binary prefixes (powers of 1024).
SI prefixes (powers of 1000) are used by default. (See table below).

-c sectors

Number of sectors to copy at a time. Defaults to 64 KiB / sector_size. Try smaller values for slow drives. The number of sectors per track (18 or 9) is a good value for floppies.


Limit rescue domain to the blocks listed in the logfile. Do not read new data beyond logfile limits. This is useful when reading from devices of undefined size (like raw devices), when the drive returns an incorrect size, or when reading from a partial copy. It can only be used after a first rescue attempt, possibly limited with the ‘--size’ option, has produced a complete logfile.


Use direct disc access to read from infile, bypassing the kernel cache. (Open the file with the O_DIRECT flag). Use it only on devices or partitions, not on regular files. Sector size must be correctly set for this to work. Not all systems support this.

If your system does not support direct disc access, ddrescue will warn you. If the sector size is not correctly set, all reads will result in errors, and no data will be rescued.


Use synchronous writes for outfile. (Issue a fsync call after every write). May be useful when forcing the drive to remap its bad sectors.

-e [+]n

Maximum number of error areas allowed before giving up. Defaults to infinity. If n is preceded by ‘+’ the number refers to new error areas found in this run, not counting those already annotated in the logfile.

-E bytes

Maximum rate of errors allowed before giving up, in bytes per second. Defaults to infinity. The rate being measured is that of actually failed reads, so the rescue may finish because of this rate being exceeded even if the total error size (errsize) does not change because the areas being tried are already marked as errors.


Force overwrite of outfile. Needed when outfile is not a regular file, but a device or partition.

-F types

Fill the blocks in outfile specified as any of types in logfile, with data read from infile. types contains one or more of the status characters defined in the chapter Logfile structure (see section Logfile structure). See the chapter Fill mode (see section Fill mode) for a complete description of the fill mode.


Generate an approximate logfile from the infile and outfile of the original rescue run. Note that you must keep the original offset between ‘--input-position’ and ‘--output-position’ of the original rescue run. See the chapter Generate mode (see section Generate mode) for a complete description of the generate mode.

-H file

Builds a map of good/bad blocks using the logfile file and uses it to simulate read errors in infile. The blocks marked as finished in file will be read normally. All other block types will be considered read errors without even trying to read them from infile. This mode is an aid in improving the algorithm of ddrescue and is also useful to verify that ddrescue produces accurate results in presence of read errors.

-i bytes

Starting position of the rescue domain in infile, in bytes. Defaults to 0. This is not the point from which ddrescue starts copying. (For example, if you pass the ‘--reverse’ option to ddrescue, it starts reading from the end of the rescue domain). In fill mode it refers to a position in the infile of the original rescue run. See the chapter Fill mode (see section Fill mode) for details.


Compare the size of infile with the size calculated from the list of blocks contained in the logfile, and exit with status 1 if they differ. This is not enabled by default because the size of some devices can’t be known in advance and because the size derived from the logfile may be incomplete, for example after doing a partial rescue.

-K initial[,max]
-K ,max

Set limits to skip size during the copying phase. initial is the size to skip on the first read error or slow read, in bytes. max is the maximum size to skip. The values given will be rounded to the next multiple of sector size. The skip size will be doubled for each read error or slow read until it reaches max or, if max is omitted, 1% of the size of infile or 1 GiB (whichever is smaller), and will be reset to initial when good data is found. Valid values range from 64 KiB to 1 GiB. initial defaults to 64 KiB. An initial value of 0 disables skipping entirely.

If ddrescue is having difficulties skipping away from a large area with scattered errors, or if the device has large error areas at regular intervals, you can increase the initial skip size with this option. Inversely, if ddrescue is skipping too much, leaving large non-tried areas behind each error (which will be read later in the usually slower backwards direction), you can reduce the maximum skip size, or disable skipping.

--skip-size’ is independent from ‘--cluster-size’. The size to skip is calculated from the end of the block that just failed.

-l entries

During the splitting phase, do not grow logfile beyond this number of entries. Logfile may be larger if it was larger at startup or if it became larger during the copying or trimming phases. Defaults to 10000. (Each entry is about 26-30 bytes in size).


Accept an incomplete synthetic (user fabricated) domain logfile or test-mode logfile and fill the gaps with non-tried blocks. The blocks in the logfile must be strictly ascending and non-overlapping, but they do not need to be contiguous. This option allows making quick edits to a logfile without all the size calculations involved in making all data blocks contiguous again.

-m file

Restrict the rescue domain to the blocks marked as finished in the logfile file. This is useful for merging partially recovered images of backups, or if the destination drive fails during the rescue.


Mark all failed blocks inside the rescue domain as non-trimmed before beginning the rescue. The effect is similar to ‘--retry-passes=1’, but the bad sectors are tried in a different order, making perhaps possible to rescue some of them.


Skip the splitting phase. Avoids spending a lot of time trying to rescue the most difficult parts of the file.


Skip the trimming phase. Specially useful in the first parts of a multi-part rescue.

-o bytes

Starting position of the image of the rescue domain in outfile, in bytes. Defaults to ‘--input-position’. The bytes below bytes aren’t touched if they exist and truncation is not requested. Else they are set to 0.


Close infile and then reopen it after every read error and, if ‘--min-read-rate’ is set, after every slow read encountered both during the copying phase. Use this option if you notice a permanent drop in transfer rate after finding read errors or slow areas. But be warned that most probably the slowing-down is intentionally caused by the kernel in an attempt to increase the probability of reading data from the device.


Preallocate space on disc for outfile. Only space for regular files can be preallocated. If preallocation succeeds, rescue will not fail due to lack of free space on disc. If ddrescue can’t determine the size to preallocate, you may need to specify it with some combination of the ‘--input-position’, ‘--output-position’, ‘--size’, and ‘--domain-logfile’ options.


Quiet operation. Suppress all messages.

-r n

Exit after given number of retry passes. Defaults to 0. -1 means infinity. Every bad sector is tried only once in each pass. To retry bad sectors detected on a previous run, you must specify a non-zero number of retry passes.


Reverse the direction of the first pass of copying, all retrying passes, and the sequential part of splitting, running them backwards from the end of the rescue domain (or from the end of infile if no domain options are specified). ‘--reverse’ does not modify the size of the blocks copied during each phase, just the order in which they are tried.

-s bytes

Maximum size of the rescue domain, in bytes. It limits the amount of input data to be copied. If ddrescue can’t determine the size of the input device, you may need to specify it with this option. Note that this option does not specify the size of the resulting outfile. For example, the following command creates an outfile 300 bytes long, but only writes data on the last 200 bytes:

ddrescue -i 100 -s 200 infile outfile logfile

Use sparse writes for outfile. (The blocks of zeros are not actually allocated on disc). May save a lot of disc space in some cases. Not all systems support this. Only regular files can be sparse.


Truncate outfile to zero size before writing to it. Only works for regular files, not for drives or partitions.

-T interval

Maximum time since last successful read allowed before giving up. Defaults to infinity. interval is a rational number (like 1.5 or 1/2) optionally followed by one of ‘s’, ‘m’, ‘h’ or ‘d’, meaning seconds, minutes, hours and days respectively. If no unit is specified, it defaults to seconds.


Verbose mode. Further -v’s (up to 4) increase the verbosity level.


Make fill mode ignore write errors. This is useful to avoid ddrescue exiting because of new errors developing while wiping the good sectors of a failing drive. Fill mode normally writes to outfile one cluster at a time. With this option, after the first write error is found in an area, the rest of that area is filled sector by sector.

-x bytes

Extend the size of outfile to make it at least bytes long. If the size of outfile is already equal or longer than bytes then this option does nothing. Use this option to guarantee a minimum size for outfile. Only regular files can be extended.

-1 file

Log rates and error sizes every second in file. If file already exists, it will be overwritten. Every time the screen is updated with new details, some of those details (time, input position, current and average rates, number of errors and error size) are written to file in a format usable by plotting utilities like gnuplot. This allows a posterior analysis of the drive to see if it has any weak zones (areas where the transfer rate drops well below the sustained average).

-2 file

Log all read operations in file. If file already exists, it will be overwritten. Every read attempt and its result (position, size, copied size and error size) is written to file. (The position written is always the beginning of the block tried, even if reading backwards). A line is also written at the beginning of each phase (copying, trimming, splitting and retrying). Finally, a line with a time mark is written every second (unless the read takes more time). Use this option with caution because file may become very large very quickly. Use lzip to compress file if you need to store or transmit it.

Numbers given as arguments to options (positions, sizes, rates, etc) may be expressed as decimal, hexadecimal or octal values (using the same syntax as integer constants in C++), and may be followed by a multiplier and an optional ‘B’ for "byte".

Table of SI and binary prefixes (unit multipliers):

kkilobyte (10^3 = 1000)|Kikibibyte (2^10 = 1024)
Mmegabyte (10^6)|Mimebibyte (2^20)
Ggigabyte (10^9)|Gigibibyte (2^30)
Tterabyte (10^12)|Titebibyte (2^40)
Ppetabyte (10^15)|Pipebibyte (2^50)
Eexabyte (10^18)|Eiexbibyte (2^60)
Zzettabyte (10^21)|Zizebibyte (2^70)
Yyottabyte (10^24)|Yiyobibyte (2^80)

Exit status: 0 for a normal exit, 1 for environmental problems (file not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or invalid input file, 3 for an internal consistency error (eg, bug) which caused ddrescue to panic.

If ddrescue is interrupted by a signal, it updates the logfile and then terminates by raising the signal received.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on June 14, 2014 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.