ZFS: getting started

De Joaquina
Saltar a: navegación, buscar

Getting Started with ZFS

Everything you hate about managing file systems and volumes is gone: you don't have to format, newfs, mount, edit /etc/vfstab, fsck, growfs, metadb, metainit, etc.

Meet your new best friends: zpool(1M) and zfs(1M).

ZFS is easy, so let's get on with it! It's time to create your first pool:

   # zpool create tank c1t2d0

You now have a single-disk storage pool named tank, with a single file system mounted at /tank. There is nothing else to do.

If you want mirrored storage for mail and home directories, that's easy too:

Create the pool:

   # zpool create tank mirror c1t2d0 c2t2d0

Create the /var/mail file system:

   # zfs create tank/mail
   # zfs set mountpoint=/var/mail tank/mail

Create home directories, and mount them all in /export/home/<username>:

   # zfs create tank/home
   # zfs set mountpoint=/export/home tank/home
   # zfs create tank/home/ahrens
   # zfs create tank/home/billm
   # zfs create tank/home/bonwick
   # zfs create tank/home/eschrock


ZFS file systems are hierarchical: each one inherits properties from above. In this example, the mountpoint property is inherited as a pathname prefix. That is, tank/home/ahrens is automatically mounted at /export/home/ahrens because tank/home is mounted at /export/home. You don't have to specify the mountpoint for each individual user — you just tell ZFS the pattern.

This is how we actually set up home directory and mail service on zion.eng, which has been running ZFS for over a year and a half.

But wait, there's more!

ZFS provides built-in compression. To compress all home directories:

   # zfs set compression=on tank/home

To give ahrens a 10G quota:

   # zfs set quota=10g tank/home/ahrens

To give bonwick a 100G reservation (membership has its privileges):

   # zfs set reservation=100g tank/home/bonwick

To automatically NFS-export all home directories read/write:

   # zfs set sharenfs=rw tank/home

To scrub all disks and verify the integrity of all data in the pool:

   # zpool scrub tank

To replace a flaky disk:

   # zpool replace tank c2t2d0 c4t1d0

To add more space:

   # zpool add tank mirror c5t1d0 c6t1d0

To move your pool from SPARC machine 'sparky' to AMD machine 'amdy':

[on sparky]

   # zpool export tank

Physically move your disks from sparky to amdy.

[on amdy]

   # zpool import tank

Everything will just work — ZFS has 'adaptive endianness' to cope with different byte order on different platforms.

You get the idea: it's simple. Any common ZFS operation can be done with a single short command.