I have used cp -rl
to copy a folder. When measuring the size of the source and of the result of the copy du -sl
returns slightly different sizes, even though diff
confirms that their content are identical:
$ cp -rl folderA/ folderB/
$ du -sl folderA folderB
98561224 folderA
98590512 folderB
$ diff --brief -ra folderA/ folderB/
$
Both folders reside on the same hard drive, no modifications to any of them have been done between the copy and the measure. I found nothing in the documentation of du
and cp
which could explain the difference.
Best Answer
Just tried this myself, and I found the discrepancy in size is from the directory files. Since they are not hardlinked they are new files that get created, maybe not with the exact same metadata?
To illustrate this run the following commands:
These sizes should be identical (dir files not included). You could print the listings with the directory sizes and diff the results to find which dirs exactly are different.