From a Linux box, I recently mounted a Windows share using CIFS.

The intent was to "locally" use rsync to backup my Windows machine. The command line used to mount the Windows drive is something like:

mount \\\share /cifs1 -t cifs -o noserverino,iocharset=utf8,ro 

Please also note that the drive attached to the Linux box is formatted NTFS.

When doing a sample backup, rsync was always re-copying the directories (names), but not the files. After looking more closely at the ls -lh output at both ends, I noticed that on the Linux side the size of the directory level is always 0:

TTT-Admin@1080-Router:/tmp/mnt/RT-1080/tmp# ls -lh
drwxrwxrwx    1 TTT-Admi root           0 Feb  8 12:14 DeltaCopy

but the size of the directory level on the CIFS side was always different from 0:

TTT-Admin@1080-Router:/cifs1/temp/Rsync-Packages# ls -lh
drwxr-xr-x    1 TTT-Admi root        8.0K Feb  8 12:14 DeltaCopy

This difference explains why rsync was always recopying directories, but not recopying the folders (which was correct, folder sizes and time stamps being the same on both ends).

The rsync command is:

rsync -av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/rsync
 -av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/

Is a directory supposed to "have a size" or not? What should I do to solve this discrepancy ?

  • Directory size as shown by ls is mostly meaningless. rsync doesn't pay attention to it. The reason why rsync wants to copy them is something else. For example, I see above a permissions discrepancy: drwxrwxrwx vs drwxr-xr-x.
    – Celada
    Feb 14, 2015 at 0:40
  • By the way, rsync works MUCH better if you run it on both sides of a network connection rather than locally on a remote-mounted filesystem.
    – Celada
    Feb 14, 2015 at 0:41
  • Why do you say that ls reported sizes are meaningless? Rsync works by looking at the time stamp and at the size, no other points AFAIK. In fact I have no problem with the files syncing, even if they show the same discrepancy with the rights.option "a" ("archive")includes the recursive option. The problem seems to be related to the fact that directories have a size on the cifs mount, but not on the linux mount (the last being normal). rsync always see a difference in size (for the directories) and sync again the directories (but not the folders in the directories, which is correct).
    – huotg01
    Feb 15, 2015 at 12:52
  • Reported sizes OF DIRECTORIES are artifacts of the underlying filesystem implementations. They don't stand for something like the number of files inside the directory or the sum of the sizes of the files located inside the directory, or anything, really. Each individual filesystem can populate that field with basically anything is wants to. rsync does indeed use size and timestamp as a shortcut for deciding whether or not regular files match between source and target, but not directories.
    – Celada
    Feb 15, 2015 at 13:01
  • Thanks @Celada Even if reported sizes are artifacts of the underlying filesystem implementation, obviously Rsync does use the reported size (and time stamp) of the directories, otherwise I would not have the problem I have. Do you have another explanation ?
    – huotg01
    Feb 15, 2015 at 16:16


You must log in to answer this question.

Browse other questions tagged .