Projects
Search     View Tickets     Browse Source     Timeline     Wiki     New Ticket

Getting Started

The underlying storage used by ZFS filesystems involves pools. A pool may consist of one or more whole disks or disk partitions. Basically, these whole disks and/or disk partitions can be combined in several different ways: dynamic striping, mirroring, or RAIDZ.
In all cases, the disks need to use the GUID Partition Table (GPT) and ZFS typically works best when it owns the entire disk due in part to how conservative it is with the write cache.

Create a Simple 1 Disk Pool

In the most simple example, let’s start by using a single drive for our “puddle” storage pool. In the following example the commands are issued as root.
First, find out which device node to use with a "diskutil list" command. In the example below, I'm going to work with /dev/disk2 which currently has an APM (Apple Partition Map) label and an exsiting HFS filesystem. I'm going to replace the APM label with a GPT one and blow away the HFS "FW" filesystem. You should unmount any mounted filesystems on the target drive at this point.

# diskutil list 
. 
. 
. 
/dev/disk2 
   #:                   type name                size     identifier 
   0: Apple_partition_scheme                    *9.4 GB   disk2 
   1:    Apple_partition_map                     31.5 KB  disk2s1 
   2:              Apple_HFS FW                  9.2 GB   disk2s3 

Now I'm going to place a GPT label on that disk: **Note this step is very important! You must format the disk before you create a ZFS pool on it

# diskutil partitiondisk /dev/disk2 GPTFormat ZFS %noformat% 100% 
Started partitioning on disk disk2 
Creating partition map 
[ + 0%..10%..20%..30%..40%..50%..60%..70%..80%..90%..100% ]  
Finished partitioning on disk disk2 
/dev/disk2 
   #:                   type name                size     identifier 
   0:  GUID_partition_scheme                    *9.4 GB   disk2 
   1:                    EFI                     200.0 MB disk2s1 
   2:                    ZFS                     9.0 GB   disk2s2 

And create our simple ZFS pool (named "puddle"):

# zpool create puddle /dev/disk2s2 

And then check my work, noting that my new ZFS filesystem is available at /Volumes/puddle:

# zpool status puddle 
  pool: puddle 
 state: ONLINE 
 scrub: none requested 
config: 
 
        NAME        STATE     READ WRITE CKSUM 
        puddle      ONLINE       0     0     0 
          disk2s2   ONLINE       0     0     0 
 
errors: No known data errors 
 
# df -hl /Volumes/puddle 
Filesystem   Size   Used Available Capacity  Mounted on 
puddle     8.9Gi  19Ki 8.9Gi     1%    /Volumes/puddle 

Creating a Mirror or RAIDZ

To create a mirror or a RAIDZ, take a look at the following example where "tank" (a mirrored pair) and "dozer" (a RAIDZ set) are the names of our pools.

# zpool create tank mirror disk2s2 disk3s2 
# zpool status tank 
  pool: tank 
 state: ONLINE 
 scrub: none requested 
config: 
 
        NAME                STATE     READ WRITE CKSUM 
        tank                ONLINE       0     0     0 
          mirror            ONLINE       0     0     0 
            disk2s2         ONLINE       0     0     0 
            disk3s2         ONLINE       0     0     0 
 
errors: No known data errors 
 
 
# zpool create dozer raidz disk4s2 disk5s2 disk6s2 
# zpool status dozer 
  pool: dozer 
 state: ONLINE 
 scrub: none requested 
config: 
 
        NAME                STATE     READ WRITE CKSUM 
        dozer               ONLINE       0     0     0 
          raidz1            ONLINE       0     0     0 
            disk4s2         ONLINE       0     0     0 
            disk5s2         ONLINE       0     0     0 
            disk6s2         ONLINE       0     0     0 
 
errors: No known data errors 

Add Storage to a Pool

To add more storage to an existing pool, like “tank” from the example above, take a look at the following example.

# zpool add tank mirror disk7s2 disk8s2 
# zpool status tank 
  pool: tank 
 state: ONLINE 
 scrub: none requested 
config: 
 
        NAME                STATE     READ WRITE CKSUM 
        tank                ONLINE       0     0     0 
          mirror            ONLINE       0     0     0 
            disk2s2         ONLINE       0     0     0 
            disk3s2         ONLINE       0     0     0 
          mirror            ONLINE       0     0     0 
            disk7s2         ONLINE       0     0     0 
            disk8s2         ONLINE       0     0     0 
 
errors: No known data errors 

Using an Existing Partition

If you have existing partitions you want to use, so long as the partition map on that drive is GPT and you've unmounted them and understand that pre-existing data on those partitions will be lost, you can use the "diskutil" command to change the label type in place. In the example below, I want to use the pre-existing HFS "blank" and Untitled 2" partitions for my "oddcouple" ZFS mirrored pool. Again, please note that with this example, any previous data on the HFS “blank” and “Untitled 2” partitions will (obviously) be overwritten! Note the Apple_HFS partition type for the “blank” and “Untitled 2” partitions:

# diskutil list 
/dev/disk0 
   #:                   type name                size     identifier 
   0:  GUID_partition_scheme                    *149.1 GB disk0 
   1:                    EFI                     200.0 MB disk0s1 
   2:              Apple_HFS Leopard             29.7 GB  disk0s2 
   3:              Apple_HFS Leopard9A376        29.7 GB  disk0s3 
   4:                    ZFS zfstest             29.7 GB  disk0s4 
   5:              Apple_HFS blank               29.7 GB  disk0s5 
   6:              Apple_HFS HFSJ_Boot           29.5 GB  disk0s6 
/dev/disk1 
   #:                   type name                size     identifier 
   0:  GUID_partition_scheme                    *153.4 GB disk1 
   1:                    EFI                     200.0 MB disk1s1 
   2:              Apple_HFS Untitled 1          30.7 GB  disk1s2 
   3:              Apple_HFS Untitled 2          30.7 GB  disk1s3 
   4:              Apple_HFS Leopard9A376        30.7 GB  disk1s4 
   5:              Apple_HFS LaCieLeopard        30.7 GB  disk1s5 
   6:              Apple_HFS Leopard9A377a       29.9 GB  disk1s6 

Change the partition type to ZFS and check your work:

# diskutil eraseVolume ZFS %noformat% /dev/disk0s5 
[ + 0%..10%..20%..30%..40%..50%..60%..70%..80%..90%..100% ]  
Finished erase on disk disk0s5 
 
# diskutil eraseVolume ZFS %noformat% /dev/disk1s3 
[ + 0%..10%..20%..30%..40%..50%..60%..70%..80%..90%..100% ]  
Finished erase on disk disk1s3 
 
# diskutil list 
/dev/disk0 
   #:                   type name                size     identifier 
   0:  GUID_partition_scheme                    *149.1 GB disk0 
   1:                    EFI                     200.0 MB disk0s1 
   2:              Apple_HFS Leopard             29.7 GB  disk0s2 
   3:              Apple_HFS Leopard9A376        29.7 GB  disk0s3 
   4:                    ZFS zfstest             29.7 GB  disk0s4 
   5:                    ZFS                     29.7 GB  disk0s5 
   6:              Apple_HFS HFSJ_Boot           29.5 GB  disk0s6 
/dev/disk1 
   #:                   type name                size     identifier 
   0:  GUID_partition_scheme                    *153.4 GB disk1 
   1:                    EFI                     200.0 MB disk1s1 
   2:              Apple_HFS Untitled 1          30.7 GB  disk1s2 
   3:                    ZFS                     30.7 GB  disk1s3 
   4:              Apple_HFS Leopard9A376        30.7 GB  disk1s4 
   5:              Apple_HFS LaCieLeopard        30.7 GB  disk1s5 
   6:              Apple_HFS Leopard9A377a       29.9 GB  disk1s6 

Now create the "oddcouple" pool and check your work:

# zpool create oddcouple mirror disk0s5 disk1s3 
 
# zpool status oddcouple 
  pool: oddcouple 
 state: ONLINE 
 scrub: none requested 
config: 
 
        NAME         STATE     READ WRITE CKSUM 
        oddcouple    ONLINE       0     0     0 
          mirror     ONLINE       0     0     0 
            disk0s5  ONLINE       0     0     0 
            disk1s3  ONLINE       0     0     0 
 
errors: No known data errors