Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 Aug 6 '12 at 7:19

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.

share|improve this answer
    
Thanks, I use rsync all the time, but wasn't aware that --inplace works with device files. – Blair Zajac Aug 6 '12 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] – Blair Zajac Aug 6 '12 at 16:30
    
Turns out that even with --inplace, rsync 3.0.9 clobbers /dev/md0 first. – Blair Zajac Aug 6 '12 at 16:57
    
Is it trying to append? – Mechanical snail Aug 6 '12 at 17:28

You must log in to answer this question.

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