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 By default the subvolumes will be sorted by subvolume ID
168 ascending.
169
170 -G [+|-]<value>
171 list subvolumes in the filesystem that its generation is
172 >=, ⟨ or = value. '+' means >= value, '-' means <= value,
173 If there is neither '+' nor '-', it means = value.
174
175 -C [+|-]<value>
176 list subvolumes in the filesystem that its ogeneration is
177 >=, <= or = value. The usage is the same to -G option.
178
179 --sort=rootid,gen,ogen,path
180 list subvolumes in order by specified items. you can add
181 '+' or '-' in front of each items, '+' means ascending, '-'
182 means descending. The default is ascending.
183
184 for --sort you can combine some items together by ',', just
185 like --sort=+ogen,-gen,path,rootid.
186
187 set-default [<subvolume>|<id> <path>]
188 Set the default subvolume for the (mounted) filesystem.
189
190 Set the default subvolume for the (mounted) filesystem at <path>.
191 This will hide the top-level subvolume (i.e. the one mounted with
192 subvol=/ or subvolid=5). Takes action on next mount.
193
194 There are two ways how to specify the subvolume, by <id> or by the
195 <subvolume> path. The id can be obtained from btrfs subvolume list,
196 btrfs subvolume show or btrfs inspect-internal rootid.
197
198 show [options] <path>
199 Show more information about subvolume <path> regarding UUIDs,
200 times, generations, flags and related snapshots.
201
202 /mnt/btrfs/subvolume
203 Name: subvolume
204 UUID: 5e076a14-4e42-254d-ac8e-55bebea982d1
205 Parent UUID: -
206 Received UUID: -
207 Creation time: 2018-01-01 12:34:56 +0000
208 Subvolume ID: 79
209 Generation: 2844
210 Gen at creation: 2844
211 Parent ID: 5
212 Top level ID: 5
213 Flags: -
214 Snapshot(s):
215
216 Options
217
218 -r|--rootid
219 rootid of the subvolume.
220
221 -u|--uuid
222 UUID of the subvolume.
223
224 snapshot [-r|-i <qgroupid>] <source> <dest>|[<dest>/]<name>
225 Create a snapshot of the subvolume <source> with the name <name> in
226 the <dest> directory.
227
228 If only <dest> is given, the subvolume will be named the basename
229 of <source>. If <source> is not a subvolume, btrfs returns an
230 error.
231
232 Options
233
234 -r
235 Make the new snapshot read only.
236
237 -i <qgroupid>
238 Add the newly created subvolume to a qgroup. This option can be
239 given multiple times.
240
241 sync <path> [subvolid...]
242 Wait until given subvolume(s) are completely removed from the
243 filesystem after deletion. If no subvolume id is given, wait until
244 all current deletion requests are completed, but do not wait for
245 subvolumes deleted in the meantime.
246
247 Options
248
249 -s <N>
250 sleep N seconds between checks (default: 1)
251
253 btrfs subvolume returns a zero exit status if it succeeds. A non-zero
254 value is returned in case of failure.
255
257 btrfs is part of btrfs-progs. Please refer to the btrfs wiki
258 http://btrfs.wiki.kernel.org for further details.
259
261 mkfs.btrfs(8), mount(8), btrfs-quota(8), btrfs-qgroup(8),
262
263
264
265Btrfs v5.4 12/03/2019 BTRFS-SUBVOLUME(8)