I've SCPed a git repo from a machine running Ubuntu to a machine running Centos (there would be issues with pushing currently uncommitted changes into the repo and cloning it on the new machine), but I've noticed that the directories are different sizes:

chris@ubuntu:~$ du -h repo/

[chris@centos ~]$ du -h repo/

The command I used was

scp -rp -i my_public_key.pem repo/ chris@centos:/home/chris/ 

The number of files is the same

chris@ubuntu:~$ find repo/ | wc -l

[chris@centos ]$ find repo/ | wc -l

Even the .git directory is a different size:

chris@ubuntu:~/repo/.git$ du -s

[chris@centos .git]$ du -s

Although the differences are small, I'm curious why they occur. Any pointers as to why this might would be gratefully received!


It doesn't seem it's just a git repo: one of the directories I transferred has just got 2 text files in it and even this is reported as having a different size:

chris@ubuntu:~/repo/data_files$ ls -la
total 7140
drwxrwxrwx 1 chris chris     512 Sep  3 18:26 .
drwxrwxrwx 1 chris chris     512 Sep  4 17:28 ..
-rw-r--r-- 1 chris chris    1839 Aug 31 14:03 file1.csv
-rw-r--r-- 1 chris chris 7306203 Aug 27 16:47 file2.csv

[chris@centos data_files]$ ls -la
total 7140
drwxrwxrwx. 2 chris chris      57 Sep  3 17:26 .
drwxrwxrwx. 5 chris chris      66 Sep  4 16:28 ..
-rw-r--r--. 1 chris chris    1839 Aug 31 13:03 file1.csv
-rw-r--r--. 1 chris chris 7306203 Aug 27 15:47 file2.csv

chris@ubuntu:~/repo/data_files$ du -sb
7308554 .

[chris@centos data_files]$ du -sb
7308099 .
  • the 2 files are reported as being the same size
  • the addition of the 2 files is 7308042: this is 57 bytes smaller than ubuntu reports and 512 smaller than centos reports
    • curiously(?!) this is the same as the reported size of .

so, it seems that this is the cause of the discrepancy.

  • Is there a way to ask du to ignore this?
  • why do centos and ubuntu have this difference?
  • Maybe on the source machine some of the files are hard-linked. – Emmanuel Rosa Sep 6 '18 at 12:33
  • @EmmanuelRosa hmm, I still get a discrepancy when I use du -ls – ChrisW Sep 6 '18 at 12:40
  • Since making the copy, have you executed any git commands on any of the repos? I believe Git has packing process which compacts some of its files. Perhaps you implicitly triggered such a process. – Emmanuel Rosa Sep 6 '18 at 12:43
  • No - I purposefully checked the sizes before making any changes. I even deleted and reran the scp command to check again! – ChrisW Sep 6 '18 at 13:50
  • 1
    What is the filesystem type used on each system? Different filesystems may have different allocation block sizes and different ways to store filesystem metadata like directories, and so the exact same files and directories may have different du results on different filesystems. – telcoM Sep 6 '18 at 15:28

Your Answer

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

Browse other questions tagged or ask your own question.