btrfs-progs: doc subvolume, sort subcommands alphabetically
[platform/upstream/btrfs-progs.git] / Documentation / btrfs-subvolume.txt
1 btrfs-subvolume(8)
2 ==================
3
4 NAME
5 ----
6 btrfs-subvolume - control btrfs subvolume(s)
7
8 SYNOPSIS
9 --------
10 *btrfs subvolume* <subcommand> [<args>]
11
12 DESCRIPTION
13 -----------
14 *btrfs subvolume* is used to control the filesystem to create/delete/list/show
15 subvolumes and snapshots.
16
17 SUBVOLUME AND SNAPSHOT
18 ----------------------
19 A subvolume in btrfs is not like an LVM logical volume, which is quite
20 independent from each other, a btrfs subvolume has its hierarchy and relations
21 between other subvolumes.
22
23 A subvolume in btrfs can be accessed in two ways.
24
25 1. From the parent subvolume +
26 When accessing from the parent subvolume, the subvolume can be used just
27 like a directory. It can have child subvolumes and its own files/directories.
28
29 2. Separate mounted filesystem +
30 When `mount`(8) using 'subvol' or 'subvolid' mount option, one can access
31 files/directories/subvolumes inside it, but nothing in parent subvolumes.
32
33 Also every btrfs filesystem has a default subvolume as its initially top-level
34 subvolume, whose subvolume id is 5(FS_TREE).
35
36 A btrfs snapshot is much like a subvolume, but shares its data(and metadata)
37 with other subvolume/snapshot. Due to the capabilities of COW, modifications
38 inside a snapshot will only show in a snapshot but not in its source subvolume.
39
40 Although in btrfs, subvolumes/snapshots are treated as directories, only
41 subvolume/snapshot can be the source of a snapshot, snapshot can not be made
42 from normal directories.
43
44 SUBCOMMAND
45 -----------
46 *create* [-i <qgroupid>] [<dest>]<name>::
47 Create a subvolume <name> in <dest>.
48 +
49 If <dest> is not given, subvolume <name> will be created in the currently
50 directory.
51 +
52 `Options`
53 +
54 -i <qgroupid>::::
55 Add the newly created subvolume to a qgroup. This option can be given multiple
56 times.
57
58 *delete* [options] <subvolume> [<subvolume>...]::
59 Delete the subvolume(s) from the filesystem.
60 +
61 If <subvolume> is not a subvolume, btrfs returns an error but continues if
62 there are more arguments to process.
63 +
64 The corresponding directory is removed instantly but the data blocks are
65 removed later.  The deletion does not involve full commit by default due to
66 performance reasons (as a consequence, the subvolume may appear again after a
67 crash).  Use one of the '--commit' options to wait until the operation is safely
68 stored on the media.
69 +
70 `Options`
71 +
72 -c|--commit-after::::
73 wait for transaction commit at the end of the operation
74 +
75 -C|--commit-each::::
76 wait for transaction commit after delet each subvolume
77
78 *find-new* <subvolume> <last_gen>::
79 List the recently modified files in a subvolume, after <last_gen> ID.
80
81 *get-default* <path>::
82 Get the default subvolume of the filesystem <path>.
83 +
84 The output format is similar to *subvolume list* command.
85
86 *list* [options] [-G [\+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>::
87 List the subvolumes present in the filesystem <path>.
88 +
89 For every subvolume the following information is shown by default. +
90 ID <ID> top level <ID> path <path> +
91 where path is the relative path of the subvolume to the top level subvolume.
92 The subvolume's ID may be used by the subvolume set-default command,
93 or at mount time via the subvolid= option.
94 If `-p` is given, then parent <ID> is added to the output between ID
95 and top level. The parent's ID may be used at mount time via the
96 `subvolrootid=` option.
97 +
98 `Options`
99 +
100 -p::::
101 print parent ID.
102 -a::::
103 print all the subvolumes in the filesystem and distinguish between
104 absolute and relative path with respect to the given <path>.
105 -c::::
106 print the ogeneration of the subvolume, aliases: ogen or origin generation.
107 -g::::
108 print the generation of the subvolume.
109 -o::::
110 print only subvolumes below specified <path>.
111 -u::::
112 print the UUID of the subvolume.
113 -q::::
114 print the parent uuid of subvolumes (and snapshots).
115 -R::::
116 print the UUID of the sent subvolume, where the subvolume is the result of a receive operation
117 -t::::
118 print the result as a table.
119 -s::::
120 only snapshot subvolumes in the filesystem will be listed.
121 -r::::
122 only readonly subvolumes in the filesystem will be listed.
123 -G [+|-]<value>::::
124 list subvolumes in the filesystem that its generation is
125 >=, \<= or = value. \'\+' means >= value, \'-' means \<= value, If there is
126 neither \'+' nor \'-', it means = value.
127 -C [+|-]<value>::::
128 list subvolumes in the filesystem that its ogeneration is
129 >=, \<= or = value. The usage is the same to '-g' option.
130 --sort=rootid,gen,ogen,path::::
131 list subvolumes in order by specified items.
132 you can add \'\+' or \'-' in front of each items, \'+' means ascending,
133 \'-' means descending. The default is ascending.
134 +
135 for --sort you can combine some items together by \',', just like
136 -sort=+ogen,-gen,path,rootid.
137
138 *set-default* <id> <path>::
139 Set the subvolume of the filesystem <path> which is mounted as
140 default.
141 +
142 The subvolume is identified by <id>, which is returned by the *subvolume list*
143 command.
144
145 *show* <path>::
146 Show information of a given subvolume in the <path>.
147
148 *snapshot* [-r] <source> <dest>|[<dest>/]<name>::
149 Create a writable/readonly snapshot of the subvolume <source> with the
150 name <name> in the <dest> directory.
151 +
152 If only <dest> is given, the subvolume will be named the basename of <source>.
153 If <source> is not a subvolume, btrfs returns an error.
154 If '-r' is given, the snapshot will be readonly.
155
156 *sync* <path> [subvolid...]::
157 Wait until given subvolume(s) are completely removed from the filesystem
158 after deletion. If no subvolume id is given, wait until all ongoing deletion
159 requests are complete. This may take long if new deleted subvolumes appear
160 during the sleep interval.
161 +
162 `Options`
163 +
164 -s <N>::::
165 sleep N seconds between checks (default: 1)
166
167 EXIT STATUS
168 -----------
169 *btrfs subvolume* returns a zero exit status if it succeeds. Non zero is
170 returned in case of failure.
171
172 AVAILABILITY
173 ------------
174 *btrfs* is part of btrfs-progs.
175 Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
176 further details.
177
178 SEE ALSO
179 --------
180 `mkfs.btrfs`(8),
181 `btrfs-subvolume`(8),
182 `btrfs-quota`(8),
183 `btrfs-qgroup`(8),