I've got two partition images (A and B) and want to use them to create a patch that I can apply on A on another computer in order to get the new B image without flooding the network. I have the following requirements:

  • works on Linux
  • can create diffs
  • can use diffs to patch files
  • can handle binary files
  • can handle large files (a few hundred GB should work)
  • no user interaction required (just a console application)
  • ideally, should be able to read from/write to pipes (so that I can pipe into it from a gzip-compressed file and write to one)

Does something like that exist?

up vote 11 down vote accepted

You should probably take a look at the rsync-related tools: rdiff and rdiff-backup. The rdiff command lets you produce a patch file and apply it to some other file.

The rdiff-backup command uses this approach to deal with entire directories, but I'm guessing you're working with single-file disk images, so rdiff will be the one to use.

  • Thanks, rdiff looks good! – thejh May 13 '11 at 15:13
  • What does "signature" and "delta" mean for rdiff? The man page doesn't say. – Tor Klingberg Sep 12 '16 at 12:54
  • 1
    To answer my own question, creating a delta with rdiff is a two step process. First create a signature file from the old file, then use the signature and new file to create the delta. They can be run together with rdiff signature oldfile | rdiff delta - newfile deltafile – Tor Klingberg Sep 13 '16 at 9:10

xdelta can do everything you want. Fair warning though, if your images aren't very similar, you can end up with a very large patch, because xdelta uses half of the defined memory buffer for finding differences. More information is available at the TuningMemoryBudget wiki page. Increasing the buffer size may help out quite a bit.

bsdiff is another option, but it's very RAM hungry and completely inappropriate for anything the size of a disk image.

bsdiff is quite memory-hungry. It requires max(17*n,9*n+m)+O(1) bytes of memory, where n is the size of the old file and m is the size of the new file. bspatch requires n+m+O(1) bytes.

JDIFF is a program that outputs the differences between two (binary) files.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.