## 16 Ddrescuelog ¶

Ddrescuelog is a tool that manipulates ddrescue mapfiles, shows mapfile contents, converts mapfiles to/from other formats, compares mapfiles, tests rescue status, and can delete a mapfile if the rescue is done. Ddrescuelog operations can be restricted to one or several parts of the mapfile if the domain setting options are used.

When performing logic operations (AND, OR, XOR) on mapfiles of different extension, only the blocks present in both files are processed. Other blocks are left untouched.

Here are some examples of how to use ddrescuelog, alone or in combination with other tools.

Example 1: Delete the mapfile if the rescue is finished (all data have been recovered without errors left).

    ddrescue -f /dev/sda /dev/sdb mapfile
    ddrescuelog -d mapfile

Example 2: Rescue two ext2 partitions in `/dev/sda` to `/dev/sdb` and repair the file systems using badblocks lists generated with ddrescuelog. File system block size is 4096.
Note: you do need to partition `/dev/sdb` beforehand.

    fdisk /dev/sdb                                   # partition /dev/sdb
    ddrescue -f /dev/sda1 /dev/sdb1 mapfile1
    ddrescue -f /dev/sda2 /dev/sdb2 mapfile2
    ddrescuelog -l- -b4096 mapfile1 > badblocks1
    ddrescuelog -l- -b4096 mapfile2 > badblocks2
    e2fsck -v -f -L badblocks1 /dev/sdb1
    e2fsck -v -f -L badblocks2 /dev/sdb2

Example 3: Rescue a whole disc with two ext2 partitions in `/dev/sda` to `/dev/sdb` and repair the file systems using badblocks lists generated with ddrescuelog. Disc sector size is 512 (first `-b`), file system block size is 4096 (second `-b`). Arguments to options `-i` and `-s` are the starting positions and sizes of the partitions being rescued.
Note: you don’t need to partition `/dev/sdb` beforehand, but if the partition table on `/dev/sda` is damaged, you’ll need to recreate it somehow on `/dev/sdb`.

    ddrescue -f /dev/sda /dev/sdb mapfile
    fdisk /dev/sdb                                  # get partition sizes
    ddrescuelog -l- -b512 -i63s -o0 -s767457s -b4096 mapfile > badblocks1
    ddrescuelog -l- -b512 -i767520s -o0 -s96520s -b4096 mapfile > badblocks2
    e2fsck -v -f -L badblocks1 /dev/sdb1
    e2fsck -v -f -L badblocks2 /dev/sdb2