ZFS: Enable filesystem compression

ZFS can compress data on filesystems. Some folks adamantly refuse to compress mounted filesystems citing performance issues. While not every situation is appropriate, compression can increase system performance by improving IO at the cost of CPU. In most cases, disk IO, more than CPU, is rate determining. This recipe descibes turning on ZFS compressionand checking its compression ratio status.


A great use for ZFS compression is a filesystem containing logs. A busy webserver can generate massive logfiles. Enabling compression for log files makes sense because they are not heavy on read operations, text in logs compresses well, and substantially more log data can be stored online and accessible.

To enable compression for the filesystem /techrx/logs, use the zfs command:

zfs set compression=yes techrx/logs

Want to know how well the compression is working? Check it using this command:

zfs get compressionratio techrx/logs

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

One Response to “ZFS: Enable filesystem compression”

  1. April 12, 2012 at 2:19 am, steffen said:

    it is actually zfs get compressratio techrx/logs

    Reply

Leave a Reply

You may also like-

ZFS: Ten reasons to reformat your hard drivesThe much anticipated release of the new ZFS filesystem in Solaris 10 will revolutionize the way system administrators (and executives) think about and work ...