File sizes with ZFS compression
For OpenZFS:
ls -lh
shows the logical size of the file, the number of bytes you would see if you were to read the filedu -h --apparent-size
shows the logical size of the filedu -h
shows the space used on disk by the file
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 -