1

I tried to find out how big each directory in my root-directory is. I cd'ed to / and did:

ls | xargs du -sh

the result:

...
1.9M    tmp
975M    usr
70G     var
...

Then I went to /var/www and did:

du -sh

the result:

81G     .

I am intrigued: How can a folder inside a 70 GB folder be 81 GB?

After experimenting a bit, i found out that:

du -sh /*/

will result in

...
1.9M    tmp
975M    usr
70G     var
...

whereas du -hd 1 will result in

...
1.9M    tmp
975M    usr
91G     var
...

Two different sizes for the /var directory, but all other directories have no difference in size.

What's the difference between those two variations of the du command?

Any ideas?

  • I can't tell this is the case for sure (because you didn't provide full du outputs) but du keeps track of inodes it visits, so if there are hardlinks then only the first occurrence will be counted. – Kamil Maciorowski Aug 3 '17 at 13:12
  • @KamilMaciorowski Thanks for that bit of information, i didn't know that yet. But all other directories have the exact same size in both methods. Only /var differs. If it'd be the inodes, shouldn't it equal out in sum? – JLix Aug 3 '17 at 13:32
  • As far as I can tell the equivalent to du -h -s $something is du -h -d 0 $something. With -d 1 I don't see the same items listed. Also, with either option, inode are only taken in account once; several hardlinks don't inflate the reported size. – xenoid Aug 3 '17 at 15:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.