I have copied a folder using rsync including symlinks, hard links, permissions, deleting files on destination et cetera. They should be pretty identical.
One folder is on a USB drive and the other on a local disk.
If I run: du -bls on both folders, the size comes up as slightly different.
My du supports --apparent-size and it is applied by -s and -l should count the content of the hard links.
How can this difference be explained and how do I get the actual total?
Both file systems are ext4, the only difference is that the USB drive is encrypted.
EDIT:
I digged down to find the folders that were actually different, I found one and the content is not special (no block device, no pipes, no hard or symlinks, no zero bytes files), the peculiarity may be having several small files within it. The difference is 872830 vs 881022 of this particular folder.
I also ran du -blsc in both folders and the result is the same in this case.
Some extra details on the commands I used:
$ du -Pbsl $LOCALDIR $USBDIR | cut -f1 872830 881022 $ du -Pbslc $LOCALDIR/* [...] 868734 total $ du -Pbslc $USBDIR/* [...] 868734 total $ ls -la $USBDIR | wc 158 1415 9123 $ ls -la $LOCALDIR | wc 158 1415 9123 $ diff -sqr --no-dereference $LOCALDIR $USBDIR | grep -v identical [No output and all identical if I remove the grep]
md5sumover the files and then verify that against the other set? I wonder if you have a lot of directories that could account for the difference (some filesystems don't truncate the directories when you delete entries)?