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

9 Fill mode

When ddrescue is invoked with the ‘--fill-mode’ option it operates in "fill mode", which is different from the default "rescue mode". That is, if you use the ‘--fill-mode’ option, ddrescue does not rescue anything. It only fills with data read from the input file the blocks of the output file whose status character from the logfile coincides with one of the type characters specified as argument to the ‘--fill-mode’ option.

In fill mode the input file may have any size. If it is too small, the data will be duplicated as many times as necessary to fill the input buffer. If it is too big, only the data needed to fill the input buffer will be read. Then the same data will be written to every cluster or sector to be filled.

Note that in fill mode the input file is always read from position 0. If you specify a ‘--input-position’, it refers to the original input file from which the logfile was built, and is only used to calculate the offset between input and output positions.

Note also that when filling the input file of the original rescue run you should set ‘--input-position’ and ‘--output-position’ to identical values, whereas when filling the output file of the original rescue run you should keep the original offset between ‘--input-position’ and ‘--output-position’.

The ‘--fill-mode’ option implies the ‘--complete-only’ option.

In fill mode the logfile is updated to allow resumability when interrupted or in case of a crash, but as nothing is being rescued the logfile is not destroyed. The status line is the only part of the logfile that is modified.

The fill mode has a number of uses. See the following examples:

Example 1: Mark parts of the rescued copy to allow finding them when examined in an hex editor. For example, the following command line fills all blocks marked as ‘-’ (bad-sector) with copies of the string ‘BAD SECTOR ’:

printf "BAD SECTOR " > tmpfile
ddrescue --fill-mode=- tmpfile outfile logfile

Example 2: Wipe only the good sectors, leaving the bad sectors alone. This way, the drive will still test bad (i.e., with unreadable sectors). This is the fastest way of wiping a failing drive, and is specially useful when sending the drive back to the manufacturer for warranty replacement.

ddrescue --fill-mode=+ --force /dev/zero bad_drive logfile

Example 3: Force the drive to remap the bad sectors, making it usable again. If the drive has only a few bad sectors, and they are not caused by drive age, you can probably just rewrite those sectors, and the drive will reallocate them automatically to new "spare" sectors that it keeps for just this purpose. WARNING! This may not work on your drive.

ddrescue --fill-mode=- --force --synchronous /dev/zero bad_drive logfile

Fill mode can also help you to figure out, independently of the file system used, what files are partially or entirely in the bad areas of the disc. Just follow these steps:

1) Copy the damaged drive with ddrescue until finished. Do not use sparse writes. This yields a logfile with only finished (‘+’) and bad-sector (‘-’) blocks.

2) Fill the bad-sector blocks of the copied drive or image file with a string not present in any file, for example "DEADBEEF".

3) Mount the copied drive (or the image file, via loopback device).

4) Grep for the fill string in all the files. Those files containing the string reside (at least partially) in damaged disc areas. Note that if all the damaged areas are in unused space, grep will not find the string in any file, which means that no files are damaged.

5) Unmount the copied drive or image file.

6) Optionally fill the bad-sector blocks of the copied drive or image file with zeros to restore the disc image.

Example 4: Figure out what files are in the bad areas of the disc.

ddrescue -b2048 /dev/cdrom cdimage logfile
printf "DEADBEEF" > tmpfile
ddrescue --fill-mode=- tmpfile cdimage logfile
rm tmpfile
mount -t iso9660 -o loop,ro cdimage /mnt/cdimage
find /mnt/cdimage -type f -exec grep -l "DEADBEEF" '{}' ';'
umount /mnt/cdimage
ddrescue --fill-mode=- /dev/zero cdimage logfile

[ << ] [ < ] [ 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.