1BTRFS-SUBVOLUME(8) Btrfs Manual BTRFS-SUBVOLUME(8)
2
3
4
6 btrfs-subvolume - manage btrfs subvolumes
7
9 btrfs subvolume <subcommand> [<args>]
10
12 btrfs subvolume is used to create/delete/list/show btrfs subvolumes and
13 snapshots.
14
16 A subvolume is a part of filesystem with its own independent
17 file/directory hierarchy. Subvolumes can share file extents. A snapshot
18 is also subvolume, but with a given initial content of the original
19 subvolume.
20
21 Note
22 A subvolume in btrfs is not like an LVM logical volume, which is
23 block-level snapshot while btrfs subvolumes are file extent-based.
24
25 A subvolume looks like a normal directory, with some additional
26 operations described below. Subvolumes can be renamed or moved, nesting
27 subvolumes is not restricted but has some implications regarding
28 snapshotting.
29
30 A subvolume in btrfs can be accessed in two ways:
31
32 · like any other directory that is accessible to the user
33
34 · like a separately mounted filesystem (options subvol or subvolid)
35
36 In the latter case the parent directory is not visible and accessible.
37 This is similar to a bind mount, and in fact the subvolume mount does
38 exactly that.
39
40 A freshly created filesystem is also a subvolume, called top-level,
41 internally has an id 5. This subvolume cannot be removed or replaced by
42 another subvolume. This is also the subvolume that will be mounted by
43 default, unless the default subvolume has been changed (see subcommand
44 set-default).
45
46 A snapshot is a subvolume like any other, with given initial content.
47 By default, snapshots are created read-write. File modifications in a
48 snapshot do not affect the files in the original subvolume.
49
51 create [-i <qgroupid>] [<dest>/]<name>
52 Create a subvolume <name> in <dest>.
53
54 If <dest> is not given, subvolume <name> will be created in the
55 current directory.
56
57 Options
58
59 -i <qgroupid>
60 Add the newly created subvolume to a qgroup. This option can be
61 given multiple times.
62
63 delete [options] <subvolume> [<subvolume>...]
64 Delete the subvolume(s) from the filesystem.
65
66 If <subvolume> is not a subvolume, btrfs returns an error but
67 continues if there are more arguments to process.
68
69 The corresponding directory is removed instantly but the data
70 blocks are removed later in the background. The command returns
71 immediately. See btrfs subvolume sync how to wait until the
72 subvolume gets completely removed.
73
74 The deletion does not involve full transaction commit by default
75 due to performance reasons. As a consequence, the subvolume may
76 appear again after a crash. Use one of the --commit options to wait
77 until the operation is safely stored on the device.
78
79 Options
80
81 -c|--commit-after
82 wait for transaction commit at the end of the operation.
83
84 -C|--commit-each
85 wait for transaction commit after deleting each subvolume.
86
87 -v|--verbose
88 verbose output of operations.
89
90 find-new <subvolume> <last_gen>
91 List the recently modified files in a subvolume, after <last_gen>
92 generation.
93
94 get-default <path>
95 Get the default subvolume of the filesystem <path>.
96
97 The output format is similar to subvolume list command.
98
99 list [options] [-G [+|-]<value>] [-C [+|-]<value>]
100 [--sort=rootid,gen,ogen,path] <path>
101 List the subvolumes present in the filesystem <path>.
102
103 For every subvolume the following information is shown by default:
104
105 ID <ID> gen <generation> top level <ID> path <path>
106
107 where ID is subvolume’s id, gen is an internal counter which is
108 updated every transaction, top level is the same as parent
109 subvolume’s id, and path is the relative path of the subvolume to
110 the top level subvolume. The subvolume’s ID may be used by the
111 subvolume set-default command, or at mount time via the subvolid=
112 option.
113
114 Options
115
116 Path filtering
117
118 -o
119 print only subvolumes below specified <path>.
120
121 -a
122 print all the subvolumes in the filesystem and distinguish
123 between absolute and relative path with respect to the
124 given <path>.
125
126 Field selection
127
128 -p
129 print the parent ID (parent here means the subvolume which
130 contains this subvolume).
131
132 -c
133 print the ogeneration of the subvolume, aliases: ogen or
134 origin generation.
135
136 -g
137 print the generation of the subvolume (default).
138
139 -u
140 print the UUID of the subvolume.
141
142 -q
143 print the parent UUID of the subvolume (parent here means
144 subvolume of which this subvolume is a snapshot).
145
146 -R
147 print the UUID of the sent subvolume, where the subvolume
148 is the result of a receive operation.
149
150 Type filtering
151
152 -s
153 only snapshot subvolumes in the filesystem will be listed.
154
155 -r
156 only readonly subvolumes in the filesystem will be listed.
157
158 -d
159 list deleted subvolumes that are not yet cleaned.
160
161 Other
162
163 -t
164 print the result as a table.
165
166 Sorting
167
168 -G [+|-]<value>
169 list subvolumes in the filesystem that its generation is
170 >=, ⟨ or = value. '+' means >= value, '-' means <= value,
171 If there is neither '+' nor '-', it means = value.
172
173 -C [+|-]<value>
174 list subvolumes in the filesystem that its ogeneration is
175 >=, <= or = value. The usage is the same to -G option.
176
177 --sort=rootid,gen,ogen,path
178 list subvolumes in order by specified items. you can add
179 '+' or '-' in front of each items, '+' means ascending, '-'
180 means descending. The default is ascending.
181
182 for --sort you can combine some items together by ',', just
183 like --sort=+ogen,-gen,path,rootid.
184
185 set-default [<subvolume>|<id> <path>]
186 Set the default subvolume for the (mounted) filesystem.
187
188 Set the default subvolume for the (mounted) filesystem at <path>.
189 This will hide the top-level subvolume (i.e. the one mounted with
190 subvol=/ or subvolid=5). Takes action on next mount.
191
192 There are two ways how to specify the subvolume, by <id> or by the
193 <subvolume> path. The id can be obtained from btrfs subvolume list,
194 btrfs subvolume show or btrfs inspect-internal rootid.
195
196 show [options] <path>
197 Show more information about subvolume <path> regarding UUIDs,
198 times, generations, flags and related snapshots.
199
200 /mnt/btrfs/subvolume
201 Name: subvolume
202 UUID: 5e076a14-4e42-254d-ac8e-55bebea982d1
203 Parent UUID: -
204 Received UUID: -
205 Creation time: 2018-01-01 12:34:56 +0000
206 Subvolume ID: 79
207 Generation: 2844
208 Gen at creation: 2844
209 Parent ID: 5
210 Top level ID: 5
211 Flags: -
212 Snapshot(s):
213
214 Options
215
216 -r|--rootid
217 rootid of the subvolume.
218
219 -u|--uuid
220 UUID of the subvolume.
221
222 snapshot [-r|-i <qgroupid>] <source> <dest>|[<dest>/]<name>
223 Create a snapshot of the subvolume <source> with the name <name> in
224 the <dest> directory.
225
226 If only <dest> is given, the subvolume will be named the basename
227 of <source>. If <source> is not a subvolume, btrfs returns an
228 error.
229
230 Options
231
232 -r
233 Make the new snapshot read only.
234
235 -i <qgroupid>
236 Add the newly created subvolume to a qgroup. This option can be
237 given multiple times.
238
239 sync <path> [subvolid...]
240 Wait until given subvolume(s) are completely removed from the
241 filesystem after deletion. If no subvolume id is given, wait until
242 all current deletion requests are completed, but do not wait for
243 subvolumes deleted in the meantime.
244
245 Options
246
247 -s <N>
248 sleep N seconds between checks (default: 1)
249
251 btrfs subvolume returns a zero exit status if it succeeds. A non-zero
252 value is returned in case of failure.
253
255 btrfs is part of btrfs-progs. Please refer to the btrfs wiki
256 http://btrfs.wiki.kernel.org for further details.
257
259 mkfs.btrfs(8), mount(8), btrfs-quota(8), btrfs-qgroup(8),
260
261
262
263Btrfs v5.1 05/17/2019 BTRFS-SUBVOLUME(8)