Actions: | Security

AllGoodBits.org

Navigation: Home | Services | Tools | Articles | Other

Introduction to ZFS

ZFS is a filesystem/logical volume manager that has generated a lot of interest, for several reasons:

Suffice to say that it's a compelling option to consider for many different types of storage needs, although obviously it's not a panacea.

One or more ZFS filesystems exist in a ZFS virtual storage pool, which consists of one of more virtual devices, which are themselves files, hard drive partitions, or preferably, entire drives.

This is quite a mouthful, but it means that we add one or more disks to a pool and then create filesystems inside that pool. I'm interested in a mirrored pool, because that gives me some redundancy, I become tolerant to the failure of one of my disks. Later we'll talk about monitoring, because there's no point being able to tolerate one failure if you don't then fix it before the next failure (which we can't tolerate) happens.

Create a mirrored pool from (virtual) devices

The command zpool manages zfs pools. We need to give it one or more devices, which ideally should be raw disks, but can be disk partitions or even ordinary files.

zpool create <poolname> mirror <device1> [<deviceN>]

On FreeBSD 8, creating a pool named 'local' from two SATA disks looks like this:

zpool create local mirror /dev/ad4 /dev/ad6

zpool list
  NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
  local   696G    75K   696G     0%  ONLINE  -

zpool status
  pool: local
  state: ONLINE
  scrub: none requested
  config:

       NAME        STATE     READ WRITE CKSUM
       local     ONLINE       0     0     0
         mirror    ONLINE       0     0     0
           ad4     ONLINE       0     0     0
           ad6     ONLINE       0     0     0

  errors: No known data errors

A zfs filesystem is created and mounted for us, according to the name of the pool:

zpool list
 NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
 local   696G    75K   696G     0%  ONLINE  -

Starting ZFS on boot looks like:

echo 'zfs_enable="YES"' >> /etc/rc.conf

But actually I want to use two filesystems in this pool:

zfs create local/library
zfs create local/backups

Quotas and Reservations

When you create filesystems in a pool, be sure to use quotas, because otherwise filling one filesystem, will mean that all filesystems are full, obviating one important reason to use separate filesystems in the first place.

zfs set quota=250G local/library
zfs set reservation=250G local/backups