{"id":1117,"date":"2013-07-18T00:53:00","date_gmt":"2013-07-17T16:53:00","guid":{"rendered":"http:\/\/www.computersolutions.cn\/blog\/?p=1117"},"modified":"2013-07-18T00:53:00","modified_gmt":"2013-07-17T16:53:00","slug":"zfs-bits-and-bobs","status":"publish","type":"post","link":"https:\/\/www.computersolutions.cn\/blog\/2013\/07\/zfs-bits-and-bobs\/","title":{"rendered":"<!--:en-->ZFS bits and bobs<!--:-->"},"content":{"rendered":"<p><!--:en-->Behind the scenes we use ZFS as storage for our offsite backups.<br \/>\nWe have backups in 2 separate physical locations + original data on the server(s), as data is mui importante!<br \/>\nZFS is a rather nice storage file system that improves radically on older RAID based solutions, offering a lot more funky options, like snapshot&#8217;s (where the OS can store have multiple versions of files, similar to Time Machine backups), and more importantly compression.<\/p>\n<p>At some point we&#8217;ll be deploying a SAN (storage area network) on a blade server in the data center for data using ZFS, using lots of three and four letter acronyms &#8211;<br \/>\nESXi for base OS, then a VM running providing ZFS storage and iSCSI targets with hardware passthru for other VM&#8217;s, then other blades in the server doing clustering.<br \/>\nRight now we&#8217;re waiting on an LSI SAS card (see more anacronyms!), so we can deploy&#8230;, but I digress.<\/p>\n<p>Back to ZFS.<\/p>\n<p>The ZFS version we use now allows flags, yay!, and that means we can choose alternate compression methods.<br \/>\nThere is a reasonably newish compression algorithm called LZ4 that is now supported, and it improves both read and write speeds over normal uncompressed ZFS, and some benefits over compressed ZFS using the standard compression algorithm(s).<\/p>\n<p>To quote:  &#8220;LZ4 is a new high-speed BSD-licensed compression algorithm written by Yann Collet that delivers very high compression and decompression performance compared to lzjb (>50% faster on compression, >80% faster on decompression and around 3x faster on compression of incompressible data)&#8221;<\/p>\n<p>First up check if your zfs version supports it:<\/p>\n<p><code><br \/>\nzpool upgrade -v<br \/>\nThis system supports ZFS pool feature flags.<\/p>\n<p>The following features are supported:<\/p>\n<p>FEAT DESCRIPTION<br \/>\n-------------------------------------------------------------<br \/>\nasync_destroy                         (read-only compatible)<br \/>\n     Destroy filesystems asynchronously.<br \/>\nempty_bpobj                           (read-only compatible)<br \/>\n     Snapshots use less space.<br \/>\nlz4_compress<br \/>\n     LZ4 compression algorithm support.<br \/>\n<\/code><\/p>\n<p>Mine does (well duh!)<\/p>\n<p>So&#8230;, I can turn on support.<\/p>\n<p>As a note, lz4 is not backward compatible, so you will need to use a ZFS version that supports flags *and* lz4.<br \/>\nAt the time of writing nas4free doesn&#8217;t support it, zfsonlinux does though, as does omnios, illumos and other solaris based OS&#8217;s.<\/p>\n<p>If you aren&#8217;t sure, check first with the command above and see if there is support.<br \/>\nNext step is to turn on that feature.<\/p>\n<p>My storage pools are typically called nas or tank<br \/>\nTo enable lz4 compression, its a 2 step process.<\/p>\n<p><code>zpool set feature@lz4_compress=enabled  <storage volume><br \/>\nzpool set compression=lz4 <storage volume or poolname><\/p>\n<p>I have nas and nas\/storage so I did - <\/p>\n<p>zpool set feature@lz4_compress=enabled nas<br \/>\nzpool set compression=lz4 nas<br \/>\nzpool set compression=lz4 nas\/storage<br \/>\n<\/code><\/p>\n<p>Once the flag is set though, you can set compression on the pools or volume.  If you set at the storage volume level, then new pools inherit the compression setting.<\/p>\n<p>Here are my volumes \/ pools<\/p>\n<p><code>zfs list<br \/>\nNAME          USED  AVAIL  REFER  MOUNTPOINT<br \/>\nnas          6.09T  4.28T   209K  \/nas<br \/>\nnas\/storage  6.09T  4.28T  6.09T  \/nas\/storage<\/code><\/p>\n<p>I&#8217;ve already set compression on (although it doesn&#8217;t take effect till I copy new data onto the pools \/ volumes).<br \/>\nWe can check compression status by doing a zfs get all command, and filtering by compress<\/p>\n<p> <code>zfs get all | grep compress<br \/>\nnas          compressratio         1.00x                    -<br \/>\nnas          compression           lz4                      local<br \/>\nnas          refcompressratio      1.00x                    -<br \/>\nnas\/storage  compressratio         1.00x                    -<br \/>\nnas\/storage  compression           lz4                      local<br \/>\nnas\/storage  refcompressratio      1.00x                    -<br \/>\n<\/code><\/p>\n<p>If I create a new pool you&#8217;ll see it gets created with the same compression inherited from its parent storage volume.<\/p>\n<p><code>zfs create nas\/test<br \/>\nroot@nas:\/nas# zfs get all | grep compress<br \/>\nnas          compressratio         1.00x                    -<br \/>\nnas          compression           lz4                      local<br \/>\nnas          refcompressratio      1.00x                    -<br \/>\nnas\/storage  compressratio         1.00x                    -<br \/>\nnas\/storage  compression           lz4                      local<br \/>\nnas\/storage  refcompressratio      1.00x                    -<br \/>\nnas\/test     compressratio         1.00x                    -<br \/>\nnas\/test     compression           lz4                      inherited from nas<br \/>\nnas\/test     refcompressratio      1.00x                    -<\/code><\/p>\n<p>I&#8217;ll copy some dummy data onto there, then recheck.<\/p>\n<p><code>nas\/test     compressratio         1.71x                    -<br \/>\nnas\/test     compression           lz4                      inherited from nas<br \/>\nnas\/test     refcompressratio      1.71x                    -<\/code><\/p>\n<p>Nice!<\/p>\n<p>Obviously, compression ratio&#8217;s will depend highly on the data, but for our purposes, most things are web data, mail and other things, so we&#8217;re heavy on text content, and benefit highly from compression.<\/p>\n<p>Once we get our SAN up and running, I&#8217;ll be looking at whether I should be using rsync still or I should look at zfs snapshots -> zfs storage on other servers.<br \/>\nThat though, is a topic for another day.<\/p>\n<p><!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Behind the scenes we use ZFS as storage for our offsite backups. We have backups in 2 separate physical locations + original data on the server(s), as data is mui importante! ZFS is a rather nice storage file system that improves radically on older RAID based solutions, offering a lot more funky options, like snapshot&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,4],"tags":[208,482,481,441],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-technical-mumbo-jumbo","category-useful-info","tag-backups","tag-compression","tag-lz4","tag-zfs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":1,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1117\/revisions"}],"predecessor-version":[{"id":1118,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1117\/revisions\/1118"}],"wp:attachment":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/media?parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/categories?post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/tags?post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}