equivariant

File sizes with ZFS compression

For OpenZFS:

Typically du -h is less than du -h --apparent-size if you have compression on.

Demo:

$ # Create file compressible down to ~33%.
$ head -c $((33*1024**2)) /dev/urandom > data
$ yes meow | head -c $((67*1024**2)) >> data

$ ls -lh data
-rw-r--r-- 1 nobody nobody 100M Jan 24 14:38 data
$ du -h --apparent-size data
100M    data
$ du -h data
34M data

$ zfs get used,referenced,logicalused,logicalreferenced,compressratio zroot/foo
NAME       PROPERTY           VALUE     SOURCE
zroot/foo  used               33.6M     -
zroot/foo  referenced         33.6M     -
zroot/foo  logicalused        100M      -
zroot/foo  logicalreferenced  100M      -
zroot/foo  compressratio      2.98x     -