| ZFS(8) | System Manager's Manual | ZFS(8) |
zfs — configure
ZFS datasets
zfs |
-?V |
zfs |
version [-j] |
zfs |
subcommand
[arguments] |
The zfs command configures ZFS datasets
within a ZFS storage pool, as described in
zpool(8). A dataset is identified by a
unique path within the ZFS namespace:
for example:
rpool/var/logThe maximum length of a dataset name is ZFS_MAX_DATASET_NAME_LEN - 1 ASCII characters (currently 255) satisfying [A-Za-z_.:/ -]. Additionally snapshots are allowed to contain a single @ character, while bookmarks are allowed to contain a single # character. / is used as separator between components. The maximum amount of nesting allowed in a path is zfs_max_dataset_nesting levels deep. ZFS tunables (zfs_*) are explained in zfs(4).
A dataset can be one of the following:
See zfsconcepts(7) for details.
Properties are divided into two types: native properties and user-defined (or "user") properties. Native properties either export internal statistics or control ZFS behavior. In addition, native properties are either editable or read-only. User properties have no effect on ZFS behavior, but you can use them to annotate datasets in a way that is meaningful in your environment. For more information about properties, see zfsprops(7).
Enabling the encryption feature allows for the creation of encrypted filesystems and volumes. ZFS will encrypt file and zvol data, file attributes, ACLs, permission bits, directory listings, FUID mappings, and userused/groupused/projectused data. For an overview of encryption, see zfs-load-key(8).
All subcommands that modify state are logged persistently to the pool in their original form.
zfs -?zfs -V,
--versionzfs version
[-j]zfs userland
utility and the zfs kernel module. Use -j option
to output in JSON format.zfs destroy command
return
EBUSY.zfs
send command.-S option reverted to the received value if
one exists.The zfs utility exits 0
on success, 1 if
an error occurs, and
2 if invalid
command line options were specified.
The following commands create a file system named pool/home and a file system named pool/home/bob. The mount point /export/home is set for the parent file system, and is automatically inherited by the child file system.
# zfs
create pool/home# zfs
set
mountpoint=/export/home
pool/home# zfs
create
pool/home/bobThe following command creates a snapshot named yesterday. This snapshot is mounted on demand in the .zfs/snapshot directory at the root of the pool/home/bob file system.
# zfs
snapshot
pool/home/bob@yesterdayThe following command creates snapshots named yesterday of pool/home and all of its descendent file systems. Each snapshot is mounted on demand in the .zfs/snapshot directory at the root of its file system. The second command destroys the newly created snapshots.
# zfs
snapshot -r
pool/home@yesterday# zfs
destroy -r
pool/home@yesterdayThe following command disables the compression property for all file systems under pool/home. The next command explicitly enables compression for pool/home/anne.
# zfs
set
compression=off
pool/home# zfs
set compression=on
pool/home/anneThe following command lists all active file systems and volumes in the system. Snapshots are displayed if listsnaps=on. The default is off. See zpoolprops(7) for more information on pool properties.
#zfslistNAME USED AVAIL REFER MOUNTPOINT pool 450K 457G 18K /pool pool/home 315K 457G 21K /export/home pool/home/anne 18K 457G 18K /export/home/anne pool/home/bob 276K 457G 276K /export/home/bob
The following command sets a quota of 50 Gbytes for pool/home/bob:
# zfs
set quota=50G
pool/home/bobThe following command lists all properties for pool/home/bob:
#zfsgetall pool/home/bob NAME PROPERTY VALUE SOURCE pool/home/bob type filesystem - pool/home/bob creation Tue Jul 21 15:53 2009 - pool/home/bob used 21K - pool/home/bob available 20.0G - pool/home/bob referenced 21K - pool/home/bob compressratio 1.00x - pool/home/bob mounted yes - pool/home/bob quota 20G local pool/home/bob reservation none default pool/home/bob recordsize 128K default pool/home/bob mountpoint /pool/home/bob default pool/home/bob sharenfs off default pool/home/bob checksum on default pool/home/bob compression on local pool/home/bob atime on default pool/home/bob devices on default pool/home/bob exec on default pool/home/bob setuid on default pool/home/bob readonly off default pool/home/bob zoned off default pool/home/bob snapdir hidden default pool/home/bob acltype off default pool/home/bob aclmode discard default pool/home/bob aclinherit restricted default pool/home/bob canmount on default pool/home/bob xattr on default pool/home/bob copies 1 default pool/home/bob version 4 - pool/home/bob utf8only off - pool/home/bob normalization none - pool/home/bob casesensitivity sensitive - pool/home/bob vscan off default pool/home/bob nbmand off default pool/home/bob sharesmb off default pool/home/bob refquota none default pool/home/bob refreservation none default pool/home/bob primarycache all default pool/home/bob secondarycache all default pool/home/bob usedbysnapshots 0 - pool/home/bob usedbydataset 21K - pool/home/bob usedbychildren 0 - pool/home/bob usedbyrefreservation 0 -
The following command gets a single property value:
#zfsget-H-ovalue compression pool/home/bob on
The following command lists all properties with local settings for pool/home/bob:
The following command reverts the contents of pool/home/anne to the snapshot named yesterday, deleting all intermediate snapshots:
# zfs
rollback -r
pool/home/anne@yesterdayThe following command creates a writable file system whose initial contents are the same as pool/home/bob@yesterday.
# zfs
clone pool/home/bob@yesterday
pool/cloneThe following commands illustrate how to test out changes to a file system, and then replace the original file system with the changed one, using clones, clone promotion, and renaming:
#zfscreatepool/project/production populate /pool/project/production with data #zfssnapshotpool/project/production@today #zfsclonepool/project/production@today pool/project/beta make changes to /pool/project/beta and test them #zfspromotepool/project/beta #zfsrenamepool/project/production pool/project/legacy #zfsrenamepool/project/beta pool/project/production once the legacy version is no longer needed, it can be destroyed #zfsdestroypool/project/legacy
The following command causes pool/home/bob and pool/home/anne to inherit the checksum property from their parent.
# zfs
inherit checksum
pool/home/bob pool/home/anneThe following commands send a full stream and then an incremental stream to a remote machine, restoring them into poolB/received/fs@a and poolB/received/fs@b, respectively. poolB must contain the file system poolB/received, and must not initially contain poolB/received/fs.
#zfssendpool/fs@a |sshhostzfsreceivepoolB/received/fs@a #zfssend-ia pool/fs@b |sshhostzfsreceivepoolB/received/fs
zfs
receive -d
OptionThe following command sends a full stream of poolA/fsA/fsB@snap to a remote machine, receiving it into poolB/received/fsA/fsB@snap. The fsA/fsB@snap portion of the received snapshot's name is determined from the name of the sent snapshot. poolB must contain the file system poolB/received. If poolB/received/fsA does not exist, it is created as an empty file system.
#zfssendpoolA/fsA/fsB@snap |sshhostzfsreceive-dpoolB/received
The following example sets the user-defined com.example:department property for a dataset:
# zfs
set
com.example:department=12345
tank/accountingThe following example shows how to maintain a history of snapshots with a consistent naming scheme. To keep a week's worth of snapshots, the user destroys the oldest snapshot, renames the remaining snapshots, and then creates a new snapshot, as follows:
#zfsdestroy-rpool/users@7daysago #zfsrename-rpool/users@6daysago @7daysago #zfsrename-rpool/users@5daysago @6daysago #zfsrename-rpool/users@4daysago @5daysago #zfsrename-rpool/users@3daysago @4daysago #zfsrename-rpool/users@2daysago @3daysago #zfsrename-rpool/users@yesterday @2daysago #zfsrename-rpool/users@today @yesterday #zfssnapshot-rpool/users@today
The following commands show how to set sharenfs property options to enable read-write access for a set of IP addresses and to enable root access for system "neo" on the tank/home file system:
# zfs
set
sharenfs='rw=@123.123.0.0/16:[::1],root=neo'
tank/homeIf you are using DNS for host name resolution, specify the fully-qualified hostname.
The following example shows how to set permissions so that user cindys can create, destroy, mount, and take snapshots on tank/cindys. The permissions on tank/cindys are also displayed.
#zfsallowcindys create,destroy,mount,snapshot tank/cindys #zfsallowtank/cindys ---- Permissions on tank/cindys -------------------------------------- Local+Descendent permissions: user cindys create,destroy,mount,snapshot
Because the tank/cindys mount point permission is set to 755 by default, user cindys will be unable to mount file systems under tank/cindys. Add an ACE similar to the following syntax to provide mount point access:
# chmod
A+user:cindys:add_subdirectory:allow
/tank/cindysThe following example shows how to grant anyone in the group staff to create file systems in tank/users. This syntax also allows staff members to destroy their own file systems, but not destroy anyone else's file system. The permissions on tank/users are also displayed.
#zfsallowstaff create,mount tank/users #zfsallow-cdestroy tank/users #zfsallowtank/users ---- Permissions on tank/users --------------------------------------- Permission sets: destroy Local+Descendent permissions: group staff create,mount
The following example shows how to define and grant a permission set on the tank/users file system. The permissions on tank/users are also displayed.
#zfsallow-s@pset create,destroy,snapshot,mount tank/users #zfsallow staff@pset tank/users #zfsallowtank/users ---- Permissions on tank/users --------------------------------------- Permission sets: @pset create,destroy,mount,snapshot Local+Descendent permissions: group staff @pset
The following example shows to grant the ability to set quotas and reservations on the users/home file system. The permissions on users/home are also displayed.
#zfsallowcindys quota,reservation users/home #zfsallowusers/home ---- Permissions on users/home --------------------------------------- Local+Descendent permissions: user cindys quota,reservation cindys% zfs set quota=10G users/home/marks cindys% zfs get quota users/home/marks NAME PROPERTY VALUE SOURCE users/home/marks quota 10G local
The following example shows how to remove the snapshot permission from the staff group on the tank/users file system. The permissions on tank/users are also displayed.
#zfsunallowstaff snapshot tank/users #zfsallowtank/users ---- Permissions on tank/users --------------------------------------- Permission sets: @pset create,destroy,mount,snapshot Local+Descendent permissions: group staff @pset
The following example shows how to see what has changed between a
prior snapshot of a ZFS dataset and its current state. The
-F option is used to indicate type information for
the files affected.
#zfsdiff-Ftank/test@before tank/test M / /tank/test/ M F /tank/test/linked (+1) R F /tank/test/oldname -> /tank/test/newname - F /tank/test/deleted + F /tank/test/created M F /tank/test/modified
The following example creates a bookmark to a snapshot. This bookmark can then be used instead of a snapshot in send streams.
# zfs
bookmark
rpool@snapshot
rpool#bookmarkThe following example show how to share SMB filesystem through ZFS. Note that a user and their password must be given.
# smbmount
//127.0.0.1/share_tmp /mnt/tmp
-o
user=workgroup/turbo,password=obrut,uid=1000Minimal /etc/samba/smb.conf configuration is required, as follows.
Samba will need to bind to the loopback interface for the ZFS utilities to communicate with Samba. This is the default behavior for most Linux distributions.
Samba must be able to authenticate a user. This can be done in a number of ways (passwd(5), LDAP, smbpasswd(5), &c.). How to do this is outside the scope of this document – refer to smb.conf(5) for more information.
See the USERSHARES section for all configuration options, in case you need to modify any options of the share afterwards. Do note that any changes done with the net(8) command will be undone if the share is ever unshared (like via a reboot).
zfs diff
and zfs list output.zfs mount to use
mount(8) to mount ZFS datasets. This
option is provided for backwards compatibility with older ZFS
versions.zfs to set the maximum pipe size for
sends/receives. Disabled by default on Linux due to an unfixed deadlock in
Linux's pipe size handling code.attr(1), gzip(1), ssh(1), chmod(2), fsync(2), stat(2), write(2), acl(5), attributes(5), exports(5), zfsconcepts(7), zfsprops(7), exportfs(8), mount(8), net(8), selinux(8), zfs-allow(8), zfs-bookmark(8), zfs-change-key(8), zfs-clone(8), zfs-create(8), zfs-destroy(8), zfs-diff(8), zfs-get(8), zfs-groupspace(8), zfs-hold(8), zfs-inherit(8), zfs-jail(8), zfs-list(8), zfs-load-key(8), zfs-mount(8), zfs-program(8), zfs-project(8), zfs-projectspace(8), zfs-promote(8), zfs-receive(8), zfs-redact(8), zfs-release(8), zfs-rename(8), zfs-rollback(8), zfs-send(8), zfs-set(8), zfs-share(8), zfs-snapshot(8), zfs-unallow(8), zfs-unjail(8), zfs-unload-key(8), zfs-unmount(8), zfs-unshare(8), zfs-upgrade(8), zfs-userspace(8), zfs-wait(8), zpool(8)
| April 18, 2025 | OpenZFS |