ZFS properties can be considered as the options that allow us to configure the file system. Among these options, we can find data compression, deduplication, file duplication, or file sharing via NFS/SAMBA. In this article, we will test data compression using a simple example.
Before continuing with the article, it is advisable to review this previous one so that all the concepts are clear.
We check the system datasets:
NAME USED AVAIL REFER MOUNTPOINT
data 528K 831M 192K /data
zroot 1.07G 4.26G 192K /zroot
By default, FreeBSD enables compression in the zroot dataset. To perform the test, we disable it in zroot and enable it in data:
root@freeBSD:~ # zfs set compression=gzip data
We generate the 100Mb test file:
100+0 records in
100+0 records out
104857600 bytes transferred in 0.772029 secs (135820774 bytes/sec)
We check the file size in the zroot dataset:
100M test_file
We copy the file to the data dataset:
We check the file size in the data dataset:
512B /data/test_file
As we can see, the size difference is overwhelming because the content of the file is nothing but zeros, making it a highly compressible pattern.
NOTE: It should be noted that properties are cumulative, meaning that if we enable compression on /data, any dataset under /data will inherit compression.
We can check the value of the feature with the following command:
NAME PROPERTY VALUE SOURCE
data compression gzip local
We can remove the configuration with the following command:
root@freeBSD:~ # zfs get compression data
NAME PROPERTY VALUE SOURCE
data compression off default
We can check all the features with a single command:
NAME PROPERTY VALUE SOURCE
data type filesystem -
data creation Wed Nov 11 18:46 2020 -
data used 840K -
data available 831M -
data referenced 192K -
data compressratio 1.00x -
data mounted yes -
data quota none default
data reservation none default
data recordsize 128K default
data mountpoint /data default
data sharenfs off default
data checksum on default
data compression gzip local
data atime on default
data devices on default
data exec on default
data setuid on default
data readonly off default
data jailed off default
data snapdir hidden default
data aclmode discard default
data aclinherit restricted default
data createtxg 1 -
data canmount on default
data xattr off temporary
data copies 1 default
data version 5 -
data utf8only off -
data normalization none -
data casesensitivity sensitive -
data vscan off default
data nbmand off default
data sharesmb off default
data refquota none default
data refreservation none default
data guid 81431519837003581 -
data primarycache all default
data secondarycache all default
data usedbysnapshots 0 -
data usedbydataset 192K -
data usedbychildren 648K -
data usedbyrefreservation 0 -
data logbias latency default
data objsetid 51 -
data dedup off default
data mlslabel -
data sync standard default
data dnodesize legacy default
data refcompressratio 1.00x -
data written 192K -
data logicalused 170K -
data logicalreferenced 63K -
data volmode default default
data filesystem_limit none default
data snapshot_limit none default
data filesystem_count none default
data snapshot_count none default
data redundant_metadata all default
data special_small_blocks 0 default
Properties can be user-defined, this information is inserted within the dataset itself and is usually used to indicate important information about its content. User-defined properties are distinguished by having a colon in the namespace. Let’s see an example.
root@freeBSD:~ # zfs get user:info data
NAME PROPERTY VALUE SOURCE
data user:info 1234 local
To remove the user-defined property, we will act in the same way as with a normal property:
We check that the property does not exist:
NAME PROPERTY VALUE SOURCE
data user:info - -