Check efficiency of lz4 compression in ZFS

daisho

New Member
Apr 25, 2019
25
3
3
Hi,

is it possible to see the real space usage of a file in ZFS when e.g. lz4 compression is enabled?
When I do a ls -l of a folder it looks like it shows the non-compressed size (or compression is completely ineffective for those files) though.

Anyone already hampered with that kind of stuff?

Thanks,
daisho
 

gea

Well-Known Member
Dec 31, 2010
2,489
838
113
DE
You can check compressratio for all filesystems
zfs get compressratio

for a single filesystem ex
zfs get compressratio tank/data

btw
if you enable compress, this will only affect newly written or modified datablocks
 

daisho

New Member
Apr 25, 2019
25
3
3
Thanks, current ratio is 1.00 because apparently I have to enable the feature also on the ZFS filesystem and not only the pool :(
(/edit: or at least it is not sufficient that the pool lists the feature as activated)
 

vanfawx

Active Member
Jan 4, 2015
366
67
28
41
Vancouver, Canada
zfs get compressratio,used,logicalused

This will get you the compression ratio, how much it's actually using on disk, and how much it would be using if not for compression.
 

thulle

New Member
Apr 11, 2019
16
7
3
Use "ls -lks"

Writing two 1MiB files to disk, one all nulldata and one half nulldata and half random data then shows:

Code:
  1 -rw-r--r-- 1 thulle thulle 1048576 27 nov 16.21 zero
529 -rw-r--r-- 1 thulle thulle 1048576 27 nov 16.21 zero2
The allocated space is the first number, 1KiB for the nulldata and 529KiB when half of it is random data.
 

daisho

New Member
Apr 25, 2019
25
3
3
Thanks to you both. Now that I've actually enabled lz4 compression I can see the different ratios (on rpool it was enabled already).