Table of Contents
ZFS file systems can be created and destroyed by using the zfs create and zfs destroy commands.
ZFS file systems are created by using the zfs create command. The create subcommand takes a single argument: the name of the file system to create. The file system name is specified as a path name starting from the name of the pool:
The pool name and initial file system names in the path identify the location in the hierarchy where the new file system will be created. All the intermediate file system names must already exist in the pool. The last name in the path identifies the name of the file system to be created. The file system name must satisfy the naming conventions defined in.
zfs create tank/home/bonwick
ZFS automatically mounts the newly created file system if it is created
successfully. By default, file systems are mounted as
using the path provided for the file system name in the create subcommand.
In this example, the newly created
bonwick file system
/tank/home/bonwick. For more information about
automanaged mount points, see .
For more information about the zfs create command, see .
To destroy a ZFS file system, use the zfs destroy command. The destroyed file system is automatically unmounted and unshared. For more information about automanaged mounts or automanaged shares, see .
In the following example, the
tabriz file system
zfs destroy tank/home/tabriz
No confirmation prompt appears with the destroy subcommand. Use it with extreme caution.
If the file system to be destroyed is busy and so cannot be unmounted,
the zfs destroy command fails. To destroy an active file
system, use the
f option. Use this option with caution as
it can unmount, unshare, and destroy active file systems, causing unexpected
zfs destroy tank/home/ahrenscannot unmount 'tank/home/ahrens': Device busy #
zfs destroy -f tank/home/ahrens
The zfs destroy command also fails if a file system
has children. To recursively destroy a file system and all its descendants,
r option. Note that a recursive destroy also destroys
snapshots so use this option with caution.
zfs destroy tank/wscannot destroy 'tank/ws': filesystem has children use '-r' to destroy the following datasets: tank/ws/billm tank/ws/bonwick tank/ws/maybee #
zfs destroy -r tank/ws
If the file system to be destroyed has indirect dependents, even the
recursive destroy command described above fails. To force the destruction
of all dependents, including cloned file systems outside
the target hierarchy, the
R option must be used. Use extreme
caution with this option.
zfs destroy -r tank/home/schrockcannot destroy 'tank/home/schrock': filesystem has dependent clones use '-R' to destroy the following datasets: tank/clones/schrock-clone #
zfs destroy -R tank/home/schrock
No confirmation prompt appears with the
R options so use these options carefully.
For more information about snapshots and clones, see.
Change the name of a file system
Relocate the file system to a new location within the ZFS hierarchy
Change the name of a file system and relocate it with the ZFS hierarchy
The following example uses the rename subcommand to do a simple rename of a file system:
zfs rename tank/home/kustarz tank/home/kustarz_old
This example renames the
kustarz file system to
The following example shows how to use zfs rename to relocate a file system.
zfs rename tank/home/maybee tank/ws/maybee
In this example, the
maybee file system is relocated
you relocate a file system through rename, the new location must be within
the same pool and it must have enough space to hold this new file system.
If the new location does not have enough space, possibly because it has reached
its quota, the rename will fail.
For more information about quotas, see.
The rename operation attempts an unmount/remount sequence for the file system and any descendant file systems. The rename fails if the operation is unable to unmount an active file system. If this problem occurs, you will need to force unmount the file system.
For information about renaming snapshots, see.