Wednesday, February 23, 2011

Adventures in native ZFS on Linux

I started using ZFS on my Linux box around 1 year ago, after I've taken part on a Sun training where BalaBit (my workplace) sent me. ZFS astonished me. It combined the whole RAID, LVM and file system thing together and made it more pleasant with constant data integration check, and powerful caching. I felt in love.

But wait, stop, what the hack is ZFS? It is a file system and a build in logical volume manager by Sun Microsystems. With many interesting features like: data integrity, support for high storage capacities, snapshots and copy-on-write clones, continuous integrity checking and automatic repair, RAID-Z, deduplication, compression, multi level caching (with SSD if you like) and encryption.

That time Linux and ZFS wasn't a good company because of licensing issues (it still exists), but ZFS was available through FUSE (Filesystem In User Space). So I repartitioned my drive at home and started using it. That time only for some not so critical data of mine. I did some benchmarking on it too. It's speed wasn't something big because of FUSE but it was OK for me.

Time went by and a company namely Knowledge Quest Infotech started to write a port os ZFS based on Lawrence Livermore National Laboratory's work can be found at http://zfsonlinux.org/. And after several months it became ready for use (in january 2011). The licensing issues are still here so it is only available as module and maybe never will go to the native kernel. Building the modules or download from KQ Stor's (the brand what Knowledge Quest Infotech made for ZFS) is acceptable for me. (Oh sometimes I hate living on the edge... but this is the way I do in informatics.:))

I had several initial issues about the new native ZFS, for example that importing the old pool, what I made with ZFS-FUSE made all my files access mode to 000, but upgrading the file system version resolved this.

The most annoying issue I've found was the memory consumption of ZFS, first I suspected it as a memory leak, but it turned out to be a feature, but not on my desktop. ZFS itself takes very large amount of memory for ARC caching and if it needs by applications it releases them, the problem was that my PC was overloaded, Firefox, Thunderbird, several JAVA apps, etc... so my 3G RAM was almost full, but when ZFS started to allocate many memory and my desktop would need it my computer started to swap despite ZFS started to free memory (it was slower than kswapd). So many times this rendered my PC unusable for minutes. But after discussing it on the lists I learned how to limit ZFS's memory allocation so now everything is perfect. Don't blame ZFS, it's memory allocation is perfect for servers with more than 4G memory but racing with my desktop programs it wasn't a success story. But now it's good and I am happy with it. I've just bought another two 1T winchester to boost my storage space and with ZFS it was faster than I wrote this sentence!

It is still a new comer in Linux but actively developed so these first glitches will be surely resolved in the near future and it will become the most powerful file system in Linux.

It this post awakened your interesting please give it a try.:)

2 comments:

nm-work said...

How do you limit your memory usage?

Can you point to mailing list discussion?

THanks :)

Stone said...

Hi,

Add to /etc/modprobe.d/zfs.conf

options zfs zfs_arc_max=536870912

Or any other size is fits your system.

Stone