Tuesday, December 18, 2012

Using ZFS under CentOS

Using ZFS

In my last post I showed how to get ZFS installed on CentOS 6.3. This post will serve as a quick start guide.

Creating a ZFS file system

The first thing you will want to do is to create a zfs file system. The syntax is simple and straight forward.
zpool create store mirror /dev/sda /dev/sdb
The above command creates a mirrored ZFS file system and mounts it at /store. That is the simplest use case you have a mirrored device that provides some hardware failure resilience.

Getting more complex

Creating a simple mirror is fine and good but lets show a little more complex example.
zpool create store raidz /dev/sdc /dev/sdd /dev/sde spare /dev/sdf
The above command create a RAID5 like ZFS file system and mounts it at /store. It also includes a hot spare drive. Other options other than raidz include raidz2 and raidz3 giving you even more redundancy.

You may want to create other ZFS file systems under your /store to give additional control  (for example setting quota's).
zfs create store/user1
zfs set quota=10G store/user1
Some of the other cool things you can do is turn on NFS sharing, enable compression or enable deduplication. To learn more about the more advanced stuff you can do with ZFS I recommend reading the ZFS Administrators Guide.