btrfs-subvolume
control btrfs subvolume(s)
- Provided by: btrfs-tools (Version: 4.4-1ubuntu1.1)
- Report a bug
control btrfs subvolume(s)
btrfs subvolume <subcommand> [<args>]
btrfs subvolume is used to control the filesystem to create/delete/list/show subvolumes and snapshots.
A subvolume in btrfs is not like an LVM logical volume, which is quite independent from each other, a btrfs subvolume has its hierarchy and relations between other subvolumes.
A subvolume in btrfs can be accessed in two ways.
When accessing from the parent subvolume, the subvolume can be used just like a directory. It can have child subvolumes and its own files/directories.
When mount(8) using subvol or subvolid mount option, one can access files/directories/subvolumes inside it, but nothing in parent subvolumes.
Also every btrfs filesystem has a default subvolume as its initially top-level subvolume, whose subvolume id is 5. (0 is also acceptable as an alias.)
A btrfs snapshot is much like a subvolume, but shares its data(and metadata) with other subvolume/snapshot. Due to the capabilities of COW, modifications inside a snapshot will only show in a snapshot but not in its source subvolume.
Although in btrfs, subvolumes/snapshots are treated as directories, only subvolume/snapshot can be the source of a snapshot, snapshot can not be made from normal directories.
create [-i <qgroupid>] [<dest>]<name>
If <dest> is not given, subvolume <name> will be created in the currently directory.
Options
-i <qgroupid>
delete [options] <subvolume> [<subvolume>...]
If <subvolume> is not a subvolume, btrfs returns an error but continues if there are more arguments to process.
The corresponding directory is removed instantly but the data blocks are removed later. The deletion does not involve full 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 media.
Options
-c|--commit-after
-C|--commit-each
find-new <subvolume> <last_gen>
get-default <path>
The output format is similar to subvolume list command.
list [options] [-G [+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>
For every subvolume the following information is shown by default.
ID <ID> top level <ID> path <path> where 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. If -p is given, then parent <ID> is added to the output between ID and top level. The parent’s ID may be used at mount time via the subvolrootid= option.
Options
-p
-a
-c
-g
-o
-u
-q
-R
-t
-s
-r
-G [+|-]<value>
-C [+|-]<value>
--sort=rootid,gen,ogen,path
for --sort you can combine some items together by ',', just like -sort=+ogen,-gen,path,rootid.
set-default <id> <path>
The subvolume is identified by <id>, which is returned by the subvolume list command.
show <path>
snapshot [-r] <source> <dest>|[<dest>/]<name>
If only <dest> is given, the subvolume will be named the basename of <source>. If <source> is not a subvolume, btrfs returns an error. If -r is given, the snapshot will be readonly.
sync <path> [subvolid...]
Options
-s <N>
btrfs subvolume returns a zero exit status if it succeeds. A non-zero value is returned in case of failure.
btrfs is part of btrfs-progs. Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for further details.
mkfs.btrfs(8), btrfs-subvolume(8), btrfs-quota(8), btrfs-qgroup(8),