1

I made a recursive copy of directory but according to du the two directories have different sizes.

$ cp -r site2 site
$ du site
838048  site/ca.oslin.org
276108  site/hts-cache
1114196 site
$ du site2
838360  site2/ca.oslin.org
276116  site2/hts-cache
1114516 site2
$ du -b site
582078187   site/ca.oslin.org
282724514   site/hts-cache
864830213   site
$ du -b site2
582393579   site2/ca.oslin.org
282724514   site2/hts-cache
865145605   site2
$ ls -a site2/ca.oslin.org/|wc -l
103060
$ ls -a site/ca.oslin.org/|wc -l
103060
$ diff -r site site2
$
Ernest A
  • 1,873

1 Answers1

5

du reports the disk usage, i.e. the size the files and all surrounding metadata is taking on the disk.

The fact you have a very minor discrepancy (0.10%) between the source and destination directories is likely due to the fact the original directory had files that were removed but that still use some ghost space in the directory entries table themselves.

You shouldn't worry about it. In fact, you might have found much larger discrepancies if going from one file system type to another, and even more if some original files were sparse files, or one or the other file systems was implementing compression.

jlliagre
  • 61,204
  • As for compression, -b comes in handy then. I find myself doing du -bsm after moving to ZFS, where I used to do du -sm, to get an idea of the amount of data. – user Mar 09 '15 at 14:59
  • That's a good observation, I've added it to http://unix.stackexchange.com/questions/120311/why-are-there-so-many-different-ways-to-measure-disk-usage – Gilles 'SO- stop being evil' Mar 09 '15 at 22:51