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>...]], delete -i|--subvolid
64 <subvolid> <path>>
65 Delete the subvolume(s) from the filesystem.
66
67 If <subvolume> is not a subvolume, btrfs returns an error but
68 continues if there are more arguments to process.
69
70 If --subvolid is used, <path> must point to a btrfs filesystem. See
71 btrfs subvolume list or btrfs inspect-internal rootid how to get
72 the subvolume id.
73
74 The corresponding directory is removed instantly but the data
75 blocks are removed later in the background. The command returns
76 immediately. See btrfs subvolume sync how to wait until the
77 subvolume gets completely removed.
78
79 The deletion does not involve full transaction commit by default
80 due to performance reasons. As a consequence, the subvolume may
81 appear again after a crash. Use one of the --commit options to wait
82 until the operation is safely stored on the device.
83
84 The default subvolume (see btrfs subvolume set-default) cannot be
85 deleted and returns error (EPERM) and this is logged to the system
86 log. A subvolume that’s currently involved in send (see btrfs send)
87 also cannot be deleted until the send is finished. This is also
88 logged in the system log.
89
90 Options
91
92 -c|--commit-after
93 wait for transaction commit at the end of the operation.
94
95 -C|--commit-each
96 wait for transaction commit after deleting each subvolume.
97
98 -i|--subvolid <subvolid>
99 subvolume id to be removed instead of the <path> that should
100 point to the filesystem with the subvolume
101
102 -v|--verbose
103 (deprecated) alias for global -v option
104
105 find-new <subvolume> <last_gen>
106 List the recently modified files in a subvolume, after <last_gen>
107 generation.
108
109 get-default <path>
110 Get the default subvolume of the filesystem <path>.
111
112 The output format is similar to subvolume list command.
113
114 list [options] [-G [+|-]<value>] [-C [+|-]<value>]
115 [--sort=rootid,gen,ogen,path] <path>
116 List the subvolumes present in the filesystem <path>.
117
118 For every subvolume the following information is shown by default:
119
120 ID <ID> gen <generation> top level <ID> path <path>
121
122 where ID is subvolume’s id, gen is an internal counter which is
123 updated every transaction, top level is the same as parent
124 subvolume’s id, and path is the relative path of the subvolume to
125 the top level subvolume. The subvolume’s ID may be used by the
126 subvolume set-default command, or at mount time via the subvolid=
127 option.
128
129 Options
130
131 Path filtering
132
133 -o
134 print only subvolumes below specified <path>.
135
136 -a
137 print all the subvolumes in the filesystem and distinguish
138 between absolute and relative path with respect to the
139 given <path>.
140
141 Field selection
142
143 -p
144 print the parent ID (parent here means the subvolume which
145 contains this subvolume).
146
147 -c
148 print the ogeneration of the subvolume, aliases: ogen or
149 origin generation.
150
151 -g
152 print the generation of the subvolume (default).
153
154 -u
155 print the UUID of the subvolume.
156
157 -q
158 print the parent UUID of the subvolume (parent here means
159 subvolume of which this subvolume is a snapshot).
160
161 -R
162 print the UUID of the sent subvolume, where the subvolume
163 is the result of a receive operation.
164
165 Type filtering
166
167 -s
168 only snapshot subvolumes in the filesystem will be listed.
169
170 -r
171 only readonly subvolumes in the filesystem will be listed.
172
173 -d
174 list deleted subvolumes that are not yet cleaned.
175
176 Other
177
178 -t
179 print the result as a table.
180
181 Sorting
182 By default the subvolumes will be sorted by subvolume ID
183 ascending.
184
185 -G [+|-]<value>
186 list subvolumes in the filesystem that its generation is
187 >=, ⟨ or = value. '+' means >= value, '-' means <= value,
188 If there is neither '+' nor '-', it means = value.
189
190 -C [+|-]<value>
191 list subvolumes in the filesystem that its ogeneration is
192 >=, <= or = value. The usage is the same to -G option.
193
194 --sort=rootid,gen,ogen,path
195 list subvolumes in order by specified items. you can add
196 '+' or '-' in front of each items, '+' means ascending, '-'
197 means descending. The default is ascending.
198
199 for --sort you can combine some items together by ',', just
200 like --sort=+ogen,-gen,path,rootid.
201
202 set-default [<subvolume>|<id> <path>]
203 Set the default subvolume for the (mounted) filesystem.
204
205 Set the default subvolume for the (mounted) filesystem at <path>.
206 This will hide the top-level subvolume (i.e. the one mounted with
207 subvol=/ or subvolid=5). Takes action on next mount.
208
209 There are two ways how to specify the subvolume, by <id> or by the
210 <subvolume> path. The id can be obtained from btrfs subvolume list,
211 btrfs subvolume show or btrfs inspect-internal rootid.
212
213 show [options] <path>
214 Show more information about a subvolume (UUIDs, generations, times,
215 flags, related snapshots).
216
217 /mnt/btrfs/subvolume
218 Name: subvolume
219 UUID: 5e076a14-4e42-254d-ac8e-55bebea982d1
220 Parent UUID: -
221 Received UUID: -
222 Creation time: 2018-01-01 12:34:56 +0000
223 Subvolume ID: 79
224 Generation: 2844
225 Gen at creation: 2844
226 Parent ID: 5
227 Top level ID: 5
228 Flags: -
229 Snapshot(s):
230
231 Options
232
233 -r|--rootid <ID>
234 show details about subvolume with root <ID>, looked up in
235 <path>
236
237 -u|--uuid UUID
238 show details about subvolume with the given <UUID>, looked up
239 in <path>
240
241 snapshot [-r|-i <qgroupid>] <source> <dest>|[<dest>/]<name>
242 Create a snapshot of the subvolume <source> with the name <name> in
243 the <dest> directory.
244
245 If only <dest> is given, the subvolume will be named the basename
246 of <source>. If <source> is not a subvolume, btrfs returns an
247 error.
248
249 Options
250
251 -r
252 Make the new snapshot read only.
253
254 -i <qgroupid>
255 Add the newly created subvolume to a qgroup. This option can be
256 given multiple times.
257
258 sync <path> [subvolid...]
259 Wait until given subvolume(s) are completely removed from the
260 filesystem after deletion. If no subvolume id is given, wait until
261 all current deletion requests are completed, but do not wait for
262 subvolumes deleted in the meantime.
263
264 Options
265
266 -s <N>
267 sleep N seconds between checks (default: 1)
268
270 Example 1. Deleting a subvolume
271
272 If we want to delete a subvolume called foo from a btrfs volume mounted
273 at /mnt/bar we could run the following:
274
275 btrfs subvolume delete /mnt/bar/foo
276
278 btrfs subvolume returns a zero exit status if it succeeds. A non-zero
279 value is returned in case of failure.
280
282 btrfs is part of btrfs-progs. Please refer to the btrfs wiki
283 http://btrfs.wiki.kernel.org for further details.
284
286 mkfs.btrfs(8), mount(8), btrfs-quota(8), btrfs-qgroup(8),
287
288
289
290Btrfs v5.10 01/18/2021 BTRFS-SUBVOLUME(8)