Using ZFS compression


One of the nice things about ZFS is it’s ability to transparently compress file system data. Compression can be enabled or disabled dynamically, and compression policies can be applied on a per-file system basis. This can be extremely useful if you need to save space on a file system that is used primarily to archive data, since you can create a file system decicated to data archival, and then enable compression on that file system to save space. If on the other hand performance is your primary concern (e.g., actively used Oracle database files), you can create a file system without compression. Both of these file systems can reside in the same ZFS pool, and enabling and disabling compression is a simple and straight forward operation.

To enable compression on the ZFS file system named concat/archive, the zfs utilities set option can be used to set the file systems “compression” attribute :

$ zfs set compression=on concat/archive

To see if compression is enabled for the file system concat/archive, the zfs utilities get options can be used to retrieve the value for the file systems “compression” attribute:

$ zfs get compression concat/archive

NAME PROPERTY VALUE SOURCE
concat compression on local

Once compression is enabled on a file system, ZFS will track the compression ratio for the data on the file system. To view the compression ratio, the zfs utilities get option can be run to retrieve the “compressratio” attribute:

$ zfs get compressratio

NAME PROPERTY VALUE SOURCE
concat compressratio 1.82x -
concat/archive compressratio 1.00x -
concat/zone2 compressratio 2.83x -

ZFS compression is some sweet livin’!

This article was posted by Matty on 2006-10-15 09:03:00 -0400 -0400