If the block size of a file system is 4KB, then for a 1KB file, 3KB space(which is internal fragmentation) is wasted. So, under a directory, is there any command to summarize how much disk space is wasted due to internal fragmentation?

  • 2
    Maybe a more useful metric (and easier to obtain and define) would be to compare the disk usage (which accounts for that fragmentation but also compression, sparseness, block sharing...) with the some of the file sizes. Nov 21, 2012 at 16:34
  • What filesystem are you using?
    – jippie
    Nov 21, 2012 at 20:59
  • @jippie I'm using ext3.
    – twimo
    Nov 23, 2012 at 7:42

1 Answer 1


Except if you have sparse files, it sounds like you're looking for du -s «dir» vs. du -s --apparent-size «dir».

Or, in stat output, the difference between size and blocks × block size:

anthony@Zia:/tmp$ echo -n 1 > foo 
anthony@Zia:/tmp$ stat -c '%s    %b × %B' foo 
1    8 × 512

And with du (which defaults to kilobytes, add -B 1 if you want bytes):

anthony@Zia:/tmp$ du foo 
4       foo
anthony@Zia:/tmp$ du --apparent-size foo 
1       foo

du will of course count entire directory trees, not just individual files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .