3

I have a dd copy of a filesystem from a SSD I want to restore back to the same SSD filesystem due to a bad OS crash, putting it back into a known good state. 95% of the blocks will be the same, so to avoid wear on the SSD I don't want to have ddrescue write blocks to the SSD that are identical to the blocks in the dd copy.

Is there a tool equivalent to dd or ddrescue or command line flags to the tools that will not write identical blocks on the destination? It'll be slower since it'll do a read and optionally write, but I'm ok with the slowdown.

1
  • 1
    There's no way with standard tools to know what bits are written to which storage location. The controller abstracts this away. Go with Mechanical snail's suggestion.
    – user3463
    Commented Aug 6, 2012 at 7:19

2 Answers 2

3

It should be possible to do this using rsync, the differential data transfer tool.

See the man page, and use the --inplace option because you want to write directly into the device file.

That said, a single write pass across the disk is a trivial amount of wear, so consider just dding it over.

4
  • Thanks, I use rsync all the time, but wasn't aware that --inplace works with device files. Commented Aug 6, 2012 at 16:18
  • It's not working with rsync 3.0.9 on RHEL5:bash-3.2# $ rsync -P --inplace md0.image /dev/md0 md0.image 18883313664 2% 118.28MB/s 1:26:10 rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Broken pipe (32) rsync: write failed on "/dev/md0": No space left on device (28) rsync error: error in file IO (code 11) at receiver.c(322) [receiver=3.0.9] rsync: connection unexpectedly closed (28 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9] Commented Aug 6, 2012 at 16:30
  • Turns out that even with --inplace, rsync 3.0.9 clobbers /dev/md0 first. Commented Aug 6, 2012 at 16:57
  • Is it trying to append? Commented Aug 6, 2012 at 17:28
0

e2image from e2fstools can do this with the -c option, but it can't read an input image from stdin as it seems to need to seek around.

The "old" dd_rescue tool (which is not the same as GNU ddrescue) has a -W option to avoid writes and can read from stdin: https://sourceforge.net/projects/ddrescue/ You might want -a as well to skip writing blocks of zeros, depending on the situation (I'm currently looking at restoring images to LVM thin pools while preserving the CoW characteristics.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .