Displaying and Accessing ZFS Clones
By setting a clone's mountpoint property to
clonedir, you can access the clone in the
mountpoint
/.zfs/clone directory that is located in the
dataset of which this is a clone. This dataset is called the head dataset.
When you set a clone's mountpoint property to clonedir, ZFS uses the final part of its dataset name as the clone subdirectory to add to .zfs/clone. Thus, ensure that each clone for which you intend to use clonedir has a unique name after the final slash for a given head dataset.
In this example, the head dataset is tank/ds/subds. Create a clone of the tank/ds/subds@march snapshot called tank/march and mount it on /tank/ds/subds. When you set its mountpoint property to clonedir, you can access the clone from the /tank/ds/subds/.zfs/clone/march directory.
To determine whether a file system is a clone, use the zfs command to verify that the value of the origin property is non-NULL.
To share a clone that has mountpoint=clonedir set, ensure that it is shared from the top-level directory that houses the .zfs/clone directory. For example, a file system mounted on /a only permits access to its clonedir clones if /a is shared and not a subdirectory of /a, so the clonedir clones are available in /a/.zfs/clone.
When you set a clone's mountpoint property to clonedir, ZFS does the following:
-
Disables any existing shares of that clone.
-
Adds the clone directory to its head dataset's
.zfs/clonedirectory, such astank/ds/subds/.zfs/clone/march.
You can mount clones in .zfs/clone in the following ways:
-
The
tank/ds/subds/marchclone is mounted at thetank/ds/subdsmount point, which istank/ds/subds/.zfs/clone/march.Create a clone that sets its
mountpointproperty toclonedir.# zfs clone -o mountpoint=clonedir snapshot-name clone-name
The following command creates a clone of the
tank/ds/subds@snapsnapshot calledtank/ds/subds/march:# zfs clone -o mountpoint=clonedir tank/ds/subds@march tank/ds/subds/marchAssuming that the mount point of
tank/ds/subdsis/tank/ds/subds, thetank/ds/subds/marchclone is mounted on demand at/tank/ds/subds/.zfs/clone/march.
-
Set an existing clone's
mountpointproperty toclonedir.# zfs set -o mountpoint=clonedir clone-nameThe following command sets the
mountpointproperty toclonedirfor the existingtank/ds/subds/marchclone:# zfs set -o mountpoint=clonedir tank/ds/subds/march -
Use the
mkdircommand to create a directory for the clone in.zfs/clonedirectory.Note that you can use the
mkdirandrmdircommands to create and destroy snapshots and clones, respectively.The
mkdircommand creates a snapshot of the head dataset and then clones it.# mkdir .zfs/clone/clone-nameFor example, with
tank/ds/subdsas the head dataset, the following command does the following:- Creates a snapshot called
tank/ds/subds@marchif it does not exist - Clones the snapshot as a dataset called
tank/ds/subds/march
The resulting mount path is
/tank/ds/subds/.zfs/clone/marchwhen the mount point oftank/ds/subdsis the default/tank/ds/subds. Note that you can specify any mount point for the mount path.# mkdir .zfs/clone/marchAs with the
zfs destroycommand, thermdircommand does not destroy the origin snapshot. - Creates a snapshot called