I migrated some special directories (not supported by common migration tools) from one Synology NAS volume (ext4) to another (btrfs). After checking if the synchronization was successful I found that sizes differ a lot.
I understand that there are block size differences but du gives me wrong data size within the same volume.
The total size of the whole directory is more than 1 TB so I narrowed the commands below to a smaller sub-directory.
Different sizes:
sudo du -sm /volume[12]/@synologydrive/@sync/repo/1/2
11418 /volume1/@synologydrive/@sync/repo/1/2
11122 /volume2/@synologydrive/@sync/repo/1/2
But for each sub-directory I get correct sizes (more or less when bytes are used) - sub-directory n is selected:
sudo du -sm /volume[12]/@synologydrive/@sync/repo/1/2/n
295 /volume1/@synologydrive/@sync/repo/1/2/n
295 /volume2/@synologydrive/@sync/repo/1/2/n
sudo du -sb /volume[12]/@synologydrive/@sync/repo/1/2/n
308387853 /volume1/@synologydrive/@sync/repo/1/2/n
308391693 /volume2/@synologydrive/@sync/repo/1/2/n
But, I'm getting completely different sizes when * is used (i.e. even on the same volume compare command above and this one on volume2):
sudo du -sm /volume[12]/@synologydrive/@sync/repo/1/2/* | grep n$
295 /volume1/@synologydrive/@sync/repo/1/2/n
200 /volume2/@synologydrive/@sync/repo/1/2/n
sudo du -sb /volume[12]/@synologydrive/@sync/repo/1/2/* | grep n$
308387853 /volume1/@synologydrive/@sync/repo/1/2/n
209533219 /volume2/@synologydrive/@sync/repo/1/2/n
I also counted sizes of all files under the n directory and I'm getting the same sizes:
ls -lA /volume1/@synologydrive/@sync/repo/1/2/n | tr -s ' ' | cut -f5 -d" " | awk '{s+=$1} END {print s}'
308387597
ls -lA /volume2/@synologydrive/@sync/repo/1/2/n | tr -s ' ' | cut -f5 -d" " | awk '{s+=$1} END {print s}'
308387597
So, it seems that the directories are "rsynced" correctly (same number of files, same sizes) and tried to exclude differences between two different file systems. But du gives me significantly bigger size on new volume1 (or more exactly - significantly smaller on old volume2).
Do you have any explanation for it?
Notes:
volume1is new btrfs target volume (I copied data to)volume2is old ext4 source volume (I copied data from)- Data were copied using
sudo rsync -a --progress --delete /volume2/@synologydrive /volume1
rsynccommand? Did you include--sparseand--hard-links? It also matters how you count the sizes that you compare. For sparse files, you either count the apparent sizes (shown bylsby default), or you count the actual size (number of bytes on disk). For hard-linked filesduwould only count a file once. – Kusalananda Dec 02 '21 at 11:36rsynccommand is mentioned above in Notes. There are no hard-links (AFAIK). I also triedrsyncwith--sparseswitch but no change. However, the core of the question is probably not in rsync itself as the sizes differ on the source volume - there are differences betweendu ... /1/2/nanddu ... /1/2/n/*. – CraZ Dec 02 '21 at 11:48du -lswitch I'm getting same folder sizes. Thanks, I've learned some new today ;-) – CraZ Dec 02 '21 at 12:07