[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5 Invoking ddrescue
The format for running ddrescue is:
ddrescue [options] infile outfile [logfile]
ddrescue supports the following options:
- ‘-h’
- ‘--help’
Print an informative help message describing the options and exit.
- ‘-V’
- ‘--version’
Print the version number of ddrescue on the standard output and exit.
- ‘-a bytes’
- ‘--min-read-rate=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 history. 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 read as (average_rate / 10).
- ‘-A’
- ‘--try-again’
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-size=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.
- ‘-B’
- ‘--binary-prefixes’
Show units with binary prefixes (powers of 1024).
SI prefixes (powers of 1000) are used by default. (See table below).- ‘-c sectors’
- ‘--cluster-size=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.
- ‘-C’
- ‘--complete-only’
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.
- ‘-d’
- ‘--direct’
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.
- ‘-D’
- ‘--synchronous’
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’
- ‘--max-errors=[+]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’
- ‘--max-error-rate=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.
- ‘-f’
- ‘--force’
Force overwrite of outfile. Needed when outfile is not a regular file, but a device or partition.
- ‘-F types’
- ‘--fill-mode=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.
- ‘-g’
- ‘--generate-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.
- ‘-i bytes’
- ‘--input-position=bytes’
Starting position in infile, in bytes. Defaults to 0. 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.
- ‘-I’
- ‘--verify-input-size’
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 bytes’
- ‘--skip-size=bytes’
Set the initial size to skip on the first read error or slow read. The value given will be rounded to the next multiple of sector size. For subsequent read errors or slow reads, ddrescue will modify the skip size depending on error rate and error history. Valid values range from 64 KiB to 1 GiB. Defaults to 64 KiB.
- ‘-l entries’
- ‘--logfile-size=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 1000. (Each entry is about 26-30 bytes in size).
- ‘-m file’
- ‘--domain-logfile=file’
Restrict the rescue domain to the blocks marked as finished in the logfile file. This is useful if the destination drive fails during the rescue.
- ‘-M’
- ‘--retrim’
Mark all failed blocks inside the rescue domain as non-trimmed before beginning the rescue. The effect is similar to ‘--retries=1’, but the bad sectors are tried in a different order, making perhaps possible to rescue some of them.
- ‘-n’
- ‘--no-split’
Skip the splitting phase. Avoids spending a lot of time trying to rescue the most difficult parts of the file.
- ‘-o bytes’
- ‘--output-position=bytes’
Starting position 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.
- ‘-p’
- ‘--preallocate’
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.
- ‘-q’
- ‘--quiet’
Quiet operation. Suppress all messages.
- ‘-r n’
- ‘--retries=n’
Exit after given number of retry passes. Defaults to 0. -1 means infinity. Every bad sector is tried only one time per pass. To retry bad sectors detected on a previous run, you must specify a non-zero number of retries.
- ‘-R’
- ‘--reverse’
Reverse direction of copying, retrying, and the sequential part of splitting, running them backwards from the end of the input file.
- ‘-s bytes’
- ‘--size=bytes’
Maximum size of the input data to be copied, in bytes. If ddrescue can’t determine the size of the input device, you may need to specify it with this option. Note that this option specifies the size of the input data to be copied, not the size of the resulting outfile. So, 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
- ‘-S’
- ‘--sparse’
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.
- ‘-t’
- ‘--truncate’
Truncate outfile to zero size before writing to it. Only works for regular files, not for drives or partitions.
- ‘-T interval’
- ‘--timeout=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.
- ‘-v’
- ‘--verbose’
Verbose mode. Further -v’s (up to 4) increase the verbosity level.
- ‘-w’
- ‘--ignore-write-errors’
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-outfile=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.
Numbers given as arguments to options (positions, sizes, retries, etc) may be followed by a multiplier and an optional ‘B’ for "byte".
Table of SI and binary prefixes (unit multipliers):
Prefix | Value | | | Prefix | Value |
| | s | sectors | ||
k | kilobyte (10^3 = 1000) | | | Ki | kibibyte (2^10 = 1024) |
M | megabyte (10^6) | | | Mi | mebibyte (2^20) |
G | gigabyte (10^9) | | | Gi | gibibyte (2^30) |
T | terabyte (10^12) | | | Ti | tebibyte (2^40) |
P | petabyte (10^15) | | | Pi | pebibyte (2^50) |
E | exabyte (10^18) | | | Ei | exbibyte (2^60) |
Z | zettabyte (10^21) | | | Zi | zebibyte (2^70) |
Y | yottabyte (10^24) | | | Yi | yobibyte (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.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 24, 2013 using texi2html 5.0.