I cloned several 32Gb pendrives with a linux system installed using dd. Later I did shrink a partition and I did some little more changes (in the "Master"). Is there any tool for transferring only the blocks changed for evoiding the slow full re-cloning with dd?

I thought in rsync, but it only seems to work with files.


According to the description: Bscp copies a single file or block device over an SSH connection, transferring only the parts that have changed.

  • This just saved me! Thank you. I wonder why Rsync couldn't do it, since it clearly has a similar algorithm, where it only copies the blocks that changed in a large file. – Tobia May 29 '17 at 7:31
  • @Tobia You could do it with rsync just not directly on the block device itself. If you had an image file created from the device, that file would obviously be transferable. – Kusalananda Sep 13 '17 at 10:11
  • 1
    @Kusalananda yes, but if I had the free space to make an image of the entire block device, I probably would not have needed the smart copy tool. – Tobia Sep 13 '17 at 16:04

No, and there can't be. Rsync uses file timestamps to determine what to copy and what to skip. There's nothing similar at a lower level than files. The data on the disk doesn't remember that there used to be a different partition arrangement.

In order to make sure that two disks are identical, a tool working underneath the filesystem would have to read every block on both sides and copy the source block onto the target block if they differ. That's usually slower than unconditionally doing the copy. It might be faster if writes to the target disk are a lot slower than reads (but still a far cry from what rsync gains by completely skipping unchanged files); I think I've seen a tool that did this but I can't find it now.

If you made a change to the partition setup on one side, make the same change on the other side, then call rsync on the individual filesystems.

  • I thought I can save some time. I have to resize the partition, to add some partitions (for uefi and grub-bios), to format, to boot each pendrive, to re-install grub, to install uefi, and to install some little patch. Only the last part could be done by rsync :-/ – Gea Planet Feb 14 '17 at 9:31
  • 1
    It takes 10 minutes to read 32Gb, but 3 hours to write the full pendrive with dd. All changes will not be more than 10Mbs in total. It would be great an utility for reading and comparing on the fly two block devices. – Gea Planet Feb 14 '17 at 9:35
  • @GeaPlanet probably considerably faster if you use cat instead of dd – roaima Sep 13 '17 at 13:36
  • The mechanism is selectable. You can tell it to use checksums. This is the good thing about rsync and large files, it will do a checksum for each chunk of the file so that a network bit flip doesn't cause the whole thing to be re-downloaded. I haven't tried it yet, but rsync has a --device option just for this! – Daniel Santos Jul 1 '18 at 18:37
  • Oh, --devices is only for copying the device node file. – Daniel Santos Jul 1 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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