Description

The zfs create -o encryption command encrypts a newly created ZFS datasets within a ZFS
storage pool, as described in zpool(1M).

Encryption

Encryption is the process in which data is encoded for privacy and
a key is needed by the data owner to access the encoded
data. You can set an encryption policy when a ZFS dataset is
created, but the policy cannot be changed. See the encryption and keysource
property descriptions in the “Native Properties” section for details.

Dataset encryption is inherited permanently and cannot be removed during dataset cloning.
When receiving a replicated dataset stream, the destination dataset must have encryption
enabled if encryption is desired. Otherwise, the data is stored as clear
text. A fully replicated stream of an encrypted dataset results in an encrypted
dataset but under a newly generated key, but the steam itself is
not encrypted.

Native ZFS Encryption Properties

The following native properties related to ZFS encryption consist of read-only statistics
about the dataset. These properties cannot be set nor inherited. Native properties
apply to all dataset types unless otherwise noted. For a full description
and list of ZFS native properties, see zfs(1M).

keystatus

Identifies the encryption key status for the dataset. The availability of a dataset's key is indicated by showing the status of available or unavailable. For datasets that do not have encryption enabled, none is displayed.

mounted

For file systems, indicates whether the file system is currently mounted. This property can be either yes or no.

rekeydate

The date of the last data encryption key change from a zfs key-K or zfs clone-K operation on this dataset. If no rekey operation has been performed, rekeydate is the same as creation date.

The following properties cannot be changed after the file system is created
and, therefore, should be set when the file system is created. If
the properties are not set with the zfs create or zpool create commands, these
properties are inherited from the parent dataset. If the parent dataset lacks these
properties due to having been created prior to these features being supported,
the new file system will have the default values for these properties.

Defines the encryption algorithm and key length that is used for the encrypted dataset. The on value is equal to aes-128-ccm. The default value is off. When encryption is set to a value other than off, the checksum property is set to sha256+mac and becomes readonly.

The following properties must be specified at creation time and can modified
by using special commands:

keysource=raw | hex | passphrase,prompt | file://|pkcs11:|https://

Defines the format and location of the key that wraps the dataset keys. The key must be present when the dataset is created, mounted, or loaded by using the zfs key-l command.

The keysource property accepts two values: format determines how the key is presented; locator identifies where the key is coming from.

format accepts three values:

raw: the raw key bytes

hex: a hexadecimal key string

passphrase: a character string that generates a key

locator accepts two values:

prompt: You are prompted for a key when the dataset is created or mounted

file:///filename: the key file location in a file system

pkcs11: A URI describing the location of a key in a PKCS#11 token

https://location: The key file location on a secure server

See “Examples” for examples of creating a key by using the https:// locator.

To change the wrapping key value or the key, you must run the zfs key-c command. If only the key location needs to be changed, for example, a filename change, then use the zfs set command with the keysource property. Note that no checking is performed by ZFS when only the key location is changed with the zfs set command, such as whether the new location has a valid wrapping key.

If keysource is not specified and not inherited, then the default keysource is set to passphrase,prompt for a dataset that has encryption on and is set to none for a dataset that has encryption off.

SUBCOMMANDS

All subcommands that modify state are logged persistently to the pool in
their original form.

zfs ?

Displays a help message.

zfs helpcommand | help | propertyproperty-name | permission

Displays zfs command usage information. You can display help for a specific command, property, or delegated permission. If you display help for a specific command or property, the command syntax or property value is displayed. Using zfs help without any arguments displays a complete list of zfs commands.

Creates a new ZFS file system with encryption enabled, which uses aes-128-ccm See the encryption property description for a list of supported encryption algorithms.

-p

Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the mountpoint property inherited from their parent. Any property specified on the command line using the -o option is ignored. If the target filesystem already exists, the operation completes successfully.

-oencryption=value

Sets the encryption property to value. Multiple -o options can be specified. An error results if the same property is specified in multiple -o options.

zfs clone [-p] [-K] [-oproperty=value] ... snapshotfilesystem|volume

Creates a clone of the given snapshot. See the “Clones” section for details. The target dataset can be located anywhere in the ZFS hierarchy, and is created as the same type as the original.

-p

Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the mountpoint property inherited from their parent. If the target filesystem or volume already exists, the operation completes successfully.

-oproperty=value

Sets the specified property; see zfs create for details.

-K

Creates a new data encryption key in the keychain for this dataset. Data written in the clone uses the new data encryption key, which is distinct from its original snapshot.

zfs setkeysource=valuefilesystem|volume| ...

Sets the keysource property to the given value for each dataset. You can only change the keysource location. If you want to change the wrapping key value, use the zfs key-c command.

-r

Recursively apply the effective value of the setting throughout the subtree of child datasets. The effective value may be set or inherited, depending on the property.

Recursively display any children of the dataset, limiting the recursion to depth. A depth of 1 will display only the dataset and its direct children.

-H

Display output in a form more easily parsed by scripts. Any headers are omitted, and fields are explicitly separated by a single tab instead of an arbitrary amount of space.

zfskey-l | {-a | [-r] filesystem|volume}

Loads the encryption key for a dataset and any datasets that inherit the key. The key that is provided with this command is not the actual key that is used to encrypt the dataset. It is a wrapping key for the set of data encryption keys for the dataset.

-l

Loads the wrapping key to unlock the encrypted dataset and datasets that inherit the key. This command loads the key based on what is defined by the dataset's keysource property.

During a pool import, a key load operation is performed when a dataset is mounted. During boot, if the wrapping key is available and the keysource is not set to prompt, the key load operation is performed.

-a

Apply to all datasets in all pools on the system.

-r

Apply the operation recursively to all datasets below the named file system or volume.

zfskey-u [-f] | {-a | [-r] filesystem|volume}

Unloads the encryption key for a dataset and any datasets that inherit the key.

-u

Unmounts the dataset and then attempts to unload the wrapping key for an encrypted dataset and datasets that inherit the key. If successful, the dataset is not accessible and is unmounted.

-f

Attempts to force unmount the dataset before attempting to unload the key. If not specified, a normal unmount is attempted.

-a

Apply to all datasets in all pools on the system.

-r

Apply the operation recursively to all datasets below the named file system or volume.

zfskey-c [-okeysource=value] | {-a | [-r] filesystem|volume}

Changes the wrapping key. If the new key has a different format or locator, the keysource property must be included as part of the command. Only the keysource property can be changed as part of the zfs key-c command.

-c

Changes the wrapping key for the key of an encrypted dataset and the datasets that inherit it. The existing key must already have been loaded before the key change operation can occur. ZFS does not prompt you for the existing passphrase.

-oproperty=value

Property to be changed as part of the key change operation. The keysource property is the only option that can be changed as part of a key change operation.

You must have permission to change the keysource properties.

-a

Apply to all datasets in all pools on the system.

-r

Apply the operation recursively to all datasets below the named file system or volume.

zfskey-K {-a | [-r] filesystem|volume}

Creates a new data encryption key. The new data encryption key is wrapped by the same wrapping key as any existing data encryption keys for this dataset.

-K

Creates a new data encryption key for this dataset. Data written after this operation will use the new data encryption key.

-a

Apply to all datasets in all pools on the system.

-r

Apply the operation recursively to all datasets below the named file system or volume.

zfs mount

zfs mount [-vO] [-ooptions] -a | filesystem

Mounts ZFS file systems. Invoked automatically as part of the boot process. For a full description of zfs mount syntax, see zfs(1M).

filesystem

Mount the specified filesystem.

A zfs mount operation of an encrypted dataset might prompt you for a key, depending on the keysource property value. This might occur, for example, if the keysource locator is set to prompt.

zfs unmount [-f] -a | filesystem|mountpoint

Unmounts currently mounted ZFS file systems. Invoked automatically as part of the shutdown process. For a full description of zfs unmount syntax, see zfs(1M).

filesystem|mountpoint

Unmount the specified filesystem. The command can also be given a path to a ZFS file system mount point on the system.

For an encrypted dataset, the key is not unloaded when the file system is unmounted. To unload the key, see zfs key.

Examples

Example 1 Creating an Encrypted Dataset

The following example shows how to create an encrypted dataset by using
a passphrase prompt, which is the default value of the keysource property.
This example assumes that the tank/home dataset is not encrypted.

In the following example, the pktool(1) command is used to generate a
raw key to a file. Next, an encrypted dataset (tank/home/anne) is created with
the aes-256-ccm algorithm and the raw key file that was generated by
pktool.

You must have the delegated key and keychange permissions to change the
keysource property.

Example 5 Rekeying the Dataset's Encryption Key

This example shows how to change a dataset's encryption key, which is
neither visible nor managed by you or an administrator. The dataset's encryption
key is wrapped (encrypted) by the key specified in the keysource property.