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?

3
  • 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. Aug 3, 2017 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, 2017 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, 2017 at 15:50

0

You must log in to answer this question.

Browse other questions tagged .