Go to main content

手册页部分 8:系统管理命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

zfs(8)

名称

zfs - 配置 ZFS 文件系统

用法概要

zfs [-?]
zfs help subcommand | help | property property-name | permission
zfs help -l properties
zfs allow filesystem|volume
zfs allow [-ldug] everyone|user|group[,...] perm|@setname[,...]
     filesystem|volume
zfs allow [-ld] -e perm|@setname[,...] filesystem|volume
zfs allow -c perm|@setname[,...] filesystem|volume
zfs allow -s @setname perm|@setname[,...] filesystem|volume
zfs clone [-p] [-K] [-o property=value] ... snapshot filesystem|volume
zfs create [-p] [-o property=value] ... filesystem
zfs create [-ps] [-b blocksize] [-o property=value] ... -V size volume
zfs destroy [-rRsf] filesystem|volume
zfs destroy [-rRsd] snapshot
zfs destroy share
zfs diff [-FHNqrte] [-o field] ... snapshot [snapshot|filesystem]
zfs diff -E [-FHqrt] [-o field] ... snapshot|filesystem
zfs get [-rHpe|-d max] [-o all | field[,...]] [-s source[,...]]
     [-I state,...] all | property[,...]
     filesystem|volume|snapshot|share ...
zfs get share [filesystem]
zfs groupspace [-hniHp] [-o field[,...]] [-sS field] ...
     [-t type [,...]] filesystem|snapshot
zfs hold [-r] tag snapshot...
zfs holds [-r] snapshot...
zfs key -l {-a | [-r] filesystem|volume}
zfs key -u [-f] {-a | [-r] filesystem|volume}
zfs key -c [-o keysource=value] {-a | [-r] filesystem|volume}
zfs key -K {-a | [-r] filesystem|volume}
zfs list [-rH|-d max][-o property[,...]] [-t type[,...]] [-I state,..]
     [-s property] ... [-S property] ...
     [filesystem|volume|snapshot|share|path] ...
zfs inherit [-rS] property filesystem|volume|snapshot|share ...
zfs mount 
zfs mount [-vO] [-o options] -a | filesystem
zfs promote clone-filesystem
zfs receive [-vnFu] [[-o property=value] | [-x property]] ...
     filesystem|volume|snapshot
zfs receive [-vnFu] [[-o property=value] | [-x property]] ...
     [-d | -e] filesystem
zfs receive -C filesystem|volume
zfs release [-r] tag snapshot...
zfs rename filesystem|volume|snapshot
     filesystem|volume|snapshot
zfs rename [-p] filesystem|volume filesystem|volume
zfs rename -r snapshot snapshot
zfs rename share share
zfs retained [-PMeuanr] [-A | -f | [-p] -o field[,...]] filesystem
zfs rollback [-rRf] snapshot
zfs send [-vbpnC] [-Rr[c]] [-w compress|none]
     [-D [-m memsize]]
     [-iI snapshot] [-s subopt] snapshot
zfs set [-r] property=value filesystem|volume|snapshot ...
zfs share -u [-o property=value] filesystem%share
zfs share filesystem|mountpoint|filesystem%share
zfs share -a| -r | filesystem
zfs snapshot [-r] [-o property=value]...
     filesystem@snapname|volume@snapname
zfs unallow [-rldug] everyone|user|group[,...] [perm|@setname[,... ]]
     filesystem|volume
zfs unallow [-rld] -e [perm|@setname[,... ]] filesystem|volume
zfs unallow [-r] -c [perm|@setname[ ... ]] filesystem|volume
zfs unallow [-r] -s @setname [perm|@setname[,... ]] filesystem|volume
zfs unmount [-f] -a | filesystem|mountpoint
zfs unshare filesystem|mountpoint|filesystem%share
zfs unshare -a | -r filesystem
zfs upgrade
zfs upgrade [-v]
zfs upgrade [-r] [-V version] -a | filesystem
zfs userspace [-hniHp] [-o field[,...]] [-sS field] ...
     [-t type [,...]] filesystem|snapshot

描述

zfs 命令按照 zpool(8) 中描述的方式配置 ZFS 存储池中的 ZFS 数据集。数据集由 ZFS 名称空间中的唯一路径进行标识。例如:

pool/{filesystem,volume,snapshot}

其中,数据集名称的最大长度为 MAXNAMELEN(256 字节)。

数据集可以为下列类型之一:

file system

filesystem 类型的 ZFS 数据集可以挂载在标准系统名称空间中,并且行为与其他文件系统相似。虽然 ZFS 文件系统被设计为符合 POSIX 标准,但是在某些情况下仍然存在一些已知的妨碍符合性的问题。依赖于标准符合性的应用程序可能会在检查文件系统可用空间时由于非标准行为而失败。

volume

作为原始设备或块设备导出的逻辑卷。此类型的数据集只应在特殊情况下使用。文件系统通常适用于大多数环境。

snapshot

文件系统或卷在给定时间点的只读版本。它被指定为 filesystem@namevolume@name

ZFS 文件系统分层结构

ZFS 存储池是为数据集提供空间的设备的逻辑集合。A storage pool is also the root of the ZFS file system hierarchy.

存储池的根可作为文件系统进行访问,例如挂载和卸载、创建快照以及设置属性。但是,物理存储特征由 zpool(8) 命令管理。

有关创建和管理存储池的更多信息,请参见 zpool(8)

Snapshots

快照是文件系统或卷的只读副本。快照可以非常快速地创建,而且最初不占用池中的其他空间。当活动数据集中的数据发生变化时,快照占用的数据多于按其他方式与活动数据集共享的数据。

快照可以具有任意名称。卷的快照可进行克隆或回滚,但是不能单独访问。

可从文件系统根目录中的 .zfs/snapshot 目录下访问文件系统快照。快照会自动根据需要进行挂载,并可以按固定的间隔卸载。.zfs 目录的可见性可由 snapdir 属性控制。

克隆

克隆是可写的卷或文件系统,其初始内容与其他数据集相同。与快照一样,创建克隆也几乎是即时的,而且最初不占用其他空间。

克隆只能从快照创建。在克隆快照时,会在父项与子项之间创建隐式相关性。即使克隆是在数据集分层结构中的某个其他位置创建的,但只要存在克隆,就无法销毁原始快照。origin 属性显示此相关性,而 destroy 命令会列出任何此类相关性(如果存在)。

使用 promote 子命令,可以颠倒克隆父项-子项相关性关系。这将导致“原始”文件系统成为所指定文件系统的克隆,从而可能销毁创建克隆时所基于的文件系统。

Mount Points

创建 ZFS 文件系统是一项简单的操作,因此每个系统可能有多个文件系统。为处理这种情况,ZFS 自动管理文件系统的挂载和卸载,而不需要编辑 /etc/vfstab 文件。所有自动管理的文件系统均由 ZFS 在引导时挂载。

By default, file systems are mounted under /path, where path is the name of the file system in the ZFS namespace.可根据需要创建和销毁目录。

文件系统也可以在 mountpoint 属性中设置挂载点。此目录会根据需要进行创建;在调用 zfs mount -a 命令时,ZFS 将自动挂载文件系统(无需编辑 /etc/vfstab)。mountpoint 属性可以继承,因此如果 pool/home 有一个挂载点 /export/stuff,则 pool/home/user 会自动继承挂载点 /export/stuff/user

A file system can be mounted temporarily at a location other than the file systems persistent mount point by specifying the -o mountpoint=value option to the zfs mount command.仅允许对具有非先前挂载点的文件系统执行此操作。

文件系统的 mountpoint 属性 none 可防止挂载此文件系统。

如果需要,也可以用传统工具(mountumount/etc/vfstab)来管理 ZFS 文件系统。如果将文件系统的挂载点设置为 legacy,则 ZFS 不会尝试管理文件系统,并且管理员将负责挂载和卸载文件系统。

Zones

添加的文件系统的物理属性由全局管理员控制。但是,区域管理员可以根据添加的文件系统的挂载方式,在该文件系统中创建、修改或销毁文件。

使用 zonecfg add dataset 子命令也可以将数据集委托给非全局区域。您不能将数据集委托给一个区域,也不能将同一数据集的子项委托给另一个区域。区域管理员可以更改数据集或其任何子项的属性。但是,quota 属性由全局管理员控制。

通过 zonecfg add device 子命令,可以将 ZFS 卷作为一个设备添加到非全局区域。但是,只有全局管理员才可修改其物理属性。

有关 zonecfg 语法的更多信息,请参见 zonecfg(8) 手册页。

将数据集委托给非全局区域后,将自动设置 zoned 属性。在全局区域中,只能通过使用临时的 mountpoint 属性(请参见“临时挂载点属性”)挂载区域文件系统。

全局管理员可强制清除 zoned 属性,但是完成此操作应非常谨慎。全局管理员应在清除该属性前确认所有挂载点是可接受的。

重复数据删除

重复数据删除是在块级别删除冗余数据以减少存储的总数据量的过程。重复数据删除面向存储池范围;每个数据集都可以使用自己的 dedup 属性增减内容。如果文件系统启用了 dedup 属性,则在写入时将同步删除重复数据块。因此,在存储池已启用 dedup 的所有数据集中只会存储唯一的数据,并且会在这些数据集的文件中共享公共组件。

Encryption

有关 ZFS 加密和 ZFS 加密语法的完整说明,请参见 zfs_encrypt(8)

File Retention

File retention protects a file from being altered or deleted for a specified period of time.After that time has passed, the file may only be deleted.File retention is only available for regular files.

A filesystem may have retention enabled by setting the retention.policy property.This can only be enabled during filesystem creation.

The period for which a file is retained may be specified in touch -R or using touch -a to set the atime into the future prior to making the file read-only.If neither of these is used, the file is retained for the retention.period.default.

Files on a filesystem with retention enabled are retained by setting the retention time via touch -R, by removing all write permissions, or by setting the readonly file attribute.

Native Properties

属性分为两种类型:本机属性和用户定义的(或用户)属性。本机属性用于提供内部统计信息或控制 ZFS 行为。此外,本机属性分为可编辑属性和只读属性。用户属性对 ZFS 行为没有影响,但可通过用户环境中有意义的方式来注释数据集。有关用户属性的更多信息,请参见下文的“用户属性”一节。

每个数据集都有一组属性,用于提供有关数据集的统计信息并控制各种行为。属性继承自父项,但子项所覆盖的除外。有些属性仅适用于某些类型的数据集(文件系统、卷或快照)。

数值属性的值可使用便于阅读的后缀(例如 kKBMGb 等,直到表示泽字节的 Z)来指定。下面都是有效(且等效)的指定:

1536M, 1.5g, 1.50GB

非数值属性的值区分大小写,并且必须为小写形式,mountpoint 属性除外。

以下本机属性包含数据集的相关只读统计信息。既不能设置这些属性,也不能继承这些属性。除非另有说明,否则本机属性适用于所有数据集类型。

available

数据集及其所有子项的可用空间的数量(假定池中没有其他活动)。由于池中会共享空间,因此可用空间会受到许多因素的限制,包括物理池大小、配额、预留空间或池中的其他数据集。

此属性也可通过其简短列名 avail 来引用。

compressratio

为此数据集实现的压缩率,以倍数形式表示。通过运行 zfs set compression=on dataset 可以启用压缩。缺省值为 off(关闭)。

creation

创建此数据集的时间。

defer_destroy

This property is on if the snapshot has been marked for deferred destroy by using the zfs destroy -d command.否则,此属性为 off

keychangedate

有关更多信息,请参见 zfs_encrypt(8)

keystatus

有关更多信息,请参见 zfs_encrypt(8)

mounted

对于文件系统,指示当前是否已挂载文件系统。此属性可以是 yesno

origin

对于克隆的文件系统或卷,指示创建克隆时所基于的快照。The origin cannot be destroyed (even with the -r or -f options) so long as a clone exists.

referenced

此数据集可访问的数据量,这些数据可以与池中其他数据集共享,也可以不与其他数据集共享。创建快照或克隆时,首先会引用与创建时所基于的文件系统或快照相同的空间量,因为其内容相同。

此属性也可通过其简短列名 refer 来引用。

rekeydate

有关更多信息,请参见 zfs_encrypt(8)

type

数据集类型:filesystemvolumesnapshot

used

此数据集及其所有后代占用的空间量。这是根据此数据集的配额和预留空间进行检查的值。使用的空间不包括此数据集的预留空间,但是会考虑 refreservation(通过 usedbyrefreservation)以及任何后代数据集的预留空间(通过 usedbychildren)。数据集占用其父项的空间量以及以递归方式销毁此数据集时所释放的空间量,应为其使用空间和预留空间的较大者。

创建快照时(请参见“快照”一节),其空间最初将在快照与文件系统之间共享,也可能与以前的快照共享。随着文件系统的变化,以前共享的空间将供快照专用,并会计算在快照的使用空间内。此外,删除快照可增加其他快照专用(和使用)的空间量。

使用的空间量、可用的空间量或引用的空间量不会考虑暂挂更改。通常,暂挂更改仅占用几秒钟的时间。使用 fsync(3C)O_SYNC 提交对磁盘的更改,不一定可以保证空间使用情况信息会立即更新。

usedby*

usedby* 属性将 used 属性分解为使用该空间的各种原因。具体而言,used = usedbychildren + usedbydataset + usedbyrefreservation + usedbysnapshots。这些属性只能用于在版本 13 或更高版本的池上创建的数据集。

usedbychildren

此数据集的子项使用的空间量,如果销毁此数据集的所有子项,将释放该空间。

usedbydataset

The amount of space used by this dataset itself, which would be freed if the dataset was destroyed (after first removing any refreservation and destroying any necessary snapshots or descendents).

usedbyrefreservation

针对此数据集设置的 refreservation 占用的空间量,如果删除 refreservation,将释放该空间。

此属性所占用的空间表示未来写操作可能消耗的空间,预留以防此数据集出现写分配故障。这可能包括未写入的数据、当前与快照共享的空间,以及卷的压缩节省空间(当用更少的可压缩数据替换时可能丢失)。当为后续写操作分配空间增加 usedbydatasetusedbysnapshots 时,将相应减少 usedbyrefreservation

usedbysnapshots

此数据集的快照占用的空间量。特别地,此空间量是销毁此数据集的所有快照后将释放的空间量。请注意,此空间量不是快照的 used 属性的简单总和,因为空间可被多个快照共享。

userused@user

此数据集中指定的用户占用的空间量。Space is charged to the owner of each file, as displayed by ls -l.The amount of space charged is displayed by du and ls -s.有关更多信息,请参见 zfs userspace 子命令。

未授权的用户只能访问各自的空间使用情况。root 用户或已用 zfs allow 授予 userused 特权的用户,可以访问每个人的空间使用情况。

zfs get all 不会显示 userused@... 属性。必须使用以下形式之一在 @ 符号后加上用户名:

  • POSIX name(例如 joe

  • POSIX numeric ID(例如 789

  • SID name(例如 joe.smith@mydomain

  • SID numeric ID(例如 S-1-123-456-789

userrefs

为此快照上的用户保留量可设置此属性。通过使用 zfs hold 命令可设置用户保留量。

groupused@group

此数据集中指定的组占用的空间量。Space is charged to the group of each file, as displayed by ls -l.有关更多信息,请参见 userused@user 属性。

未授权的用户只能访问各自的组的空间使用情况。root 用户或已用 zfs allow 授予 groupused 特权的用户,可以访问所有组的空间使用情况。

volblocksize=blocksize

可为卷指定卷的块大小。在写入卷后无法更改 blocksize,因此应在创建卷时设置该值。卷的缺省 blocksize 是 8 KB。范围位于 512 字节到 1 MB 之间的 2 的任意次幂都有效。

此属性也可通过其简短列名 volblock 来引用。

effectivereadlimit
effectivewritelimit

这些属性展示了数据集上的有效限制是什么。显示的值指示制约数据集的最大吞吐量。报告的有效限制是根数据集与所指示的数据集之间任意一点上的最低数据限制。有关限制行为的更多详细信息,请参见 readlimitwritelimit

使用以下本机属性可以更改 ZFS 数据集的行为。

aclmode=discard | mask | passthrough

控制 chmod(2) 执行期间如何修改 ACL。带有 aclmode 属性 discard(缺省值)的文件系统删除不表示文件模式的所有 ACL 条目。aclmode 属性 mask 减少用户或组的权限。除非用户项与文件或目录的属主具有相同的 UID,否则将减少权限,以使其不会大于组权限位。在这种情况下,减少 ACL 权限,以使其不会大于所有者权限位。mask 还跨模式更改保留 ACL(两次模式更改之间没有进行显式 ACL 设置 [通过 chmod(1)])。带有 aclmode 属性 passthrough 的文件系统指示除了生成必要的 ACL 条目来表示文件或目录的新模式以外,不会对 ACL 进行其他更改。

refreservation=size | none | auto

为数据集(不含其后代)预留的最小空间量。对于文件系统,缺省 refreservation 为 none。

对于 ZFS 卷,refreservation 自动设置为比实际卷大小稍大的值以将 ZFS 元数据开销考虑在内。您可以使用 dense 值为当前卷大小的数据和元数据保留足够的空间。例如,如果您需要更多的空间用于其他文件系统,可以临时减小某个卷的 refreservation 值,这会将此卷转换为一个稀疏卷。当卷是通过指定 dense 值创建的时,您可以将卷 refreservation 值恢复为原始值。

如果 usedbydataset 空间低于此值,则认为数据集正在使用 refreservation 指定的空间量。usedbyrefreservation 数字表示该额外空间,并添加到数据集占用的总已使用空间,继而占用父数据集的用量、配额和预留空间。这将通过确保提前预留用于未来写操作的空间,防止数据集过度承载池资源。

与快照共享的空间此后将被新数据替换,快照表示承诺保留两份副本。如果设置了 refreservation,则在拍摄新快照时必须将 usedbyrefreservation 增大到 refreservation 的最大大小,以将此承诺考虑在内。如果对此增量没有足够空间可用于数据集,则将拒绝创建快照。

此属性也可通过其简短列名 refreserv 来引用。

aclinherit=discard | noallow | restricted | passthrough | passthrough-x passthrough-mode-preserve

控制创建文件和目录时继承 ACL 项的方法。A file system with an aclinherit property of discard does not inherit any ACL entries.aclinherit 属性值为 noallow 的文件系统仅继承指定了“拒绝”权限的可继承 ACL 项。在继承 ACL 项时,属性值 restricted(缺省值)会删除 write_aclwrite_owner 权限。如果文件系统的 aclinherit 属性值为 passthrough,则会继承所有可继承的 ACL 项,并且继承 ACL 项时不会对其进行任何修改。如果文件系统的 aclinherit 属性值为 passthrough-x,则与 passthrough 具有同样的意义,区别在于仅当文件创建模式也需要执行位时,所有 ACE 均继承执行权限。如果文件系统的 aclinherit 属性值为 passthrough-mode-preserve,则该文件系统与 "passthrough" 具有相同的语义,区别在于创建文件和目录时,owner@、group@ 和 everyone@ ACE 由来自应用程序所请求的模式的值覆盖。

当属性值设置为 passthrough 时,将使用由可继承的 ACE 确定的模式来创建文件。如果不存在影响模式的可继承 ACE,则会根据应用程序请求的模式设置模式。

atime=on | off

控制文件被读取后是否更新该文件的访问时间。禁用该属性可避免在读取文件时产生写入流量,因此可显著提高性能,但可能会使邮件程序与其他相似的实用程序感到困惑。缺省值为 on

canmount=on | off | noauto

如果此属性设置为 off,则无法挂载文件系统,并且 zfs mount -a 将忽略此文件系统。将此属性设置为 off 与将 mountpoint 属性设置为 none 的效果相似,区别在于数据集仍有一个可继承的正常 mountpoint 属性。通过将此属性设置为 off,可以将数据集单独用作一种继承属性的机制。例如,设置 canmount=off 将使两个数据集具有相同的 mountpoint,因此两个数据集的子项会出现在同一个目录中,但是可能具有不同的继承特征。

设置 noauto 选项时,只能显式挂载和卸载数据集。数据集不会在创建或导入时自动挂载,也不能通过 zfs mount -a 命令挂载或通过 zfs unmount -a 命令卸载。

不会继承此属性。

checksum=on | off | fletcher2 | fletcher4 | sha256 | sha256+mac

控制用于验证数据完整性的校验和。The default value is on, which automatically selects an appropriate algorithm (currently fletcher4, but this may change in future releases).值为 off 将禁止对用户数据进行完整性检查。实际操作中建议要禁用校验和。

更改此属性只会影响新写入的数据。

只有在启用加密时,值 sha256+mac 才可用。在启用加密时,校验和属性变为 readonly,然后始终将其设置为 sha256+mac

compression=on | off | lzjb | gzip | gzip-N | zle | lz4

控制用于此数据集的压缩算法。在提供适当的数据压缩时,将为 lzjb 压缩算法优化性能。将压缩设置为 on 会使用 lzjb 压缩算法。The gzip compression algorithm uses the same compression as the gzip(1) command.通过使用值 gzip-N 可以指定 gzip 级别,其中 N 是一个从 1(最快)至 9(最佳压缩率)的整数。Currently, gzip is equivalent to gzip-6 (which is also the default for gzip(1)). lz4 provides better compression than lzjb with lower CPU overhead.Neither gzip nor lz4 compression is currently supported when set at the root pool level nor on the root pool dataset.

该属性也可通过其简短列名 compress 来引用。更改此属性只会影响新写入的数据。

copies=1 | 2 | 3

控制为此数据集存储的数据副本数量。这些副本是对池提供的任何冗余(例如镜像或 RAID-Z)的补充。这些副本将存储在不同的磁盘上(如果可能)。多个副本使用的空间由相关联的文件和数据集占用,按照配额和预留空间更改 used 属性和计算方式。

更改此属性只会影响新写入的数据。因此,在创建文件系统时通过使用 -o copies=N 选项设置此属性。

在数据集上启用加密时,可设置的最大副本数量是 2

当数据集是自动置备的 ZFS 卷时,更改副本也会导致更改 refreservation。有关详细信息,请参见 "refreservation"。

dedup=on | off | verify | sha256[,verify]

控制重复数据删除对数据集是否有效。缺省值为 off(关闭)。用于重复数据删除的缺省校验和是 sha256(可能会更改)。在启用 dedup 时,dedup 校验和算法会覆盖 checksum 属性。将值设置为 verify 等效于指定 sha256,verify

如果将属性设置为 verify,则只要两个块具有相同的签名,ZFS 都会与现有块进行逐字节比较,以确保内容完全相同。

devices=on | off

控制是否可在此文件系统中打开设备节点。缺省值为 on

exec=on | off

控制是否可从此文件系统中执行进程。缺省值为 on

logbias = latency | throughput

控制 ZFS 如何为此数据集优化同步请求。如果 logbias 设置为 latency,ZFS 将使用池的不同日志设备(如有)低延迟地处理请求。如果 logbias 设置为 throughput,ZFS 将不使用池的不同日志设备。相反,ZFS 将优化同步操作,以提高池的全局吞吐量并有效使用资源。缺省值为 latency

mlslabel=label | none

有关多级别文件系统中 mlslabel 属性行为的说明,请参见 multilevel 属性。下面的 mlslabel 说明适用于非多级别文件系统:

mlslabel 属性是一个敏感标签,用于确定能否在启用了 Trusted Extensions 的系统的区域中挂载数据集。如果有标签的数据集与有标签的区域相符,则可以从有标签的区域挂载和访问数据集。

如果未设置 mlslabel 属性,缺省值将为 none。将 mlslabel 属性设置为 none 等效于删除该属性。

只有在启用了 Trusted Extensions 并且具有相应的特权时,才能修改 mlslabel 属性。不可委托用于修改此属性的权限。将标签更改为较高级别标签或设置初始数据集标签时,需要 {PRIV_FILE_UPGRADE_SL} 特权。将标签更改为较低级别标签或缺省标签 (none) 时,需要 {PRIV_FILE_DOWNGRADE_SL} 特权。只有在未挂载数据集时,才能将数据集更改为缺省值以外的标签。将具有缺省标签的数据集挂载到有标签区域时,挂载操作会自动将 mlslabel 属性设置为该区域的标签。

如果启用 Trusted Extensions,则只能挂载具有缺省标签 (none) 的数据集。

mountpoint=path | none | legacy

控制用于此文件系统的挂载点。有关如何使用此属性的更多信息,请参见“挂载点”一节。

当文件系统的 mountpoint 属性发生更改时,将卸载该文件系统以及继承挂载点的任何子项。如果新值为 legacy,则该文件系统和子级将保持卸载状态。否则,如果属性以前为 legacynone,或者该文件系统和子级在属性发生更改之前处于挂载状态,则会自动在新位置重新挂载它们。此外,任何共享文件系统都将取消共享,并在新位置进行共享。

nbmand=on | off

有关更多信息,请参见 zfs_share(8)

primarycache=all | none | metadata

控制在主高速缓冲存储器 (ARC) 中缓存的内容。如果将此属性设置为 all,则会高速缓存用户数据和元数据。如果将此属性设置为 none,则不会高速缓存用户数据和元数据。如果将此属性设置为 metadata,则只会高速缓存元数据。缺省值为 all

quota=size | none

限制数据集及其后代可占用的空间量。这包括后代(含文件系统和快照)占用的所有空间。配额的实施可能会延迟几秒钟。这种延迟意味着在系统注意到用户超出配额前,用户可以超出其配额。然后,系统将开始拒绝其他写入。对已有配额的数据集的后代设置配额不会覆盖祖先的配额,但会施加额外的限制。不能对卷设置配额,因为 volsize 属性可用作隐式配额。

readlimit=size | none | default
writelimit=size | none | default

限制将读取或写入数据集的速率(以字节/秒为单位)。在某个数据集上施加的限制将应用于该数据集及其所有后代。值 "none" 将覆盖由父项设置的任何缺省值。值 "default" 将使数据集回到由父项设置的任何缺省值。这些值不是保证带宽,实际带宽可能会受其他因素限制,包括用量以及在层次结构中其他数据集上设置的限制。这些限制的实施可能会延迟几秒钟。

defaultreadlimit=size | none
defaultwritelimit=size | none

为数据集设置将读取或写入数据集的缺省限制(以每秒字节数为单位)。在某个数据集上施加的缺省限制将仅应用于数据集的后代。此值由后代继承,可通过在后代上设置 readlimitwritelimit 值来覆盖。这些值不是保证带宽,实际带宽可能会受其他因素限制,包括用量以及在层次结构中其他数据集上设置的限制。这些限制的实施可能会延迟几秒钟。

sync=standard | always | disabled

确定文件系统事务的同步程度。在创建数据集时可设置此属性,也可动态设置此属性,并且属性将会立即生效。此属性可能具有以下设置之一:

standard

缺省选项。将同步文件系统事务写入到意图日志,然后刷新写入的所有设备,以确保数据稳定(即设备控制器未进行高速缓存)。

always

将每个文件系统事务写入到稳定的存储器中并刷新。此值对性能具有重大不利影响,但是适合为同步文件系统事务排除故障。

disabled

禁用同步请求。仅当下一次提交 DMU 事务组时,文件系统事务才会提交至稳定的存储器,这可能会延迟好几秒钟。此设置提供最高性能。但是,这是非常危险的,因为 ZFS 会忽略应用程序的同步事务要求,例如数据库或 NFS。而且,当此设置对当前活动的根或 /var 文件系统生效时,可能导致行为不合规范、应用程序数据丢失以及增加反复攻击的漏洞。管理员只应在了解这些风险时才使用此选项。

defaultuserquota=size | none

设置缺省用户配额。缺省值为 none。该值将应用于没有明确指定用户配额的所有用户。

defaultgroupquota=size | none

设置缺省组配额。缺省值为 none。该值将应用于没有明确指定用户配额的所有组。

userquota@user=size | none | default

限制指定的用户占用的空间量。与 refquota 属性相似,计算 userquota 空间不包括后代数据集(例如快照和克隆)使用的空间。用户空间占用由 userspace@user 属性标识。

用户配额的实施可能会延迟几秒钟。这种延迟意味着在系统注意到用户超出配额前,用户可以超出其配额。The system would then begin to refuse additional writes with the EDQUOT error message.有关更多信息,请参见 zfs userspace 子命令。

未授权的用户只能访问各自的组的空间使用情况。root 用户或已用 zfs allow 授予 userquota 特权的用户,可以获取和设置每个人的配额。

对于卷、第 4 版以前的文件系统或第 15 版以前的池,此属性均不可用。zfs get all 不会显示 userquota@... 属性。必须使用以下形式之一在 @ 符号后加上用户名:

  • POSIX name(例如 joe

  • POSIX numeric ID(例如 789

  • SID name(例如 joe.smith@mydomain

  • SID numeric ID(例如 S-1-123-456-789

值为 default 会将配额重置为 defaultuserquota 属性定义的缺省值。

groupquota@group=size | none | default

限制指定的组占用的空间量。组空间占用由 userquota@user 属性标识。

未授权的用户只能访问各自的组的空间使用情况。root 用户或已用 zfs allow 授予 groupquota 特权的用户,可以获取和设置所有组的配额。

值为 default 会将组配额重置为 defaultgroupquota 属性定义的缺省值。

readonly=on | off

控制是否可以修改此数据集。缺省值为 off(关闭)。

该属性也可通过其简短列名 rdonly 来引用。

recordsize=size

为文件系统中的文件指定建议的块大小。该属性专门设计用于对大小固定的记录中的文件进行访问的数据库工作负荷。ZFS 会根据为典型的访问模式优化的内部算法来自动调整块大小。

对于创建很大的文件但访问较小的随机块中的文件的数据库而言,这些算法可能不是最优的。Specifying a recordsize greater than or equal to the record size of the database can result in significant performance gains.强烈建议不要将该属性用于一般用途的文件系统,否则可能会对性能产生不利影响。

缺省 recordsize 是 128 KB。指定的大小必须是 2 的若干次幂,并且必须大于或等于 512 字节同时小于或等于 1 MB。

更改文件系统的 recordsize 只影响以后创建的文件,现有文件和接收的数据不受影响。

此属性也可通过其简短列名 recsize 来引用。

refquota=size | none

限制数据集可以占用的空间量。这种限制不包括后代(含文件系统和快照)所占用的空间。refquota 的实施可能会延迟几秒钟。这种延迟意味着在系统注意到用户超出配额前,用户可以超出其配额。然后,系统将开始拒绝其他写入。

refreservation=size | none | auto

为数据集(不含其后代)预留的最小空间量。

对于 ZFS 卷,缺省的 refreservation 值为 auto,对于其他类型的数据集,缺省值为 none。当 refreservation=auto 时,会为卷保留足够的空间来存储其指定的卷大小 (volsize) 和关联的元数据。此实际保留量同时取决于 volsizecopies 属性。A volume can also be manually provisioned by setting refreservation to a numeric value (for example, zfs set refreservation=10g).由于元数据的存在,保证会用于卷数据的实际空间将略少于所请求的 refreservation 数值。A sparse volume (for example, when -s is specified at volume creation) is equivalent to one with a refreservation of none.请注意,refreservation=auto 仅适用于 ZFS 卷。

为卷保留的但该卷当前未使用的空间计入 usedbyrefreservation 中。因此,zfs 卷的实际总 refreservation 始终等于 usedbydatasetusedbyrefreservation 之和。此完整总和是父数据集的使用量、配额和保留量的总和。这将通过确保提前预留用于未来写操作的空间,防止每个数据集过度承载池资源。

与快照共享的空间此后将被新数据替换,快照表示承诺保留两份副本。如果设置了 refreservation,则在拍摄新快照时必须将 usedbyrefreservation 增大到 refreservation 的最大大小,以将此承诺考虑在内。如果对此增量没有足够空间可用于数据集,则将拒绝创建快照。

此属性也可通过其简短列名 refreserv 来引用。

reservation=size | none

为数据集及其后代预留的最小空间量。如果使用的空间量低于该值,则认为数据集正在占用其预留空间指定的空间量。父数据集的使用空间中会包含预留空间,并会针对父数据集的配额和预留空间对其进行计数。

此属性也可通过其简短列名 reserv 来引用。

rstchown=on | off

指示文件系统是否通过 chown(1)chown (2) 系统调用来限制用户放弃其文件。缺省值是限制 chown。如果 rstchownoff,则 chown 的行为将如同用户具有 PRIV_FILE_CHOWN_SELF 特权一样。

secondarycache=all | none | metadata

控制在二级高速缓存 (L2ARC) 中缓存的内容。如果将此属性设置为 all,则会高速缓存用户数据和元数据。如果将此属性设置为 none,则不会高速缓存用户数据和元数据。如果将此属性设置为 metadata,则只会高速缓存元数据。缺省值为 all

setuid=on | off

控制文件系统是否遵照 set-UID 位。缺省值为 on

shadow=URI | none

将 ZFS 文件系统视为 URI 描述的文件系统的影子。设置该属性时,数据从 URI 标识的文件系统迁移到影子文件系统。将迁移的文件系统必须为只读才能进行完整迁移。

对影子文件系统中尚未迁移的目录的访问会被阻止,直到迁移了整个目录。对影子文件系统中尚未迁移的文件进行访问将导致只迁移被访问文件的一部分。多个进程可以同时迁移一个文件的不同部分。

接受两种格式的 URI,一种用于将本地文件系统迁移到同一物理系统上的其他文件系统,另一个用于从 NFS 服务器远程迁移文件系统。这两种格式为:

file:///path
nfs://host/path

如果迁移完成时 shadowd(8) 仍在运行,则文件系统将自动重新挂载(影子属性设置为 none)。或者,迁移完成时,您可以手动将影子属性设置为 none

sharenfs=on | off

有关更多信息,请参见 zfs_share(8)

sharesmb=on | off

有关更多信息,请参见 zfs_share(8)

snapdir=hidden | visible

按照“快照”一节的讨论,控制在文件系统的根中是否隐藏或显示 .zfs 目录。缺省值为 hidden

version=1 | 2 | current

此文件系统的盘上版本,与池版本无关。只可以为后续支持的版本设置此属性。设置 zfs upgrade 命令。

volsize=size

指定卷的逻辑大小。缺省情况下,创建卷将建立稍大于实际逻辑卷大小的 refreservation,以用于 ZFS 源数据开销。对 volsize 的任何更改都会反映为对 refreservation 的等效更改。volsize 只可以设置为多个 volblocksize,并且不能为零。

在卷上设置 refreservation,以防止使用者的意外行为。如果没有预留空间,则卷可能用完空间,导致不明确的行为或数据损坏,具体取决于卷的使用方式。如果在卷的使用过程中(特别是在缩减大小时)更改卷大小,也会出现上述影响。调整卷大小时,需要格外小心。如果卷是自动置备的,则更改其大小还会导致更改 refreservation。有关更多信息,请参见 "refreservation" 部分。

Though not recommended, a sparse volume (also known as thin provisioning) can be created by specifying the -s option to the zfs create -V command.稀疏卷是预留空间小于卷大小的卷。因此,当池空间不足时,对稀疏卷的写操作可能因 ENOSPC 而失败。对于稀疏卷,预留空间中不会反映对 volsize 的更改。

vscan=on | off

有关更多信息,请参见 zfs_share(8) 手册页。

xattr=on | off

控制是否为此文件系统启用扩展属性。缺省值为 on

zoned=on | off

控制是否从非全局区域管理数据集。有关更多信息,请参见“区域”一节。缺省值为 off(关闭)。

在创建文件系统后无法更改以下属性,因此在创建文件系统时应设置这些属性。如果未使用 zfs createzpool create 命令设置属性,则从父数据集继承这些属性。如果在这些功能获得支持以前已创建的父数据集缺少这些属性,则新文件系统将为这些属性采用缺省值。

casesensitivity=sensitive | insensitive | mixed

有关更多信息,请参见 zfs_share(8)

normalization = none | formC | formD | formKC | formKD

有关更多信息,请参见 zfs_share(8)

utf8only=on | off

有关更多信息,请参见 zfs_share(8)

encryption=off | on | aes-128-ccm | aes-192-ccm | aes-256-ccm |
aes-128-gcm | aes-192-gcm | aes-256-gcm

有关更多信息,请参见 zfs_encrypt(8)

multilevel=on | off

缺省值为 off(关闭)。设置为 on 后,无法将其关闭。

多级别文件系统中的对象带有各自的标签,这些标签使用自动生成的显式敏感标签属性。可以就地为对象设置标签,方法是使用 setlabel(1)setflabel(3TSOL) 接口更改此标签属性。

区域数据集、系统根数据集以及其他包含打包的 Solaris 代码的数据集不应是多级别的。

多级别文件系统的上限在 mlslabel 属性中维护。通常,mlslabel 由系统自动管理。多级别属性设置为 on 时,它将设置为 ADMIN_LOW,并在升级文件和目录时浮现以表示最大敏感标签。创建多级别文件系统之后,mlslabel 无法更改为较低级别标签,无法删除或设置为 none。

启用 Trusted Extensions 后,mlslabel 值定义文件系统中的对象可以具有的最高可能标签。不允许将文件的标签创建为或重新标记为高于 mlslabel 的标签。可以在创建文件系统期间显式设置 mlslabel 属性,否则,将自动创建 mlslabel 属性的缺省值 ADMIN_HIGH。基于 mlslabel 的挂载策略不适用于多级别文件系统。

在创建时必须指定以下属性,并可以使用特殊命令修改该属性:

keysource=raw | hex | passphrase,prompt | file

有关更多信息,请参见 zfs_encrypt(8)

retention.policy=off | privileged | mandatory

This controls whether file retention is enabled for the given filesystem.It may only be set during filesystem create and is read-only thereafter.

off

File retention is disabled.

privileged

File retention is enabled.A process with the FILE_RETENTION_OVERRIDE privilege can delete a retained file or change its retention time backwards, but cannot modify the file's contents.The filesystem and its containing pool are not protected from destruction.

mandatory

File retention is enabled.No privilege, including those held by root, can allow for a retained file to be deleted until the retention has expired.A retained file's contents cannot be changed.Its retention timestamp may be changed forward, but cannot be changed backwards.The filesystem and its containing pool are protected from destruction until the last retention timestamp has expired.

retention.period.min=timeinterval
retention.period.max=timeinterval

These values constrain the range of time for which a file may be retained.The retention.period.default may not be less than retention.period.min or greater than retention.period.max.A retention time specified with touch -a or touch -R that is less than retention.period.min will be increased to retention.period.min and one that is greater than retention.period.max will be decreased to retention.period.max.

Retention period values must be less than 100 years.

retention.period.default=timeinterval

This value is used as the retention period for a file when no time was specified using touch prior to retention.

Retention period values must be less than 100 years.

retention.period.grace=timeinterval

The retention grace period controls automatic file retention.If it is set to zero seconds, automatic retention is disabled.If it is set to a period greater than zero seconds, automatic retention is enabled.Once a file has remained unmodified for that non-zero grace period it is automatically retained for the period specified by retention.period.default.

On mandatory retention filesystems, once automatic retention is enabled, it cannot be turned off.That is, the grace period value, once changed from zero to a positive integer, cannot be set back to zero.Further, on mandatory retention filesystems, the grace period value may never be increased, but may be reduced with a minimum of 1 second.

On privileged retention filesystems, the grace period value may be adjusted as desired.

Retention period values must be less than 100 years.

retention.status.expiry

The latest-expiring retention timestamp of a file is shown by this read-only filesystem property.If that time has passed, the property will also display (expired) indicating that all file retentions have expired.

retention.status.files

A count of retained files is shown by this read-only filesystem property.This count increases when a file is retained.It does not change when a file's retention expires; it is only reduced when a retained file is deleted.This count does not reflect files which auto-retention hasn't yet retained yet, but those will be included on their next access.

临时挂载点属性

通过传统的 mount(8) 命令或 zfs mount 命令挂载文件系统时,该文件系统的挂载选项将根据其属性设置。属性与挂载选项之间的相互关系如下:

        PROPERTY          MOUNT OPTION
        devices           devices/nodevices
        mountpoint        mountpoint
        exec              exec/noexec
        readonly          ro/rw
        setuid            setuid/nosetuid
        xattr             xattr/noxattr
        rstchown          rstchown/norstchown

In addition, these options can be set on a per-mount basis using the -o option, without affecting the property that is stored on disk.命令行上指定的值会覆盖数据集中存储的值。nosuid 选项是 nodevices,nosetuid 的别名。zfs get 命令将这些属性作为临时属性进行报告。如果在数据集挂载期间更改了属性,新设置将覆盖临时设置。如果被修改的属性是挂载点,数据集将立即从临时挂载点卸载,并重新挂载到新的持久性挂载点。

User Properties

除了标准的本机属性外,ZFS 还支持任意用户属性。用户属性对 ZFS 行为没有影响,但是应用程序或管理员可以使用这些属性来注释数据集(文件系统、卷和快照)。

用户属性名称必须含有一个冒号 (:) 字符,以便与本机属性区分。这些名称可包含小写字母、数字和以下标点符号:冒号 (:)、破折号 (-)、句号 (.) 和下划线 (_)。预期约定是将属性名称分为两部分,例如 moduleproperty,但是 ZFS 并不强制执行这种名称空间。用户属性名称最多可有 256 个字符,不能以破折号 (-) 开头。

在程序中使用用户属性时,强烈建议对属性名的 module 部分使用反向 DNS 域名,以尽量避免两个独立开发的软件包将同一属性名用于不同用途。在 Oracle Solaris 发行版中,为 beadm 命令和库保留了 com.oracle 用户属性。com.oracle:rootfs 保留用于 Oracle Solaris 引导。它将定义与可引导数据集相关联的根文件系统数据集。

用户属性的值是任意字符串,始终会继承但是从不会验证这些值。对属性执行操作的所有命令(如 zfs listzfs getzfs set 等)都可用来处理本机属性和用户属性。使用 zfs inherit 命令可清除用户属性。如果任意父数据集中均未定义该属性,则会将其完全删除。属性值仅限于 1024 个字符。

ZFS 卷作为交换设备或转储设备

初始安装期间,将会在 ZFS 根池的 ZFS 卷上创建交换设备和转储设备。必须将单独的 ZFS 卷用于交换区域和转储设备。在 ZFS 文件系统中,不要交换到文件。不支持 ZFS 交换文件配置。

通过为该设备指定 encryption 属性,以及在 vfstab(5) 中指定 encrypted 选项,可以对用作交换设备的 ZFS 卷进行加密。有关加密属性的更多信息,请参见 zfs_encrypt(8)

如果您需要在安装或升级系统后更改交换区域或转储设备,请使用 swap(8)dumpadm(8) 命令。如果需要更改交换区域或转储设备的大小,请参见在 Oracle Solaris 11.4 中管理 ZFS 文件系统一书。

SUBCOMMANDS

修改状态的所有子命令将以原始形式永久记录到池中。

zfs ?

显示帮助消息。

zfs help command | help | property property-name | permission

显示 zfs 命令的用法信息。可以显示特定命令、属性或委托权限的帮助。如果显示特定命令或属性的帮助,将显示命令语法或属性值。在不带任何参数的情况下使用 zfs help 将显示完整的 zfs 命令列表。

zfs help -l properties

显示 zfs 属性信息,包括是否可以编辑和继承属性值以及可能的属性值。

zfs allow filesystem | volume
zfs allow [-ldug] everyone|user|group[,...] perm|@setname[,...] filesystem| volume
zfs allow [-ld] -e perm|@setname[,...] filesystem|volume
zfs allow -c perm|@setname[,...] filesystem|volume
zfs allow -s @setname perm|@setname[,...] filesystem|volume

有关 zfs allow 语法和示例的完整说明,请参见 zfs_allow(8)

zfs clone [-p] [-K] [-o property=value] ... snapshot filesystem|volume

创建给定快照的克隆。有关详细信息,请参见“克隆”一节。目标数据集可以位于 ZFS 分层结构中的任意位置,并且创建为与原始数据集相同的数据类型。

-p

创建所有非现有的父数据集。以这种方式创建的数据集会根据从父项继承的 mountpoint 属性自动挂载。如果目标文件系统或卷已存在,则操作将成功完成。

-o property=value

设置指定的属性;有关详细信息,请参见 zfs create

-K

有关信息,请参见 zfs_encrypt(8)

zfs create [-p] [-o property=value] ... filesystem

创建新的 ZFS 文件系统。该文件系统会根据从父项继承的 mountpoint 属性自动挂载。

-p

创建所有非现有的父数据集。以这种方式创建的数据集会根据从父项继承的 mountpoint 属性自动挂载。Any property specified on the command line using the -o option is ignored.如果目标文件系统已经存在,则会成功完成此操作。

-o property=value

与在创建数据集时调用命令 zfs set property=value 一样设置指定的属性。在创建时也可设置任何可编辑的 ZFS 属性。可以指定多个 -o 选项。An error results if the same property is specified in multiple -o options.

zfs create [-ps] [-b blocksize] [-o property=value] ... -V size volume

创建一个给定大小的卷。The volume is exported as a block device in /dev/zvol/{dsk,rdsk}/path, where path is the name of the volume in the ZFS namespace.size 表示设备导出的逻辑大小。缺省情况下,创建一个同等大小的预留空间。

size 自动舍入到最接近的 128 KB,确保无论 blocksize 有多大,卷具有的块数量均为整数。

-p

创建所有非现有的父数据集。以这种方式创建的数据集会根据从父项继承的 mountpoint 属性自动挂载。Any property specified on the command line using the -o option is ignored.如果目标文件系统已经存在,则会成功完成此操作。

-s

创建一个不带预留空间的稀疏卷。有关稀疏卷的更多信息,请参见“本机属性”一节中的 volsize

-o property=value

与在创建数据集时调用 zfs set property=value 命令一样设置指定的属性。在创建时也可设置任何可编辑的 ZFS 属性。可以指定多个 -o 选项。An error results if the same property is specified in multiple -o options.

-b blocksize

Equivalent to -o volblocksize=blocksize.If this option is specified in conjunction with -o volblocksize, the resulting behavior is undefined.

zfs destroy [-rRsf] filesystem|volume

销毁给定数据集及其所有快照。缺省情况下,此命令会取消共享当前已共享的任何文件系统,卸载当前已挂载的任何文件系统,并拒绝销毁具有活动相关项(子项或克隆)的数据集。缺省行为是在控制权交还给调用方之后以异步方式回收由数据集占用的空间。可以使用 zpool monitor 命令查看异步数据集销毁的进度。有关更多信息,请参见 zpool(8) 手册页。

-r

以递归方式销毁所有子项。

-R

以递归方式销毁所有相关项,包括在目标分层结构以外克隆的文件系统。

-s

以同步方式销毁快照。缺省行为是在命令返回到调用方之后以异步方式回收已销毁的数据集。如果指定了此选项,则在完全释放由数据集占用的块之前,控制权不会交还给调用方。

-f

强制使用 unmount -f 命令卸载任何文件系统。此选项对非文件系统或已卸载的文件系统没有影响。

Extreme care should be taken when applying either the -r or the -f options, as they can destroy large portions of a pool and cause unexpected behavior for mounted file systems in use.

zfs destroy [-rRsd] snapshot

The given snapshot is destroyed immediately if and only if the zfs destroy command without the -d option would have destroyed it.例如快照没有克隆和用户启动的引用计数为零的情况下,会发生此类立即销毁。

如果快照不符合立即销毁的资格,则将其标记为延期删除。在此状态下,此快照作为可用的可见快照存在,直到满足上述两个先决条件时将其删除。

-d

Defer snapshot deletion.

-r

销毁后代文件系统中具有此名称的所有快照(或标记为延期删除)。

-R

以递归方式销毁所有相关项。

-s

以同步方式销毁快照。缺省行为是在命令返回到调用方之后以异步方式回收已销毁的数据集。如果指定了此选项,则在完全释放由数据集占用的块之前,控制权不会交还给调用方。

zfs destroy [share

销毁指定的文件系统共享。

zfs diff [-FHNqrte] [-o field] ... snapshot [snapshot | filesystem]
zfs diff -E [-FHNqrt] [-o field] ... snapshot | filesystem

提供快照与后代数据集之间的区别的高级说明。后代可以是数据集的快照或当前数据集。

如果指定单个快照,将提供该快照和当前数据集之间的区别。

对于已执行原始快照与后代之间的更改的每个文件,将与文件名一起说明更改的类型。如果重命名,旧名称和新名称都显示。对于在文件名中找到的空格字符、反斜杠字符及其他不可列显或非 7 位的 ASCII 字符,都显示为三位八进制表示的字节值前面的反斜杠字符。

If the -t option is specified, the first column of output from the command is the file's st_ctim value.对于已删除的文件,这是以前快照中的最终 st_ctim

更改类型遵循显示的任何时间戳并通过单字符说明:

+

指明文件是在后来的数据集内添加的。

-

指明文件是在后来的数据集内删除的。

M

指明文件是在后来的数据集内修改的。

R

指明文件是在后来的数据集内重命名的。

If the -F option is specified, the next column of output is a single character describing the type of the file.The mappings are:

F

常规文件

/

目录

B

块设备

>

Door

|

FIFO

@

符号链接

P

Event portal

=

套接字

如果修改涉及非目录文件的链接计数更改,该更改将表示为修改行中的圆括号内的增量。If the file was renamed, the old name is separated from the new with the string ->.

If the -H option is selected, easier-to-parse output is produced.Fields are separated by a single tab, and no arrow string (->) is placed between the old and new names of a rename.No guarantees are made on the spacing between fields of non -H output.

If the -e option is selected, then all files added or modified between the two snapshots are enumerated and no deleted files are displayed.无论修改是何种类型,更改类型始终报告为 +

If the -E option is selected, then differences are given as if from an empty snapshot to the specified snapshot or dataset.

If the -r option is selected, the differences between the dataset and all the children datasets are displayed recursively.如果提供快照作为参数,所有子数据集都必须存在该快照名称。否则,将为不包含该快照的数据集发出警告。If the -q option is also selected, these warnings will be silenced.

If the -N option is selected with -r, then all the new child datasets added to the current dataset will be enumerated, along with the differences among the existing datasets.

If the -o field option is selected then only selected fields are displayed.Each line starts with the standard fields requested by the -F and -t options, followed by the fields requested in successive -o options.As with the -H option, all fields are separated by a single tab.允许的字段名称包括:

object

The number printed by ls -i for the file

parent

The number printed by ls -i for enclosing directory of the file

size

The file size as displayed by ls -s

links

指向文件的链接数

linkschange

指向文件的链接数的更改

name

文件的名称

oldname

重命名之前文件的名称,或连字符 (如果文件未重命名)

user

ls 显示的文件的所有者名称

group

ls 显示的文件的组名

ctime

上一次修改文件元数据的时间戳

mtime

上一次修改文件的时间戳

atime

上一次访问文件的时间戳

crtime

创建文件的时间戳

mountpoint

显示挂载点名称。

dataset_name

显示数据集名称。

除非用户已具有 {PRIV_SYS_CONFIG}{PRIV_SYS_MOUNT} 特权,否则必须通过 zfs allow 向他们授予 diff 权限才能使用该子命令。

zfs get [-rHpe|-d max] [-o all | field[,...]] [-s source[,...]] [-I state,...] all | property[,...] filesystem|volume|snapshot|share ...

显示给定数据集的属性。如果未指定任何数据集,则该命令将显示系统中所有数据集的属性。对于每个属性,将显示以下列:

     name      Dataset name
     property  Property name
     value     Property value
     source    Property source. Can either be local, default,
               temporary, inherited, or none (-).

All columns except the RECEIVED column are displayed by default; specify particular or all columns, using the -o option.此命令接受“本机属性”和“用户属性”一节中介绍的逗号分隔的属性列表。

特殊值 all 可用于显示应用于给定数据集的类型(文件系统、卷或快照)的所有属性。

-r

递归显示任何子项的属性。

-H

以更容易被脚本解析的格式显示输出。将省略所有标题,并通过单个制表符而不是任意数量的空格显式分隔各个字段。

-p

显示可解析(确切)值中的数字。

-e

将属性子列表扩展到任意深度。

-d max

递归显示数据集的任何子项,并将递归深度限制为 depth。深度为 1 时将仅显示数据集及其直接子项。

-o field

将显示字段集。包括一个或多个:

name,property,value,received,source

以逗号分隔的列表形式显示多个字段。缺省值为:

name,property,value,source

关键字 all 指定所有资源。

-s source

将显示逗号分隔的源列表。将忽略来自此列表中的源之外的某个源的属性。每个源必须是以下源之一:

local,default,inherited,temporary,received,none

缺省值是所有源。

-I state

A comma-separated list of dataset states to display instead of the 'normal' datasets that are usually displayed.The state parameter can include the following non-normal states: receiving, resumable, hidden, or all.For instance, specifying -I resumable will display only resumable datasets.The state value 'all' will display datasets with receiving, resumable or hidden states.

zfs groupspace [-hniHp] [-o field[,...]] [-sS field]... [-t type [,...]] filesystem | snapshot

显示指定文件系统或快照中每个组占用的空间和每个组的配额。This subcommand is identical to zfs userspace, except that the default types to display are -t posixgroup,smbgroup.

-
zfs hold [-r] tag snapshot ...

向指定快照中添加通过 tag 参数命名的单个引用。每个快照都有其自己的标志名称空间,标志在该空间内必须是唯一的。

如果一个快照上存在一个保持,尝试使用 zfs destroy 命令销毁该快照将返回 EBUSY

-r

指定将具有特定标志的保持递归应用于所有后代文件系统的快照。

zfs holds [-r] snapshot ...

列出指定快照的所有现有用户引用。

-r

除了列出命名快照上的保持外,还列出在命名后代快照上设置的保持。

zfs inherit [-rS] property filesystem|volume|snapshot|share ...

清除指定的属性,以使从祖先继承该属性。如果没有祖先设置该属性,则将使用缺省值。有关缺省值的列表和可以继承的属性的详细信息,请参见“属性”一节。

-r

使所有子项递归继承给定属性。

-S

恢复为接收的属性值(如果有)。If the property does not have a received value, the behavior of zfs inherit -S is the same as zfs inherit without -S.If the property does have a received value, zfs inherit masks the received value with the inherited value until zfs inherit -S reverts to the received value.

zfs key -l | {-a | [-r] filesystem|volume}
zfs key -u [-f] | {-a | [-r] filesystem | volume
zfs key -c [-o keysource=value] {-a | [-r] filesystem|volume}
zfs key -K {-a | [-r] filesystem|volume}

有关 zfs key 语法和示例的完整说明,请参见 zfs_encrypt(8)

zfs list [-rH|-d max] [-o property[,...]] [ -t type[,...]] [-I state,...][ -s property ] ... [ -S property ] ... [filesystem|volume|snapshot|share|path] ...

以表格格式列出给定数据集的属性信息。如果已指定,可以通过绝对路径名或相对路径名列出属性信息。缺省情况下,将显示所有文件系统和卷。如果 listsnaps 属性为 on,将显示快照。缺省值为 "off"。如果 listshares 属性设置为 on,将显示共享。将显示以下字段:nameusedavailablereferencedmountpoint

-H

用于脚本模式。不输出标题并通过单个制表符而不是任意空格分隔各个字段。

-r

在命令行上递归显示数据集的任何子项。

-d depth

递归显示数据集的任何子项,并将递归最大深度限制为 depth。深度为 1 时将仅显示数据集及其直接子项。

-o property

要显示的属性的逗号分隔列表。属性必须为:

  • “本机属性”一节中介绍的属性之一

  • A user property

  • name,将显示数据集名称

  • space,将显示文件系统和卷上的空间使用情况属性。This is a shortcut for specifying -o name,avail,used,usedsnap,usedds,usedrefreserv,usedchild -t filesystem,volume syntax.

-s property

基于属性的值按列的升序对输出排序的属性。该属性必须为“属性”一节中介绍的属性之一,或者为按数据集名称排序的特殊值 name。Multiple properties can be specified at one time using multiple -s property options.Multiple -s options are evaluated from left to right in decreasing order of importance.

下面列出了排序条件:

  • 数字类型按数字顺序排序。

  • 字符串类型按字母顺序排序。

  • 不适合某行的类型会将该行排序到字面值底部,而不管指定的排序方式为何。

  • 如果未指定任何排序选项,将保留 zfs list 的现有行为。

-S property

Same as the -s option, but sorts by property in descending order.

-t type

A comma-separated list of types to display, where type is one of filesystem, snapshot, volume, share, or all.For example, specifying -t snapshot displays only snapshots.以下别名可用于替换类型说明符:fs(文件系统)、snap(快照)和 vol(卷)。

-I state

A comma-separated list of dataset states to display instead of the 'normal' datasets that are usually displayed.The state parameter can include the following non-normal states: receiving, resumable, hidden, or all.For instance, specifying -I resumable will display only resumable datasets.The state value 'all' will list all datasets in states other than the 'normal' state.

-p

使用确切的(可解析的)数字输出。

zfs mount

显示当前挂载的所有 ZFS 文件系统。

zfs mount [-vOS] [-o options] -a | filesystem

挂载 ZFS 文件系统。自动在引导过程中调用。

-o options

将临时在挂载的持续时间中使用的可选、逗号分隔的挂载选项列表。有关详细信息,请参见“临时挂载点属性”一节。

-O

执行覆盖挂载。有关更多信息,请参见 mount(8)

-v

Report mount progress.

-a

挂载所有可用的 ZFS 文件系统。自动在引导过程中调用。

filesystem

挂载指定的文件系统。

针对已加密数据集的 zfs mount 操作可能会提示您输入密钥,具体取决于 keysource 属性值。例如,如果 keysource 定位器设置为 prompt,可能会发生这种情况。

zfs promote clone-filesystem

将克隆文件系统提升为不再依赖其原始快照。这使得可以销毁创建克隆所基于的文件系统。克隆父项-子项相关性关系将被颠倒,以便原始文件系统变为指定文件系统的克隆。

所克隆的快照和此快照之前的任何快照现在都归提升的克隆所有。这些快照使用的空间将从原始文件系统转移至提升的克隆,因此必须提供足够的空间容纳这些快照。此操作不占用任何新空间,但会调整空间记帐。提升的克隆不能有与其自身的名称冲突的任何快照名称。rename 子命令可用于重命名任何冲突的快照。

zfs receive [-vnFu] [[-o property=value] | [-x property]] ... filesystem|volume|snapshot
zfs receive [-vnFu] [[-o property=value] | [-x property]] ... [-d | -e] filesystem
zfs receive -C <filesystem|volume>

创建一个快照,其内容与在标准输入中提供的流中指定的内容相同。如果接收了完整的流,那么同时会创建一个新文件系统。流使用 zfs send 子命令创建,缺省情况下通过该命令将创建完整的流。 zfs recv 可以用作 zfs receive 的别名。

如果接收增量流,则目标文件系统必须已存在,并且其最新快照必须与增量流的源匹配。For ZFS volumes, the destination device link is destroyed and re-created, which means the volume cannot be accessed during the receive operation.

When a snapshot replication package stream that is generated by using the zfs send -R command is received, any snapshots that do not exist on the sending location are destroyed by using the zfs destroy -d command.If -o property=value or -x property is specified, it applies to the effective value of the property throughout the entire subtree of replicated datasets.可以设置或继承有效属性值,具体取决于属性以及数据集是否位于复制子树中的最顶层。Received properties are retained in spite of being overridden and may be restored with zfs inherit -rS or zfs send -Rb.

The name of the snapshot (and file system, if a full stream is received) that this subcommand creates depends on the argument type and the -d or -e option.

如果参数为快照名称,则将创建指定的 snapshot。如果参数为文件系统或卷名称,则会在指定的 filesystemvolume 中创建与发送的快照名称相同的快照。If the -d or -e option is specified, the snapshot name is determined by appending the sent snapshot's name to the specified filesystem.If the -d option is specified, all but the pool name of the sent snapshot path is appended (for example, b/c@1 appended from sent snapshot a/b/c@1), and if the -e option is specified, only the tail of the sent snapshot path is appended (for example, c@1 appended from sent snapshot a/b/c@1).In the case of -d, any file systems needed to replicate the path of the sent snapshot are created within the specified file system.

-d

使用所发送快照路径中除第一个元素之外的所有元素(除池名称之外的所有内容)确定上面段落中所述的新快照的名称。

-C

将接收检查点写入 stdout。接收检查点是已接收快照的目录。

-e

使用所发送快照路径的最后一个元素确定上面段落中所述的新快照的名称。

-F

执行接收操作之前,强制将文件系统回滚到最新快照。如果接收增量复制流(例如,zfs send -R -[iI] 生成的流),则将销毁发送端不存在的快照和文件系统。

This is not allowed on mandatory retention filesystems.

-n

不实际接收该流。This can be useful in conjunction with the -v option to verify the name the receive operation would use.

请注意,ZFS 不会验证流所需的文件系统和克隆是否存在。因此,即使模拟接收已通过,实际接收也会由于未满足流依赖性而失败。

-o property=value

设置指定的属性,就好像在调用命令 zfs set property=value 的同时,从非增量 send 流创建了接收的数据集,或从增量 send 流更新了接收的数据集。也可以在接收时设置任何可编辑的 ZFS 属性。绑定到接收数据的一次性设置属性(例如 normalizationcasesensitivity)无法在接收时设置,甚至当通过 zfs receive 新创建数据集时也是如此。可以指定多个 -o 选项。An error results if the same property is specified in multiple -o or -x options.

-u

未挂载与接收流关联的文件系统。

-v

列显有关执行接收操作所需的流和时间的详细信息。

-x property

确保 receive 后的指定属性的有效值不受 send 流(如果有)中该属性的值的影响,就好像属性已从 send 流中排除一样。如果指定的属性在 send 流中不存在,则此选项不起作用。如果需要覆盖接收的属性,则可以设置或继承有效值,具体取决于属性。In the case of an incremental update, -x leaves any existing local setting or explicit inheritance unchanged (since the received property is already overridden).All -o restrictions apply equally to -x.

zfs release [-r] tag snapshot...

从指定快照中删除通过 tag 参数命名的单个引用。每个快照的标志必须已经存在。

如果一个快照上存在一个保持,尝试使用 zfs destroy 命令销毁该快照将返回 EBUSY

-r

在所有后代文件系统的快照上递归释放具有特定标志的保持。

zfs rename filesystem|volume|snapshot
filesystem|volume|snapshot
zfs rename [-p] filesystem|volume filesystem|volume

重命名给定的数据集。新目标可以位于 ZFS 分层结构中的任意位置(快照除外)。只能在父文件系统或卷中重命名快照。重命名快照时,无需将快照的父文件系统指定为第二个参数的一部分。重命名的文件系统可以继承新挂载点,在这种情况下,将卸载这些文件系统并在新挂载点重新挂载。

All child ZFS datasets must be unmounted before the parent ZFS dataset can be renamed.如果无法卸载子数据集,zfs 则会报告错误。

$ zfs rename rpool/parent rpool/renamed
cannot unmount '/rpool/child': Device busy

在这种情况下,可以使用以下方法重命名数据集:

$ zfs snapshot rpool/parent@rename
$ zfs clone rpool/parent@rename rpool/renamed
$ zfs promote rpool/renamed
$ zfs destroy rpool/parent
$ zfs destroy rpool/renamed@rename

请注意,在创建 @rename 快照后写入到 rpool/parent 的所有数据都将丢失。

不允许重命名根数据集。仅能通过重命名池来重命名根数据集,这样会将根数据集重命名为新的池名称。Use zpool export pool command and then zpool import pool newpoolname command to rename the root dataset to the new pool name.

-p

创建所有不存在的父数据集。以这种方式创建的数据集会根据从父项继承的 mountpoint 属性自动挂载。

zfs rename -r snapshot snapshot

递归重命名所有后代数据集的快照。快照是唯一可以递归重命名的数据集。

zfs rename share share

将指定共享重命名为新的共享名称。

zfs retained [-PMeuanr] [-A | -f | [-p] -o field[,...]] filesystem

Lists the files retained in the specified filesystem.

-P/-M

The -P and -M options select whether privileged (-P) or mandatory (-M) retention datasets are shown.If neither option is included, all are shown.

-e/-u

These options select whether expired (-e) or unexpired (-u) retention files are shown.If neither option is included, all are shown.

-a/-n

These options select whether automatic (-a) or non-automatic (-n) retention datasets are included.If neither option is included, all are shown.

-r

If the -r option is included, all descendent datasets with retained files are also displayed.

-A

If the -A option is included, retained files are listed including file information - mode, system attributes, crtime, mtime, ctime, rtime, uid, gid, then filename.Output fields are space-delimited with any spaces or backslashes preceded by a backslash (e.g. file "a b c" would be shown as "a\ b\ c").

-f

If the -f option is included, only the filenames are shown, with no dataset name, retention properties, or timestamps.

-p

Display the list of retained files in the pool specified using a stable machine-parseable format.有关更多信息,请参见下文的“可解析的输出格式”。

-o field[,...]

Display the specified field(s) in parseable format.Available fields are dataset, policy, automatic, mountpoint, filename, object, mode, sysattrs, size, uid, gid, crtime, mtime, ctime, rtime, and expired.

zfs rollback [-rRf] snapshot

将给定的数据集回滚到以前的快照。在回滚数据集时,将放弃自创建快照以来更改的所有数据,而且数据集会返回到创建快照时的状态。缺省情况下,该命令无法回滚到除最新快照以外的快照。In order to do so, all intermediate snapshots must be destroyed by specifying the -r option.

The -rR options do not recursively destroy the child snapshots of a recursive snapshot.这其中的任一选项仅销毁顶层递归快照。要完全回滚递归快照,必须回滚各个子快照。

Datasets with mandatory retention policy may not be rolled back.

-r

递归销毁比指定的快照更新的快照。

-R

递归销毁更新的快照以及这些快照的任何克隆快照。

-f

Used with the -R option to force an unmount of any clone file systems that are to be destroyed.

zfs send [-vbpnC] [-[Rr[c]]] [-w compress|none] [-D [-m memsize]]
[-[iI] snapshot] [-s subopt] snapshot

创建第二个 snapshot 的流表示,该快照将写入标准输出。输出可以重定向到文件或不同的系统(例如,使用 ssh(1))。缺省情况下,生成完整的流。

-b

仅发送接收的属性值,无论这些值是否将被本地设置覆盖,但仅当已接收到数据集时才发送。当希望 zfs receive 恢复在所发送数据集中备份的接收属性,并避免发送可能与源数据集没有任何关系的本地设置,但仅通过备份数据的方式时,可使用此选项。

-c

创建自包含流。自包含流不依赖于任何不包含在流软件包中的数据集。Valid with the -r and -R options.If used with the -R option and if clones are present, no snapshot preceding the clone origin will be included in the stream.If used with the -i or -I option, the stream will be dependent on the snapshot specified as an argument to the -i or -I option.

See Saving, Sending, and Receiving ZFS Data in Managing ZFS File Systems in Oracle Solaris 11.4 for details.

-C

从 stdin 读取接收检查点。接收检查点是已成功接收且无需重新发送的快照的目录。

-D

对流执行 dedup 处理。在不支持流重复数据删除功能的系统上,无法接收重复数据删除流。

See Saving, Sending, and Receiving ZFS Data in Managing ZFS File Systems in Oracle Solaris 11.4 to understand how a replication stream package differs from a recursive stream package.

-i snapshot

生成从第一个 snapshot 到第二个 snapshot 的增量流。增量源(第一个 snapshot)可以指定为快照名称的最后一部分(例如,@ 之后的部分),假设其来自于与第二个 snapshot 相同的文件系统。

如果目标是克隆,则源可以是原始快照,必须完整指定该快照(例如 pool/fs@origin,而不仅是 @origin)。

-I snapshot

生成将第一个快照中的所有中间快照发送到第二个快照的流软件包。例如,-I @a fs@d 类似于 -i @a fs@b; -i @b fs@c; -i @c fs@d。可以与 -i 选项一样指定增量源快照。

-n

不实际发送该流。This option can also be used with the -v option to see what snapshots would have been sent.

-p

Use the -p option to include properties in the send stream without the -R option.有关更多信息,请参见在 Oracle Solaris 11.4 中管理 ZFS 文件系统》中的“向 ZFS 快照流应用不同的属性值”

-R

生成复制指定文件系统和所有后代文件系统(截至指定快照)的复制流软件包。接收时,所有属性、快照、后代文件系统和克隆都将被保留。

如果将 -i-I 标志与 -R 标志结合使用,则会生成增量复制流。属性的当前值、当前快照和文件系统名称是在接收流时设置的。如果接收该流时指定了 -F 标志,则会销毁发送端不存在的快照和文件系统。

When combined with the -c option, a self-contained replication stream package is created.如果存在克隆,则克隆源之前的快照都不会包含到流中。If both the -c and -I options are used, file systems and volumes that do not have the snapshot specified with the -I option are sent as self-contained streams.

-r

生成递归流软件包。递归流软件包包含一系列完整流和/或增量流。接收后,将保留所有属性和后代文件系统。Unlike with the replication stream packages generated with the -R flag, intermediate snapshots are not preserved unless the intermediate snapshot is the origin of a clone that is included in the stream.

If the -i option is used in conjunction with the -r option, an incremental recursive stream is generated.属性的当前值、当前快照以及文件系统名称是在接收流时设置的。If the -F option is specified when this stream is received, snapshots and file systems that do not exist on the sending side are destroyed.The -I option cannot be used in conjunction with the -r option.

When combined with the -c option, a self-contained recursive stream package is created.If both the -c and -i options are used, file systems and volumes that do not have the snapshot specified with the -i option are sent as self-contained streams.

See Saving, Sending, and Receiving ZFS Data in Managing ZFS File Systems in Oracle Solaris 11.4 to understand how a recursive stream package differs from a replication stream package.

-s streamsize

The -s switch is used to specify a set of stream options that modify the format of the stream or the operation of the send command.后面的选项优先于前面的选项。任何选项的前面都可带有 'no',用于禁用选项。For example -s nocheck requests the use of a stream format without per-record checksums.

Specifies that the size of the stream, in bytes, that will be output to stderr. -v suppresses the -s streamsize option.

-s check

指定输出流将使用带有每个记录的校验和的发送流格式。此格式是系统范围的缺省值。When an interrupted transfer is resumed by using a receive checkpoint (see zfs send -C), the use of the 'check' format before the outage enables the resumed transfer to preserve and reuse the portions of the interrupted snapshot that were already successfully received.

-s nocheck

指定输出流将使用不带每个记录的校验和的传统发送流格式。此格式适用于传输到不支持新格式的早期系统。

-v

显示有关所生成流软件包的详细信息。

-w

指定 compress 参数。The compressed filesystem blocks are sent compressed in the stream, that is, without decompressing them. compress also implicitly enables the -p option, and is mutually exclusive with the -D option.

The none argument disables the compress behaviour. none is the default argument, when the -w option is not specified.

-m memsize

通过使用适当的后缀,将重复数据删除处理使用的内存量限制为以字节、千字节、兆字节或千兆字节指定的值。例如,2G、2048M、2097152K 或 2147483648。

-s memsize

指定以字节为单位的重复数据删除内存大小将输出到 stderr。If both -s streamsize and -s memsize options are specified, the values are output on successive lines in the order specified on the command line. -s option is incompatible with -v option.

将提交流的格式。您将接收到有关将来版本的 ZFS 的流。

snapshot 参数指定的快照必须存在。If the -R or -r options are used then a recursive snapshot as specified by the snapshot argument should exist and will be sent recursively.有两种特殊情况。第一种情况是,如果一个子孙文件系统树彻底丢失了相应的指定快照,则会将其跳过,并且不会将其包括在发送流中。在这种情况下,会针对跳过的每个快照输出警告消息。第二种情况是,如果一个子孙文件系统树是混合状态(即,子孙文件系统树的根丢失了所请求的快照,但它的一个或多个子文件系统具有所请求的快照),则将生成一个错误以终止发送操作。

要发送多级别文件系统的快照,用户的进程安全许可必须支配由 mlslabel 属性指定的标签。

zfs set [-r] property=value filesystem|volume|snapshot ...

对每个数据集将该属性设置为给定值。只能编辑某些属性。有关可设置哪些属性和可接受的值的更多信息,请参见“属性”一节。指定数值作为确切值,或者使用后缀 BKMGTPEZ(分别代表字节、千字节、兆字节、千兆字节、兆兆字节、千兆兆字节、艾字节和泽字节)以可读的格式指定数值。可以对快照设置用户属性。有关更多信息,请参见“用户属性”一节。

-r

在子数据集的整个子树中递归应用设置的有效值。根据属性,可以设置或继承有效值。Use the zfs help -l properties command to review whether a property is settable or inheritable.

zfs share [-u] -o property=value ... filesystem%share
zfs share filesystem|mountpoint|filesystem%share
zfs share -a | filesystem

有关 zfs share 语法和示例以及设置 share.nfsshare.smb 属性的完整说明,请参见 zfs_share(8)

zfs snapshot [-r] [-o property=value] ... filesystem@snapname|volume@snapname

以给定的名称创建快照。先前通过成功的系统调用对文件系统进行的所有修改都是快照的一部分。zfs snap 可以用作 zfs snapshot 的别名。有关详细信息,请参见“快照”一节。

-r

递归创建所有后代数据集的快照。以原子方式创建快照,以便所有递归快照与创建快照的时刻相对应。

-o property=value

设置指定的属性;有关详细信息,请参见 zfs create

zfs unallow [-rldug] everyone|user|group[,...] [perm|@setname[, ...]] filesystem|volume
zfs unallow [-rld] -e [perm|@setname [,...]] filesystem|volume
zfs unallow [-r] -c [perm|@setname[,...]]
filesystem|volume
zfs unallow [-r] -s @setname [perm|@setname[,...]]
filesystem|volume

有关 zfs unallow 语法和示例的完整说明,请参见 zfs_allow(8)

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

卸载当前挂载的 ZFS 文件系统。自动在关闭过程中调用。

-f

Forcibly unmount the file system, even if it is currently in use.

-a

卸载所有可用的 ZFS 文件系统。自动在引导过程中调用。

filesystem|mountpoint

卸载指定的文件系统。也可以为该命令指定系统上 ZFS 文件系统挂载点的路径。

对于已加密的数据集,卸载文件系统时,不会卸载密钥。要卸载密钥,请参见 zfs key

zfs unshare filesystem|mountpoint|filesystem%share
zfs unshare -a | -r filesystem

有关 zfs unshare 语法和示例的完整说明,请参见 zfs_share(8)

zfs upgrade

标识文件系统版本,这将确定当前运行的软件发行版中可用的文件系统功能。您可以继续使用旧文件系统版本,但某些功能可能不可用。A file system can be upgraded by using the zfs upgrade -a command.无法在运行早期软件版本的系统上访问更高版本的文件系统。

zfs upgrade [-v]

显示当前软件支持的 ZFS 文件系统版本。将显示当前 ZFS 文件系统版本和所有先前支持的版本,同时显示每一版本所提供功能的说明。

zfs upgrade [-r] [-V version] [-a | filesystem]

将文件系统升级到新的盘上版本。如果升级文件系统,则意味着在运行旧软件版本的系统上将不再可以访问该文件系统。无法在运行旧软件版本的系统上访问从新文件系统快照生成的 zfs send 流。

通常,文件系统版本与池版本无关。有关 zpool upgrade 命令的信息,请参见 zpool(8)

在某些情况下,文件系统版本和池版本是相互关联的,在升级文件系统版本之前,必须升级池版本。

-a

升级所有已导入池中的所有文件系统。

filesystem

升级指定的文件系统。

-r

升级指定的文件系统和所有后代文件系统。

-V version

升级到指定的 version。If the -V flag is not specified, this command upgrades to the most recent version.此选项只能用于增加版本号,最高只能增加到此软件支持的最新版本。

zfs userspace [-hniHp] [-o field[,...]] [-sS field]... [-t type [,...]] filesystem | snapshot

显示指定文件系统或快照中每个用户占用的空间和每个用户的配额。This corresponds to the userused@user and userquota@user properties.

-h

显示语法帮助消息并退出。

-n

列显数字 ID 而不是用户/组名称。

-H

不输出标题,使用制表符分隔的输出。

-p

使用确切的(可解析的)数字输出。

-o field[,...]

仅显示以下集中的指定字段:type,name,used,quota。缺省设置是显示所有字段。

-s field

按此字段对输出排序。可以多次指定 sS 标志,以先按一个字段排序,然后按另一个字段排序。The default is -s type -s name.

-S field

按此字段的相反顺序排序。See -s.

-t type[,...]

仅列显以下集中的指定类型:all,posixuser,smbuser,posixgroup,smbgroup

The default is -t posixuser,smbuser

缺省值可以更改为包含组类型。

-i

将 SID 转换为 POSIX ID。如果不存在映射,POSIX ID 可能是临时的。Normal POSIX interfaces (for example, stat(2), ls -l) perform this translation, so the -i option allows the output from zfs userspace to be compared directly with those utilities.However, -i may lead to confusion if some files were created by an SMB user before a SMB-to-POSIX name mapping was established.在这种情况下,一些文件归 SMB 实体所有,一些归 POSIX 实体所有。However, the -i option will report that the POSIX entity has the total usage and quota for both.

Parseable Output Format

The zpool retained command provides a -p option that displays output in a machine-parseable format.输出格式是一行或多行以冒号 (:) 分隔的字段。Output includes only those fields requested by means of the -o option, in the order requested.

当请求多个字段时,将在输出之前使用反斜杠 (\) 对任何文本冒号字符进行转义。类似地,也会对文本反斜杠字符进行转义 (\\)。通过使用环境变量设置为 IFS=: 的 shell read(1) 函数,可以解析此转义格式。请注意,当仅请求一个字段时,不会进行转义。

示例

示例 1 创建 ZFS 文件系统分层结构

以下命令创建名为 pool/home 的文件系统和名为 pool/home/bob 的文件系统。对父文件系统设置挂载点 /export/home,子文件系统将自动继承该挂载点。

# zfs create pool/home
# zfs set mountpoint=/export/home pool/home
# zfs create pool/home/bob
示例 2 创建 ZFS 快照

以下命令创建名为 yesterday 的快照。该快照按要求挂载在 pool/home/bob 文件系统根目录中的 .zfs/snapshot 目录下。

# zfs snapshot pool/home/bob@yesterday
示例 3 创建和销毁多个快照

以下命令为 pool/home 及其所有后代文件系统创建名为 yesterday 的快照。每个快照都按要求挂载在其文件系统根目录中的 .zfs/snapshot 目录下。第二个命令销毁新建的快照。

# zfs snapshot -r pool/home@yesterday
# zfs destroy -r pool/home@yesterday
示例 4 禁用和启用文件系统压缩

以下命令禁用 pool/home 下的所有文件系统的 compression 属性。下一个命令显式启用 pool/home/annecompression

# zfs set compression=off pool/home
# zfs set compression=on pool/home/anne
示例 5 列出 ZFS 数据集

以下命令列出所有的活动文件系统和系统中的卷。如果 listsnaps 属性为 on,将显示快照。缺省值为 "off"。如果 listshares 属性设置为 on,将显示共享。有关池属性的更多信息,请参见 zpool(8)

# zfs list
   NAME                      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
示例 6 在 ZFS 文件系统上设置配额

以下命令将 pool/home/bob 的配额设置为 30 GB。

# zfs set quota=30G pool/home/bob
示例 7 列出 ZFS 属性

以下命令列出 pool/home/bob 的所有属性。

# zfs get all pool/home/bob
NAME           PROPERTY              VALUE                  SOURCE
pool/home/bob  aclinherit            restricted             default
pool/home/bob  aclmode               discard                default
pool/home/bob  atime                 on                     default
pool/home/bob  available             30.0G                  -
pool/home/bob  canmount              on                     default
pool/home/bob  casesensitivity       mixed                  -
pool/home/bob  checksum              on                     default
pool/home/bob  compression           on                     local
pool/home/bob  compressratio         1.00x                  -
pool/home/bob  copies                1                      default
pool/home/bob  creation              Tue Jul  3 10:39 2012  -
pool/home/bob  dedup                 off                    default
pool/home/bob  devices               on                     default
pool/home/bob  encryption            off                    -
pool/home/bob  exec                  on                     default
pool/home/bob  keychangedate         -                      default
pool/home/bob  keysource             none                   default
pool/home/bob  keystatus             none                   -
pool/home/bob  logbias               latency                default
pool/home/bob  mlslabel              none                   -
pool/home/bob  mounted               yes                    -
pool/home/bob  mountpoint            /pool/home/bob         default
pool/home/bob  multilevel            off                    -
pool/home/bob  nbmand                off                    default
pool/home/bob  normalization         none                   -
pool/home/bob  primarycache          all                    default
pool/home/bob  quota                 30G                    local
pool/home/bob  readonly              off                    default
pool/home/bob  recordsize            128K                   default
pool/home/bob  referenced            31K                    -
pool/home/bob  refquota              none                   default
pool/home/bob  refreservation        none                   default
pool/home/bob  rekeydate             -                      default
pool/home/bob  reservation           none                   default
pool/home/bob  rstchown              on                     default
pool/home/bob  secondarycache        all                    default
pool/home/bob  setuid                on                     default
pool/home/bob  shadow                none                   -
pool/home/bob  share.*               ...                    inherited
pool/home/bob  snapdir               hidden                 default
pool/home/bob  sync                  standard               default
pool/home/bob  type                  filesystem             -
pool/home/bob  used                  31K                    -
pool/home/bob  usedbychildren        0                      -
pool/home/bob  usedbydataset         31K                    -
pool/home/bob  usedbyrefreservation  0                      -
pool/home/bob  usedbysnapshots       0                      -
pool/home/bob  utf8only              off                    -
pool/home/bob  version               6                      -
pool/home/bob  vscan                 off                    default
pool/home/bob  xattr                 on                     default
pool/home/bob  zoned                 off                    default

以下命令获取单个属性值。

# zfs get -H -o value compression pool/home/bob
on

以下命令列出具有 pool/home/bob 的本地设置的所有属性。

# zfs get -r -s local -o name,property,value all pool/home/bob

NAME            PROPERTY  VALUE
pool/home/bob   compression  on
pool/home/bob   quota     30G
示例 8 回滚 ZFS 文件系统

以下命令将 pool/home/anne 的内容恢复为名为 yesterday 的快照,并删除所有中间快照。

# zfs rollback -r pool/home/anne@yesterday
示例 9 创建 ZFS 克隆

以下命令创建初始内容与 pool/home/bob@yesterday 相同的可写文件系统。

# zfs clone pool/home/bob@yesterday pool/clone
示例 10 提升 ZFS 克隆

以下命令说明如何使用克隆、克隆提升及重命名检验文件系统的更改,然后将原始文件系统替换为更改的文件系统。

# zfs create pool/project/production
  populate /pool/project/production with data
# zfs snapshot pool/project/production@today
# zfs clone pool/project/production@today pool/project/beta
make changes to /pool/project/beta and test them
# zfs promote pool/project/beta
# zfs rename pool/project/production pool/project/legacy
# zfs rename pool/project/beta pool/project/production
once the legacy version is no longer needed, it can be destroyed
# zfs destroy pool/project/legacy
示例 11 Inheriting ZFS Properties

以下命令使 pool/home/bobpool/home/anne 继承其父项的 checksum 属性。

# zfs inherit checksum pool/home/bob pool/home/anne
示例 12 远程复制 ZFS 数据

以下命令将完整流和增量流依次发送到远程计算机中,以将它们分别恢复到 poolB/received/fs@apoolB/received/fs@b 中。poolB 必须包含文件系统 poolB/received,最初不能包含 poolB/received/fs

# zfs send pool/fs@a | \
   ssh host zfs receive poolB/received/fs@a
# zfs send -i a pool/fs@b | ssh host \
   zfs receive poolB/received/fs

上述语法假设 sshd 已配置为允许远程 root 访问。

示例 13 Using the zfs receive -d Option

以下命令将 poolA/fsA/fsB@snap 的完整流发送到远程计算机中,以将其接收到 poolB/received/fsA/fsB@snap 中。已接收快照的名称中的 fsA/fsB@snap 部分是基于发送快照的名称决定的。poolB 必须包含文件系统 poolB/received。如果 poolB/received/fsA 不存在,将其作为空文件系统创建。

# zfs send poolA/fsA/fsB@snap | \
   ssh host zfs receive -d poolB/received
示例 14 Setting User Properties

The following example sets the user-defined com.example:department property for a dataset.

# zfs set com.example:department=12345 tank/accounting
示例 15 执行滚动快照

以下示例显示如何通过一致的命名方案维护快照的历史信息。为保留一周的快照,用户销毁最早的快照,重命名剩余的快照,然后创建新快照,如下所示:

# zfs destroy -r pool/users@7daysago
# zfs rename -r pool/users@6daysago @7daysago
# zfs rename -r pool/users@5daysago @6daysago
# zfs rename -r pool/users@4daysago @5daysago
# zfs rename -r pool/users@3daysago @4daysago
# zfs rename -r pool/users@2daysago @3daysago
# zfs rename -r pool/users@yesterday @2daysago
# zfs rename -r pool/users@today @yesterday
# zfs snapshot -r pool/users@today
示例 16 显示 ZFS 快照的差别

The following example is output of the zfs diff -F and -t options specified:

# zfs diff -Ft myfiles@snap1
1269962501.206726811   M   /   /myfiles/
1269962444.207369955   M   F   /myfiles/link_to_me      (+1)
1269962499.207519034   R       /myfiles/rename_me -> /myfiles/renamed
1269962431.813566720   -   F   /myfiles/delete_me
1269962518.666905544   +   F   /myfiles/new_file
1269962501.393099817   +   |   /myfiles/new_pipe
示例 17 Resuming an Interrupted Send/Receive

Request that the dataset hierarchy at dst/fs on system target be made to match the source hierarchy src/fs as of the recursive snapshot @TOSNAP:

# zfs send -R src/fs@TOSNAP | \
   ssh target zfs receive -F dst/fs

If the above command is interrupted, request the transfer be resumed where it left off:

# ssh target zfs receive -C dst/fs | \
   zfs send -RC src@TOSNAP | \
   ssh target zfs receive -F dst/fs

Similarly, to request that a dataset hierarchy dst/fs on system target that already matches the source hierarchy as of recursive snapshot @FROMSNAP now be incrementally updated to match the new source recursive snapshot @TOSNAP:

# zfs send -R -I src/fs@FROMSNAP src/fs@TOSNAP | \
   ssh target zfs receive -F dst/fs

If the above incremental update is interrupted, request the transfer be resumed where it left off:

# ssh target zfs receive -C dst/fs | \
  zfs send -RC -I src/fs@FROMSNAP src/fs@TOSNAP | \
  ssh target zfs receive -F dst/fs
示例 18 Display Incomplete Datasets
# zfs list -I all tank/dest
   NAME                 USED  AVAIL  REFER  TYPE        STATE
   tank/dest/one/%now   521M   120G   521M  volume      receiving
   tank/dest/two       33.8M   120G  33.8M  filesystem  resumable
示例 19 Destroy Resumable Datasets

Resumable datasets that will never be resumed can be destroyed to release space.Care should be taken to make sure the correct datasets are listed and that the incompletely received data will never be resumed.Then the following command will remove the resumable datasets:

# zfs list -HI resumable -o name tank/dest | \
   xargs -i -n1 zfs destroy "{}"

退出状态

将返回以下退出值:

0

成功完成。

1

出现错误。

2

指定的命令行选项无效。

3

发生了致命错误。

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
system/file-system/zfs
接口稳定性
Committed(已确定)

另请参见

chmod(1), chown(1), gzip(1), pktool(1), setlabel(1), ssh(1), chmod(2), chown(2), stat(2), write(2), fsync(3C), setflabel(3TSOL), dfstab(5), vfstab(5), attributes(7), datasets(7), filesystem(7), sysattr(7), mount(8), shadowd(8), share(8), share_nfs(8), share_smb(8), unshare(8), zfs_allow(8), zfs_encrypt(8), zfs_share(8), zonecfg(8), zpool(8)

For information about other ZFS features, see zfs_allow(8), zfs_encrypt(8), zfs_share(8), and the Managing ZFS File Systems in Oracle Solaris 11.4 book.

警告

Files in filesystems with mandatory retention that are retained but the retention has not yet expired will prevent destruction of their containing filesystem.There is no privilege which will allow this to be overridden

附注

如通过 diff 子命令修改中所述的文件可能已通过多种方式进行了修改。使 st_ctim(请参见 stat(2))中发生更改的任何操作都是报告修改的基础。