I want to sync 2 directories (/src & /dst) to mirror all the files in both of them.

Here is a steps:

  1. sudo rsync -vaP --stats /src /dst -> completed without errors
  2. sudo rsync -vaP --stats /dst /src -> completed without errors
  3. diff -rq /src /dst-> doesn't show any diffs.
  4. du -s /src && du -s /dst shows different sizes (10% diff).

How it's possible? I'm completely stuck with this dilemma.

  • Search about sparse files – Gilles Quenot Jan 10 '20 at 0:14
  • Sparse files may be expanded on copy when the -S flag is not used. (Will make the destination take more space)
  • Hard links within the tree may be expanded to separate files on copy when the -H flag is not used. (Will make the destination take more space)
  • Filesystems may have different allocation sizes. A one-byte file may take up 512 bytes of disk allocation on one filesystem and may take up 4096 bytes (or even more) on another. If your tree has a lot of small files, this will make a large difference. (Destination may take more or less space depending on the particulars)
  • Directories may be much larger than necessary to hold the current contents on some filesystems. When the contents are copied, the directory will be smaller on the destination. Not normally a big deal, but some pathological directories can be enormous. (Will make the destination take less space)

It's also possible for filesystems to have different compression/deduplication/redundancy settings leading to different storage requirements for the data. But that's less common, and even when present the differences aren't always visible via du.

  • There might also be hard-linked files, which (without the -H option) will be copied as separate files. – Gordon Davisson Jan 10 '20 at 5:30
  • Quite true. I'll add that in as well. – BowlOfRed Jan 10 '20 at 5:50

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.