Don't worry, this isn't typical "du vs. df" question. :-) I mounted a squashfs image (via loop) and used du to reported the size: du --apparent-size -lsh image1/ which reported 215M. Then I used rsync ("rsync -aS") to copy all files to a real partition (ext4). To my surprise du reports for this directory now: 302M. Where do the additional 87MB come from? Without --apparent-size the values are 242M and 676M, respectively.

  • Run du -ab | sort -k2 on both sides and see what files' sizes differ. – Gilles Mar 1 '12 at 1:35
  • Maybe hard links get expanded, that is each hard link is copied as file. Try the -H option in rsync. – vasquez Mar 1 '12 at 6:19
  • @vasquez The -l option for du should have taken care of that but thanks for the suggestion. – antje-m Mar 7 '12 at 6:53

Gilles had the right idea. Comparing the two outputs showed that squashfs reported different sizes for the directories than ext4 which (probably) explains the difference. Thanks to all who responded.

  • So is there actually a nice way to compare disk usage without being confused by the different directory sizes? – drfrogsplat Nov 19 '12 at 1:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.