Server Fault is a question and answer site for system and network administrators. 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

I'm using zfs on my FreeBSD 9.0 x64 and pretty happy with it, but I find it hard to count directory real, not compressed, size.

Surely I can walk over the directory and count every file size with ls, but I'd expect some extra key for du for that purpose.

So, how can I tell the directory size for dir placed on zfs with compression on?

Thamk you in advance for the advice, I simple can't rememeber there is no such a 'simple' way, without 'find ./ -type d -exec ls -l '{}' \; | awk ...'!

share|improve this question
See this answer for some solutions: – Zanchey Feb 21 '12 at 6:11
If using deduplication, what would you consider the "real" size to be? – ryandenki Feb 21 '12 at 6:36
up vote 6 down vote accepted

Use the du with its -A flag:

root@pg78:/usr/local/pgsql/data/base/218204 # du -A -h 221350.219
1.0G    221350.219
root@pg78:/usr/local/pgsql/data/base/218204 # du -h 221350.219
501M    221350.219

Very handy. It even works with -d for recursive goodness:

root@pg78:/usr/local/pgsql/data/base # du -h -c -d0 .
387G    .
387G    total
root@pg78:/usr/local/pgsql/data/base # du  -A -h -c -d0 .
518G    .
518G    total
share|improve this answer
Really good solution! And the best it is there "right from the box"! – Alexander Oct 4 '12 at 6:38

You could install the GNU version of du(1):

cd /usr/ports/sysutils/coreutils && make install clean

Then you can use the --apparent-size flag:

/space# zfs create space/comptest
/space# zfs set compression=on space/comptest
/space# dd if=/dev/zero of=/space/comptest/zerofile bs=1M count=40
/space/comptest# gdu
2K      .
/space/comptest# gdu --apparent-size
40961K  .
share|improve this answer
Great, thank you! – Alexander Feb 21 '12 at 6:36
There is NO reason to use a port for this. Use the base OS du with its -A flag. – Sean Oct 4 '12 at 0:05
This is useful for ZFS on Linux. GNU du doesn't have a -A option. – jakar May 31 '14 at 6:55

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.