Zpool

From OpenZFS on OS X
Revision as of 21:00, 12 March 2014 by Ilovezfs (Talk | contribs)

Jump to: navigation, search

Creating a pool

In the past, it was customary to label (i.e., partition) the disks before using them with ZFS. This is no longer the case. Now the preferred method is to have ZFS label the disks for you.

The case-sensitivity default is sensitive, but some 3rd party apps on OS X don't work entirely right if you have a case-sensitive volume. Normalization default is none, though OS X likes NFD normalization, or you may have some issues with characters.

The default for ashift is 9, but you will most likely want to create pools with an ashift of 12, which is appropriate for 4096 (4k) disks (i.e., Advanced Format disks), even if your disks are still the older 512. If you are using SSDs in your pool now, or anticipate replacing any of your pool's disks with SSDs in the future, then an ashift of 13 is a better choice. It is important to get this right now because a vdev's ashift cannot be changed after the vdev is created.

Recommended pool creation command line

zpool create -f -o ashift=12 \
-O casesensitivity=insensitive \
-O normalization=formD \
$poolname mirror /dev/diskX /dev/diskY
  • Replace $poolname with the name of the pool you want, for example "tank".
  • If you want to use the entire disk for ZFS, replace /dev/diskX with the available disk. For example /dev/disk1
  • If you have already partitioned the disk, and wish to only use a slice, use /dev/disk1s2
  • -f instructs ZFS to label the disk for you.

Use "diskutil list" to make sure you pick the correct disk before attempting to create your pool.

You can also decide to disable access time, enable compression, and all those nice things. But that can be done at any time in ZFS. For example

zfs set compression=lz4 $poolname

or for pool version 28 compatibility

zfs set compression=on $poolname

Because turning compression on later will only apply to new data added to a dataset, not the preexisting uncompressed data, if you do want compression, you should turn it on as soon as possible, or enable it at the time the pool is created.

For example, you may want to use something like this

zpool create -f -o ashift=12 \
-O compression=lz4 \
-O casesensitivity=insensitive \
-O atime=off \
-O normalization=formD \
tank mirror /dev/disk3 /dev/disk4

If you absolutely must be compatible with non-OpenZFS implementations of ZFS (e.g., Oracle Solaris), you'd need to do

zpool create -f -o version=28 -o ashift=12 \
-O compression=on \
-O casesensitivity=insensitive \
-O atime=off \
-O normalization=formD \
tank mirror /dev/disk3 /dev/disk4

Unplugging a pool

Pool export is not yet automatic in Open ZFS on OS X. Before you unplug any devices should must export all pools used by the device.

zpool export $poolname

The export can sometimes fail if the mount is busy (as with all filesystems). So you might need to close any windows still accessing the ZFS volume. If you are just rebooting, you need not export first.