I have two partial disk images from a failing hard drive. File B contains the bulk of the disk's contents, with gaps where sector reads failed. File A is the result of telling
ddrescue to retry all the failed sectors, so it is almost entirely gaps, but contains a few places where rereads succeeded. I now need to merge the interesting contents of File A back into File B. The algorithm is simple:
while not eof(A): read 512 bytes from A if any of them are nonzero: seek to corresponding offset in B write bytes into B
and I could sit down and write this myself, but I would first like to know if someone else has already written and debugged it.
(To complicate matters, due to limited space, File B and File A are on two different computers -- this is why I didn't just tell
ddrescue to attempt to fill in the gaps in B in the first place -- but A can be transferred over the network relatively easily, being sparse.)