Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – Stéphane Chazelas Nov 21 '12 at 16:34
What filesystem are you using? – jippie Nov 21 '12 at 20:59
@jippie I'm using ext3. – zzhang Nov 23 '12 at 7:42
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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