Sunday, July 01, 2012

ZFS on Linux

Quick notes on ZFS on Linux

  • due to license issues, it's not in the kernel, but available as fuse module
  • package is named zfs-fuse in Ubuntu
  • it supports compression and deduplication
  • the open source version does not support encryption, only the newer closed source one does
  • deduplication comes with a heavy performance penality, write speed goes down by a factor of 5 or more, so it's not good for active storage, but still great for backup devices
  • everything is checksummed, so hardware failures will not go unnoticed
  • shrinking a pool is not supported
  • compression and deduplication can be enabled or disabled on a running file system, thus gaining the space saving on a initial copy without the later running cost
  • no more /etc/fstab, zfs has a background daemon that handles mounting
  • manual/legacy mounting does not seem to be supported with zfs-fuse
  • no support for full copy-on-write clones, as clones always carry a dependency to their parent
  • fast snapshots are supported
  • no fsck, but zfs scrub
  • a pool automatically resizes to the underlying block device, restart the zfs-fuse daemon to force it
  • zfs destroy is really slow, taking minutes or hours, not seconds

Quick guide on using ZFS on Linux

Creating a zpool:

sudo zpool create poolname /dev/sdaX

A pool is a collection of physical devices, similar to a volume group in LVM. Pools can be mirrored or RAID'ed, but also just be single partitions.

Creating a ZFS:

sudo zfs create poolname/filesystemname

Unlike LVM where each logical volume is separate, all ZFS file systems in a pool share the same free space, thus no more running out of diskspace before the disk is truly full. Quotas can be used to restrict filesystems to a specific size.

Enabling compression and deduplication:

sudo zfs set dedup=on filesystemname
sudo zfs set compress=on filesystemname

Compression and deduplication can be enabled at any point.

Getting info on the ZFS on the system:

sudo zpool list
sudo zpool status
sudo zfs list
sudo zfs get all

Manually mounting a ZFS:

sudo zfs set canmount=noauto filesystem
sudo zfs set mountpoint=mountpoint filesystem
sudo zfs mount filesystem

Mounting is completely done by the zfs-fuse daemon, not by /etc/fstab, this can be a little confusing at first, but turns out is much easier to use then constantly making sure fstab is up to date. By default ZFS will mount all created file systems to /poolname/filesytem, this can be adjusted via the mountpoint property. Each file system can have it's own mountpoint and doesn't need to be a child of the pool file system. The root file system of the pool should probably be set to mountpoint=none in most cases.

First Impressions after a week

  • checksumming does detect broken hardware as advertised, something that other FS don't do
  • dedup and compression can save a lot of diskspace on space (~50% here)
  • dedup is extremely slow (one fifth the speed or worse)
  • tools are easy to use and well documented
  • mounting is confusing, but works very well once understood 
  • zfs-fuse is very unstable, I had numerous crashes so far (doing copy with dedup of a few gigs of data), filesystems however seem to have survived all of those


RKBA said...
This comment has been removed by the author.
RKBA said...

Everything I've read says you should ignore zfs-fuse and go with ZFS On Linux (from instead. Much more stable, more features, and much faster since it's a kernel module instead of a FUSE (userspace) add-in. I've been running it for about 3 months and love it.

Corwin said...

This post was obsolete when it was written. ZFS is native, please don't run the fuse version.

Unknown said...
This comment has been removed by a blog administrator.