How to Set Up ZFS on a System
Example 3-1 Configuring a Mirrored ZFS File System
In the following example, a basic ZFS configuration is created on the system with the following specifications:
-
Two disks are allocated to the ZFS file system:
c1t0d0andc2t0d0. -
The pool
system1uses mirroring. -
The file system
homeis created over the pool. -
The following properties are set for
home:mountpoint,share.nfs, andcompression. -
Two children file systems,
user1anduser2are created onhome. -
A quota is set for
user2. This property restricts the disk space available foruser2regardless of the available disk space of the entire pool.
The command zfs get used example displays file system properties.
$ zpool create system1 mirror c1t0d0 c2t0d0 $ zpool list NAME SIZE ALLOC FREE CAP HEALTH ALTROOT system1 80G 137K 80G 0% ONLINE - $ zpool status system1 pool: system1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM system1 ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c1t0d0 ONLINE 0 0 0 c2t0d0 ONLINE 0 0 0 errors: No known data errors $ zfs create system1/home $ zfs set mountpoint=/export/zfs system1/home $ zfs set share.nfs=on system1/home $ zfs set compression=on system1/home $ zfs get compression system1/home NAME PROPERTY VALUE SOURCE system1/home compression on local $ zfs create system1/home/user1 $ zfs create system1/home/user2 $ zfs set quota=10G system1/home/user2 $ zfs list NAME USED AVAIL REFER MOUNTPOINT system1 92.0K 67.0G 9.5K /system1 system1/home 24.0K 67.0G 8K /export/zfs system1/home/user1 8K 67.0G 8K /export/zfs/user1 system1/home/user2 8K 10.0G 8K /export/zfs/user2
Example 3-2 Configuring a RAID-Z ZFS File System
This example creates a RAID-Z file system and shows how you can specify disks by using either their shorthand device names or their full device names: the disk c6t0d0 is the same as /dev/dsk/c6t0d0.
-
Three disks are allocated to the ZFS file system:
c4t0d0,c5t0d0, andc6t0d0. -
The pool
rdpooluses a RAID-Z single-parity configuration. -
The file system
baseis created over the pool.
$ zpool create rdpool raidz c4t0d0 c5t0d0 /dev/dsk/c6t0d0 $ zpool list NAME SIZE ALLOC FREE CAP HEALTH ALTROOT rdpool 120G 205K 120G 0% ONLINE - $ zpool status -v rdpool pool: rdpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM rdpool ONLINE 0 0 0 raidz-0 ONLINE 0 0 0 c4t0d0 ONLINE 0 0 0 c5t0d0 ONLINE 0 0 0 c6t0d0 ONLINE 0 0 0 errors: No known data errors $ zfs create rdpool/base $ zfs set mountpoint=/export/zfs rdpool/base $ zfs set share.nfs=on rdpool/base $ zfs set compression=on rdpool/base $ zfs get compression rdpool/home NAME PROPERTY VALUE SOURCE rdpool/base compression on local $ zfs create rdpool/base/user1 $ zfs create rdpool/base/user2 $ zfs set quota=10G rdpool/base/user2 $ zfs list NAME USED AVAIL REFER MOUNTPOINT rdpool 92.0K 67.0G 9.5K /rdpool rdpool/base 24.0K 67.0G 8K /export/zfs rdpool/base/user1 8K 67.0G 8K /export/zfs/user1 rdpool/base/user2 8K 10.0G 8K /export/zfs/user2