#!/bin/sh # TO USE THIS SCRIPT, MAKE SURE TO UPDATE THE DEVICE SIZE BELOW TO MATCH # YOUR DISK! if [ "$#" -ne 1 ]; then echo "1 filename expected" fi ( # Add current position header echo "0x0 ?"; # Convert to hex, and from 4096-blocks to bytes cat "$1" | sort -n | awk '{printf "0x%x 0x%x +\n", $1 * 4096, $2 * 4096}' # Add last byte, so the mapfile will have the right size # This should be the block device size minus one echo "0x1d1aa8f5fff 0x1 ?" ) | ddrescuelog --complete-mapfile='?' - > "$1.done" ddrescuelog --change-types='?+,+?' "$1.done" > "$1.notdone"