btrfs-subvolume(8) btrfs 子卷(8) 

SYNOPSIS 概要 

btrfs subvolume <subcommand> [<args>]
btrfs 子卷 <子命令> [<参数>]

DESCRIPTION 描述 

btrfs subvolume is used to create/delete/list/show btrfs subvolumes and snapshots.
btrfs 子卷用于创建/删除/列出/显示 btrfs 子卷和快照。

A BTRFS subvolume is a part of filesystem with its own independent file/directory hierarchy and inode number namespace. Subvolumes can share file extents. A snapshot is also subvolume, but with a given initial content of the original subvolume. A subvolume has always inode number 256 (see more in Inode numbers (in Subvolumes)).
BTRFS 子卷是文件系统的一部分,具有独立的文件/目录层次结构和 inode 编号命名空间。子卷可以共享文件范围。快照也是子卷,但具有原始子卷的给定初始内容。子卷始终具有 inode 编号 256(请参阅子卷中的 inode 编号更多信息)。

Note 注意

A subvolume in BTRFS is not like an LVM logical volume, which is block-level snapshot while BTRFS subvolumes are file extent-based.
BTRFS 中的子卷不像 LVM 逻辑卷,后者是基于块级的快照,而 BTRFS 子卷是基于文件范围的。

A subvolume looks like a normal directory, with some additional operations described below. Subvolumes can be renamed or moved, nesting subvolumes is not restricted but has some implications regarding snapshotting. The numeric id (called subvolid or rootid) of the subvolume is persistent and cannot be changed.
子卷看起来像一个普通目录,具有下面描述的一些附加操作。子卷可以重命名或移动,嵌套子卷没有限制,但在快照方面有一些影响。子卷的数字 ID(称为 subvolid 或 rootid)是持久的,不能更改。

A subvolume in BTRFS can be accessed in two ways:
BTRFS 中的子卷可以通过两种方式访问:

  • like any other directory that is accessible to the user
    就像对用户可访问的任何其他目录一样

  • like a separately mounted filesystem (options subvol or subvolid)
    就像一个单独挂载的文件系统(选项 subvol 或 subvolid)

In the latter case the parent directory is not visible and accessible. This is similar to a bind mount, and in fact the subvolume mount does exactly that.
在后一种情况下,父目录是不可见和不可访问的。这类似于绑定挂载,事实上,子卷挂载就是这样做的。

A freshly created filesystem is also a subvolume, called top-level, internally has an id 5. This subvolume cannot be removed or replaced by another subvolume. This is also the subvolume that will be mounted by default, unless the default subvolume has been changed (see btrfs subvolume set-default).
新创建的文件系统也是一个子卷,称为顶层,内部具有 id 5。这个子卷不能被删除或替换为另一个子卷。这也是默认情况下将被挂载的子卷,除非默认子卷已更改(参见 btrfs subvolume set-default)。

A snapshot is a subvolume like any other, with given initial content. By default, snapshots are created read-write. File modifications in a snapshot do not affect the files in the original subvolume.
快照是像任何其他子卷一样具有给定初始内容的子卷。默认情况下,快照是以读写方式创建的。在快照中对文件的修改不会影响原始子卷中的文件。

Subvolumes can be given capacity limits, through the qgroups/quota facility, but otherwise share the single storage pool of the whole btrfs filesystem. They may even share data between themselves (through deduplication or snapshotting).
子卷可以通过 qgroups/quota 功能设置容量限制,但否则共享整个 btrfs 文件系统的单个存储池。它们甚至可以在彼此之间共享数据(通过去重或快照)。

Note 注意

A snapshot is not a backup: snapshots work by use of BTRFS’ copy-on-write behaviour. A snapshot and the original it was taken from initially share all of the same data blocks. If that data is damaged in some way (cosmic rays, bad disk sector, accident with dd to the disk), then the snapshot and the original will both be damaged. Snapshots are useful to have local online “copies” of the filesystem that can be referred back to, or to implement a form of deduplication, or to fix the state of a filesystem for making a full backup without anything changing underneath it. They do not in themselves make your data any safer.
快照不是备份:快照通过 BTRFS 的写时复制行为工作。快照和最初生成它的原始数据最初共享所有相同的数据块。如果数据以某种方式受损(宇宙射线、磁盘坏道、对磁盘的 dd 操作),那么快照和原始数据都将受损。快照对于拥有本地在线文件系统的“副本”以供参考,或者实现一种去重形式,或者修复文件系统的状态以进行完整备份而不会在其下面发生任何更改非常有用。它们本身并不会使您的数据更安全。

Subvolume flags 子卷标志 

The subvolume flag currently implemented is the ro property (read-only status). Read-write subvolumes have that set to false, snapshots as true. In addition to that, a plain snapshot will also have last change generation and creation generation equal.
目前实现的子卷标志是 ro 属性(只读状态)。读写子卷将其设置为 false,快照设置为 true。此外,普通快照还将具有相同的最后更改生成和创建生成。

Read-only snapshots are building blocks of incremental send (see btrfs-send(8)) and the whole use case relies on unmodified snapshots where the relative changes are generated from. Thus, changing the subvolume flags from read-only to read-write will break the assumptions and may lead to unexpected changes in the resulting incremental stream.
只读快照是增量发送的构建块(参见 btrfs-send(8)),整个用例依赖于未修改的快照,从中生成相对变化。因此,将子卷标志从只读更改为读写将打破假设,并可能导致生成的增量流中的意外更改。

A snapshot that was created by send/receive will be read-only, with different last change generation, read-only and with set received_uuid which identifies the subvolume on the filesystem that produced the stream. The use case relies on matching data on both sides. Changing the subvolume to read-write after it has been received requires to reset the received_uuid. As this is a notable change and could potentially break the incremental send use case, performing it by btrfs property set requires force if that is really desired by user.
通过发送/接收创建的快照将是只读的,具有不同的最后更改生成,只读并设置了 received_uuid,该标识在文件系统上产生流的子卷。用例依赖于双方匹配的数据。在接收后将子卷更改为读写需要重置 received_uuid。由于这是一个显着的更改,并且可能会破坏增量发送用例,如果用户确实希望执行此操作,则需要通过 btrfs property set 强制执行。

Note 注意

The safety checks have been implemented in 5.14.2, any subvolumes previously received (with a valid received_uuid) and read-write status may exist and could still lead to problems with send/receive. You can use btrfs subvolume show to identify them. Flipping the flags to read-only and back to read-write will reset the received_uuid manually. There may exist a convenience tool in the future.
安全检查已在 5.14.2 中实施,任何先前接收过的子卷(具有有效的 received_uuid)和读写状态可能仍然存在,并可能导致发送/接收问题。您可以使用 btrfs subvolume show 来识别它们。将标志翻转为只读,然后再切换为读写将手动重置 received_uuid。未来可能会存在一个方便的工具。

Nested subvolumes 嵌套子卷

There are no restrictions for subvolume creation, so it’s up to the user how to organize them, whether to have a flat layout (all subvolumes are direct descendants of the toplevel one), or nested.
对于子卷的创建没有限制,因此由用户决定如何组织它们,是采用平面布局(所有子卷都是顶层子卷的直接后代)还是嵌套布局。

What should be mentioned early is that a snapshotting is not recursive, so a subvolume or a snapshot is effectively a barrier and no files in the nested appear in the snapshot. Instead there’s a stub subvolume (also sometimes empty subvolume with the same name as original subvolume, with inode number 2). This can be used intentionally but could be confusing in case of nested layouts.
需要提前提到的是,快照不是递归的,因此子卷或快照实际上是一个屏障,嵌套中的文件不会出现在快照中。相反,会有一个存根子卷(有时也是与原始子卷同名的空子卷,inode 编号为 2)。这可以被有意使用,但在嵌套布局的情况下可能会令人困惑。

Case study: system root layouts
案例研究:系统根布局

There are two ways how the system root directory and subvolume layout could be organized. The interesting use case for root is to allow rollbacks to previous version, as one atomic step. If the entire filesystem hierarchy starting in / is in one subvolume, taking snapshot will encompass all files. This is easy for the snapshotting part but has undesirable consequences for rollback. For example, log files would get rolled back too, or any data that are stored on the root filesystem but are not meant to be rolled back either (database files, VM images, …).
系统根目录和子卷布局有两种组织方式。根的有趣用例是允许一次性回滚到以前的版本。如果从 / 开始的整个文件系统层次结构在一个子卷中,那么拍摄快照将包含所有文件。这对于快照部分来说很容易,但对于回滚来说有不良后果。例如,日志文件也会被回滚,或者存储在根文件系统上但不打算回滚的任何数据(数据库文件、VM 镜像等)。

Here we could utilize the snapshotting barrier mentioned above, each directory that stores data to be preserved across rollbacks is it’s own subvolume. This could be e.g. /var. Further more-fine grained partitioning could be done, e.g. adding separate subvolumes for /var/log, /var/cache etc.
在这里,我们可以利用上面提到的快照障碍,每个存储要在回滚中保留的数据的目录都是它自己的子卷。例如,这可以是 /var 。此外,可以进行更细粒度的分区,例如为 /var/log/var/cache 等添加单独的子卷。

That there are separate subvolumes requires separate actions to take the snapshots (here it gets disconnected from the system root snapshots). This needs to be taken care of by system tools, installers together with selection of which directories are highly recommended to be separate subvolumes.
存在单独的子卷需要单独的操作来进行快照(这里它与系统根快照断开连接)。这需要由系统工具、安装程序以及选择哪些目录强烈建议成为单独的子卷来处理。

Mount options 挂载选项

Mount options are of two kinds, generic (that are handled by VFS layer) and specific, handled by the filesystem. The following list shows which are applicable to individual subvolume mounts, while there are more options that always affect the whole filesystem:
挂载选项有两种类型,一种是通用的(由 VFS 层处理),另一种是特定的,由文件系统处理。以下列表显示了哪些适用于单个子卷挂载的选项,同时还有更多选项总是影响整个文件系统:

  • generic: noatime/relatime/…, nodev, nosuid, ro, rw, dirsync
    通用: noatime/relatime/…, nodev, nosuid, ro, rw, dirsync

  • fs-specific: compress, autodefrag, nodatacow, nodatasum
    特定于文件系统: 压缩, autodefrag, nodatacow, nodatasum

An example of whole filesystem options is e.g. space_cache, rescue, device, skip_balance, etc. The exceptional options are subvol and subvolid that are actually used for mounting a given subvolume and can be specified only once for the mount.
整个文件系统选项的一个示例是例如 space_cache, rescue, device, skip_balance 等。特殊选项是 subvol 和 subvolid,实际上用于挂载给定的子卷,并且只能为挂载指定一次。

Subvolumes belong to a single filesystem and as implemented now all share the same specific mount options, changes done by remount have immediate effect. This may change in the future.
子卷属于单个文件系统,目前实现时都共享相同的特定挂载选项,重新挂载所做的更改会立即生效。这在将来可能会发生变化。

Mounting a read-write snapshot as read-only is possible and will not change the ro property and flag of the subvolume.
将读写快照挂载为只读是可能的,并且不会更改子卷的只读属性和标志。

The name of the mounted subvolume is stored in file /proc/self/mountinfo in the 4th column:
挂载子卷的名称存储在文件 /proc/self/mountinfo 的第 4 列中:

27 21 0:19 /subv1 /mnt rw,relatime - btrfs /dev/sda rw,space_cache
           ^^^^^^

Inode numbers i 节点编号

A directory representing a subvolume has always inode number 256 (sometimes also called a root of the subvolume):
代表子卷的目录始终具有 i 节点编号 256(有时也称为子卷的根):

$ ls -lis
total 0
389111 0 drwxr-xr-x 1 user users 0 Jan 20 12:13 dir
389110 0 -rw-r--r-- 1 user users 0 Jan 20 12:13 file
   256 0 drwxr-xr-x 1 user users 0 Jan 20 12:13 snap1
   256 0 drwxr-xr-x 1 user users 0 Jan 20 12:13 subv1

If a subvolume is nested and then a snapshot is taken, then the cloned directory entry representing the subvolume becomes empty and the inode has number 2. All other files and directories in the target snapshot preserve their original inode numbers.
如果子卷被嵌套,然后拍摄快照,那么代表子卷的克隆目录条目变为空,i 节点编号为 2。目标快照中的所有其他文件和目录保留其原始 i 节点编号。

Note 注意

Inode number is not a filesystem-wide unique identifier, some applications assume that. Please use pair subvolumeid:inodenumber for that purpose. The subvolume id can be read by btrfs inspect-internal rootid or by the ioctl BTRFS_IOC_INO_LOOKUP.
Inode 编号不是文件系统范围内的唯一标识符,一些应用程序会假定它是。请使用配对的子卷 ID:inode 编号来实现此目的。子卷 ID 可以通过 btrfs inspect-internal rootid 或 ioctl BTRFS_IOC_INO_LOOKUP 读取。

Performance 性能

Subvolume creation needs to flush dirty data that belong to the subvolume, this step may take some time, otherwise once there’s nothing else to do, the snapshot is instant and in the metadata it only creates a new tree root copy.
子卷创建需要刷新属于子卷的脏数据,这一步可能需要一些时间,否则一旦没有其他事情要做,快照就会立即生成,并且在元数据中只创建一个新的树根副本。

Snapshot deletion has two phases: first its directory is deleted and the subvolume is added to a list, then the list is processed one by one and the data related to the subvolume get deleted. This is usually called cleaning and can take some time depending on the amount of shared blocks (can be a lot of metadata updates), and the number of currently queued deleted subvolumes.
快照删除有两个阶段:首先删除其目录并将子卷添加到列表,然后逐个处理列表并删除与子卷相关的数据。这通常被称为清理,根据共享块的数量(可能有大量元数据更新)和当前排队删除的子卷数量,可能需要一些时间。

SUBVOLUME AND SNAPSHOT 子卷和快照 

A subvolume is a part of filesystem with its own independent file/directory hierarchy. Subvolumes can share file extents. A snapshot is also subvolume, but with a given initial content of the original subvolume.
子卷是具有独立文件/目录层次结构的文件系统的一部分。子卷可以共享文件范围。快照也是子卷,但具有原始子卷的给定初始内容。

Note 注意

A subvolume in btrfs is not like an LVM logical volume, which is block-level snapshot while btrfs subvolumes are file extent-based.
在 btrfs 中,子卷不像 LVM 逻辑卷,后者是基于块级的快照,而 btrfs 子卷是基于文件范围的。

A subvolume looks like a normal directory, with some additional operations described below. Subvolumes can be renamed or moved, nesting subvolumes is not restricted but has some implications regarding snapshotting.
子卷看起来像一个普通目录,具有下面描述的一些额外操作。子卷可以重命名或移动,嵌套子卷没有限制,但在快照方面有一些影响。

A subvolume in btrfs can be accessed in two ways:
在 btrfs 中,子卷可以通过两种方式访问:

  • like any other directory that is accessible to the user
    就像对用户可访问的任何其他目录一样

  • like a separately mounted filesystem (options subvol or subvolid)
    就像一个单独挂载的文件系统(选项 subvol 或 subvolid)

In the latter case the parent directory is not visible and accessible. This is similar to a bind mount, and in fact the subvolume mount does exactly that.
在后一种情况下,父目录是不可见和不可访问的。这类似于绑定挂载,事实上,子卷挂载就是这样做的。

A freshly created filesystem is also a subvolume, called top-level, internally has an id 5. This subvolume cannot be removed or replaced by another subvolume. This is also the subvolume that will be mounted by default, unless the default subvolume has been changed (see subcommand set-default).
新创建的文件系统也是一个子卷,称为顶层子卷,内部具有 id 5。该子卷无法被移除或替换为另一个子卷。这也是默认挂载的子卷,除非默认子卷已更改(参见子命令 set-default)。

A snapshot is a subvolume like any other, with given initial content. By default, snapshots are created read-write. File modifications in a snapshot do not affect the files in the original subvolume.
快照是像任何其他子卷一样具有给定初始内容的子卷。默认情况下,快照是以读写方式创建的。在快照中对文件的修改不会影响原始子卷中的文件。

SUBCOMMAND 子命令 

create [options] [<dest>/]<name> [[<dest2>/]<name2> …]
create [选项] [<dest>/]<name> [[<dest2>/]<name2> …]

Create subvolume(s) at the destination(s).
在目标位置创建子卷。

If dest part of the path is not given, subvolume name will be created in the current directory.
如果未提供路径的目标部分,则子卷名称将在当前目录中创建。

If multiple destinations are given, then the given options are applied to all subvolumes.
如果给定了多个目标位置,则给定选项将应用于所有子卷。

If failure happens for any of the destinations, the command would still retry the remaining destinations, but would return 1 to indicate the failure (similar to what mkdir would do.
如果任何目的地发生失败,命令仍会重试剩余的目的地,但会返回 1 表示失败(类似于 mkdir 的行为)。

Options

-i <qgroupid>

Add the newly created subvolume to a qgroup. This option can be given multiple times.
将新创建的子卷添加到一个 qgroup 中。此选项可以多次给出。

-p|--parents

Create any missing parent directories for each argument (like mkdir -p).
为每个参数创建任何缺失的父目录(类似于 mkdir -p)。

delete [options] [<subvolume> [<subvolume>…]], delete -i|--subvolid <subvolid> <path>

Delete the subvolume(s) from the filesystem.
从文件系统中删除子卷。

If subvolume is not a subvolume, btrfs returns an error but continues if there are more arguments to process.
如果子卷不是一个子卷,btrfs 会返回一个错误,但如果还有更多的参数需要处理,它会继续执行。

If --subvolid is used, path must point to a btrfs filesystem. See btrfs subvolume list or btrfs inspect-internal rootid how to get the subvolume id.
如果使用了 --subvolid,路径必须指向一个 btrfs 文件系统。查看 btrfs subvolume list 或 btrfs inspect-internal rootid 如何获取子卷 id。

The corresponding directory is removed instantly but the data blocks are removed later in the background. The command returns immediately. See btrfs subvolume sync how to wait until the subvolume gets completely removed.
相应的目录会立即被移除,但数据块会在后台稍后被移除。该命令会立即返回。查看 btrfs subvolume sync 如何等待直到子卷完全被移除。

The deletion does not involve full transaction commit by default due to performance reasons. As a consequence, the subvolume may appear again after a crash. Use one of the --commit options to wait until the operation is safely stored on the device.
出于性能原因,默认情况下删除不涉及完整事务提交。因此,在崩溃后,子卷可能会再次出现。使用 --commit 选项之一,等待操作安全存储在设备上。

Deleting subvolume needs sufficient permissions, by default the owner cannot delete it unless it’s enabled by a mount option user_subvol_rm_allowed, or deletion is run as root. The default subvolume (see btrfs subvolume set-default) cannot be deleted and returns error (EPERM) and this is logged to the system log. A subvolume that’s currently involved in send (see btrfs-send(8)) also cannot be deleted until the send is finished. This is also logged in the system log.
删除子卷需要足够的权限,默认情况下,所有者无法删除它,除非通过挂载选项 user_subvol_rm_allowed 启用,或者以 root 用户身份运行删除操作。默认子卷(参见 btrfs subvolume set-default)无法删除,并返回错误(EPERM),并将此记录到系统日志中。当前涉及发送的子卷(参见 btrfs-send(8))在发送完成之前也无法删除。这也记录在系统日志中。

Options

-c|--commit-after

wait for transaction commit at the end of the operation.
在操作结束时等待事务提交。

-C|--commit-each

wait for transaction commit after deleting each subvolume.
在删除每个子卷后等待事务提交。

-i|--subvolid <subvolid>

subvolume id to be removed instead of the <path> that should point to the filesystem with the subvolume
要删除的子卷 ID,而不是应指向具有子卷的文件系统的<path>

-v|--verbose -v|--详细

(deprecated) alias for global -v option
(已弃用)全局 -v 选项的别名

find-new <subvolume> <last_gen>

List the recently modified files in a subvolume, after last_gen generation.
列出上一代后子卷中最近修改的文件。

get-default <path> 获取默认子卷 <path>。

Get the default subvolume of the filesystem path.
获取文件系统路径的默认子卷。

The output format is similar to subvolume list command.
输出格式类似于子卷列表命令。

list [options] [-G [+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>
列出 [选项] [-G [+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>

List the subvolumes present in the filesystem path.
列出文件系统路径中存在的子卷。

For every subvolume the following information is shown by default:
对于每个子卷,默认显示以下信息:

ID ID gen generation top level parent_ID path path
ID ID gen 代数 顶级 parent_ID 路径 路径

where ID is subvolume’s (root)id, generation is an internal counter which is updated every transaction, parent_ID is the same as the parent subvolume’s id, and path is the relative path of the subvolume to the top level subvolume. The subvolume’s ID may be used by the subvolume set-default command, or at mount time via the subvolid= option.
其中 ID 是子卷(根)的 id,代数是一个内部计数器,每个事务都会更新,parent_ID 与父子卷的 id 相同,path 是子卷相对于顶级子卷的相对路径。子卷的 ID 可能会被子卷 set-default 命令使用,或者在挂载时通过 subvolid= 选项使用。

Options

Path filtering: 路径过滤:

-o

Print only subvolumes below specified <path>. Note that this is not a recursive command, and won’t show nested subvolumes under <path>.
仅打印指定<path>下的子卷。请注意,这不是一个递归命令,不会显示<path>下的嵌套子卷。

-a

print all the subvolumes in the filesystem and distinguish between absolute and relative path with respect to the given path.
打印文件系统中的所有子卷,并根据给定路径区分绝对路径和相对路径。

Field selection: 字段选择:

-p

print the parent ID (parent here means the subvolume which contains this subvolume).
打印父 ID(这里的父代表包含此子卷的子卷)。

-c

print the ogeneration of the subvolume, aliases: ogen or origin generation.
打印子卷的 ogeneration,别名:ogen 或 origin generation。

-g

print the generation of the subvolume (default).
打印子卷的生成(默认)。

-u

print the UUID of the subvolume.
打印子卷的 UUID。

-q

print the parent UUID of the subvolume (parent here means subvolume of which this subvolume is a snapshot).
打印子卷的父 UUID(这里的父代表这个子卷是哪个子卷的快照)。

-R

print the UUID of the sent subvolume, where the subvolume is the result of a receive operation.
打印发送子卷的 UUID,其中子卷是接收操作的结果。

Type filtering: 类型过滤:

-s

only snapshot subvolumes in the filesystem will be listed.
仅列出文件系统中的快照子卷。

-r

only readonly subvolumes in the filesystem will be listed.
只会列出文件系统中的只读子卷。

-d

list deleted subvolumes that are not yet cleaned.
列出尚未清理的已删除子卷。

Other: 其他:

-t

print the result as a table.
将结果打印为表格。

Sorting: 排序:

By default the subvolumes will be sorted by subvolume ID ascending.
默认情况下,子卷将按照子卷 ID 升序排序。

-G [+|-]<value>

list subvolumes in the filesystem that its generation is >=, <= or = value. '+’ means >= value, '-’ means <= value, If there is neither '+’ nor '-’, it means = value.
列出文件系统中其生成代数大于等于、小于等于或等于指定值的子卷。'+’ 表示大于等于指定值,'-' 表示小于等于指定值,如果既没有 '+' 也没有 '-',则表示等于指定值。

-C [+|-]<value>

list subvolumes in the filesystem that its ogeneration is >=, <= or = value. The usage is the same to -G option.
列出文件系统中其生成代数大于等于、小于等于或等于指定值的子卷。用法与 -G 选项相同。

--sort=rootid,gen,ogen,path

list subvolumes in order by specified items. you can add + or - in front of each items, + means ascending, - means descending. The default is ascending.
按指定项目顺序列出子卷。您可以在每个项目前面添加 + 或 -,+ 表示升序,- 表示降序。默认为升序。

for --sort you can combine some items together by ,, just like --sort=+ogen,-gen,path,rootid.
对于 --sort,您可以通过,,将一些项目组合在一起,就像 --sort=+ogen,-gen,path,rootid。

set-default [<subvolume>|<id> <path>]
设置默认子卷[<子卷>|<ID> <路径>]

Set the default subvolume for the (mounted) filesystem.
为(已挂载的)文件系统设置默认子卷。

Set the default subvolume for the (mounted) filesystem at path. This will hide the top-level subvolume (i.e. the one mounted with subvol=/ or subvolid=5). Takes action on next mount.
为路径上(已挂载的)文件系统设置默认子卷。这将隐藏顶层子卷(即使用 subvol=/ 或 subvolid=5 挂载的子卷)。在下次挂载时生效。

There are two ways how to specify the subvolume, by id or by the subvolume path. The id can be obtained from btrfs subvolume list btrfs subvolume show or btrfs inspect-internal rootid.
有两种指定子卷的方式,可以通过 ID 或者子卷路径。ID 可以从 btrfs subvolume list、btrfs subvolume show 或者 btrfs inspect-internal rootid 获取。

show [options] <path> 显示 [选项] <路径>

Show more information about a subvolume (UUIDs, generations, times, flags, related snapshots).
显示有关子卷的更多信息(UUID、生成、时间、标志、相关快照)。

/mnt/btrfs/subvolume
        Name:                   subvolume
        UUID:                   5e076a14-4e42-254d-ac8e-55bebea982d1
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2018-01-01 12:34:56 +0000
        Subvolume ID:           79
        Generation:             2844
        Gen at creation:        2844
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Snapshot(s):

Options

-r|--rootid <ID>

show details about subvolume with root ID, looked up in path
显示具有根 ID 的子卷的详细信息,在路径中查找

-u|--uuid UUID

show details about subvolume with the given UUID, looked up in path
显示具有给定 UUID 的子卷的详细信息,在路径中查找

snapshot [-r] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>
快照 [-r] [-i <qgroupid>] <源> <目标>|[<目标>/]<名称>

Create a snapshot of the subvolume source with the name name in the dest directory.
在目标目录中使用名称为名称的快照创建源子卷的快照。

If only dest is given, the subvolume will be named the basename of source. If source is not a subvolume, btrfs returns an error.
如果只提供目标,则子卷将被命名为源的基本名称。如果源不是子卷,则 btrfs 会返回错误。

Options

-r

Make the new snapshot read only.
将新快照设置为只读。

-i <qgroupid>

Add the newly created subvolume to a qgroup. This option can be given multiple times.
将新创建的子卷添加到一个 qgroup 中。此选项可以多次给出。

sync <path> [subvolid…] 同步 <路径> [子卷 ID…]

Wait until given subvolume(s) are completely removed from the filesystem after deletion. If no subvolume id is given, wait until all current deletion requests are completed, but do not wait for subvolumes deleted in the meantime.
等待给定的子卷在删除后完全从文件系统中移除。如果没有给定子卷 ID,则等待直到所有当前的删除请求完成,但不等待其间删除的子卷。

If the filesystem status changes to read-only then the waiting is interrupted.
如果文件系统状态变为只读,则等待将被中断。

Options

-s <N>

sleep N seconds between checks (default: 1)
在检查之间休眠 N 秒(默认值为 1)。

EXAMPLES 示例

Deleting a subvolume 删除子卷 

If we want to delete a subvolume called foo from a btrfs volume mounted at /mnt/bar we could run the following:
如果我们想要从挂载在 /mnt/bar 的 btrfs 卷中删除名为 foo 的子卷,我们可以运行以下命令:

btrfs subvolume delete /mnt/bar/foo

EXIT STATUS 退出状态 

btrfs subvolume returns a zero exit status if it succeeds. A non-zero value is returned in case of failure.
如果成功,btrfs 子卷将返回零退出状态。如果失败,则返回非零值。

AVAILABILITY 可用性 

btrfs is part of btrfs-progs. Please refer to the documentation at https://btrfs.readthedocs.io.
btrfs 是 btrfs-progs 的一部分。请参考 https://btrfs.readthedocs.io 上的文档。

SEE ALSO 参见 

btrfs-qgroup(8), btrfs-quota(8), btrfs-send(8), mkfs.btrfs(8), mount(8)