FreeBSD: How to know real file size on zfs with compression on?

Solution 1:

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

Solution 2:

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  .

Tags:

Find

Ls

Freebsd

Du

Zfs