summaryrefslogtreecommitdiff
path: root/Documentation/btrfs-subvolume.8
blob: 76688bd2636d42625d5b70e0dd90a3694a5dcff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
'\" t
.\"     Title: btrfs-subvolume
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 12/05/2018
.\"    Manual: Btrfs Manual
.\"    Source: Btrfs v4.19.1
.\"  Language: English
.\"
.TH "BTRFS\-SUBVOLUME" "8" "12/05/2018" "Btrfs v4\&.19\&.1" "Btrfs Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
btrfs-subvolume \- manage btrfs subvolumes
.SH "SYNOPSIS"
.sp
\fBbtrfs subvolume\fR \fI<subcommand>\fR [\fI<args>\fR]
.SH "DESCRIPTION"
.sp
\fBbtrfs subvolume\fR is used to create/delete/list/show btrfs subvolumes and snapshots\&.
.SH "SUBVOLUME AND SNAPSHOT"
.sp
A subvolume is a part of filesystem with its own independent file/directory hierarchy\&. Subvolumes can share file extents\&. A snapshot is also subvolume, but with a given initial content of the original subvolume\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.sp
A subvolume in btrfs is not like an LVM logical volume, which is block\-level snapshot while btrfs subvolumes are file extent\-based\&.
.sp .5v
.RE
.sp
A subvolume looks like a normal directory, with some additional operations described below\&. Subvolumes can be renamed or moved, nesting subvolumes is not restricted but has some implications regarding snapshotting\&.
.sp
A subvolume in btrfs can be accessed in two ways:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
like any other directory that is accessible to the user
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
like a separately mounted filesystem (options
\fIsubvol\fR
or
\fIsubvolid\fR)
.RE
.sp
In the latter case the parent directory is not visible and accessible\&. This is similar to a bind mount, and in fact the subvolume mount does exactly that\&.
.sp
A freshly created filesystem is also a subvolume, called \fItop\-level\fR, internally has an id 5\&. This subvolume cannot be removed or replaced by another subvolume\&. This is also the subvolume that will be mounted by default, unless the default subvolume has been changed (see subcommand \fIset\-default\fR)\&.
.sp
A snapshot is a subvolume like any other, with given initial content\&. By default, snapshots are created read\-write\&. File modifications in a snapshot do not affect the files in the original subvolume\&.
.SH "SUBCOMMAND"
.PP
\fBcreate\fR [\-i \fI<qgroupid>\fR] [<dest>/]\fI<name>\fR
.RS 4
Create a subvolume
\fI<name>\fR
in
\fI<dest>\fR\&.
.sp
If
\fI<dest>\fR
is not given, subvolume
\fI<name>\fR
will be created in the current directory\&.
.sp
\fBOptions\fR
.PP
\-i \fI<qgroupid>\fR
.RS 4
Add the newly created subvolume to a qgroup\&. This option can be given multiple times\&.
.RE
.RE
.PP
\fBdelete\fR [options] \fI<subvolume>\fR [\fI<subvolume>\fR\&...]
.RS 4
Delete the subvolume(s) from the filesystem\&.
.sp
If
\fI<subvolume>\fR
is not a subvolume, btrfs returns an error but continues if there are more arguments to process\&.
.sp
The corresponding directory is removed instantly but the data blocks are removed later in the background\&. The command returns immediately\&. See
\fBbtrfs subvolume sync\fR
how to wait until the subvolume gets completely removed\&.
.sp
The deletion does not involve full transaction commit by default due to performance reasons\&. As a consequence, the subvolume may appear again after a crash\&. Use one of the
\fI\-\-commit\fR
options to wait until the operation is safely stored on the device\&.
.sp
\fBOptions\fR
.PP
\-c|\-\-commit\-after
.RS 4
wait for transaction commit at the end of the operation\&.
.RE
.PP
\-C|\-\-commit\-each
.RS 4
wait for transaction commit after deleting each subvolume\&.
.RE
.PP
\-v|\-\-verbose
.RS 4
verbose output of operations\&.
.RE
.RE
.PP
\fBfind\-new\fR \fI<subvolume>\fR \fI<last_gen>\fR
.RS 4
List the recently modified files in a subvolume, after
\fI<last_gen>\fR
generation\&.
.RE
.PP
\fBget\-default\fR \fI<path>\fR
.RS 4
Get the default subvolume of the filesystem
\fI<path>\fR\&.
.sp
The output format is similar to
\fBsubvolume list\fR
command\&.
.RE
.PP
\fBlist\fR [options] [\-G [+|\-]\fI<value>\fR] [\-C [+|\-]\fI<value>\fR] [\-\-sort=rootid,gen,ogen,path] \fI<path>\fR
.RS 4
List the subvolumes present in the filesystem
\fI<path>\fR\&.
.sp
For every subvolume the following information is shown by default:
.sp
ID
\fI<ID>\fR
gen
\fI<generation>\fR
top level
\fI<ID>\fR
path
\fI<path>\fR
.sp
where ID is subvolume\(cqs id, gen is an internal counter which is updated every transaction, top level is the same as parent subvolume\(cqs id, and path is the relative path of the subvolume to the top level subvolume\&. The subvolume\(cqs ID may be used by the subvolume set\-default command, or at mount time via the subvolid= option\&.
.sp
\fBOptions\fR
.PP
Path filtering
.RS 4
.PP
\-o
.RS 4
print only subvolumes below specified
\fI<path>\fR\&.
.RE
.PP
\-a
.RS 4
print all the subvolumes in the filesystem and distinguish between absolute and relative path with respect to the given
\fI<path>\fR\&.
.RE
.RE
.PP
Field selection
.RS 4
.PP
\-p
.RS 4
print the parent ID (\fIparent\fR
here means the subvolume which contains this subvolume)\&.
.RE
.PP
\-c
.RS 4
print the ogeneration of the subvolume, aliases: ogen or origin generation\&.
.RE
.PP
\-g
.RS 4
print the generation of the subvolume (default)\&.
.RE
.PP
\-u
.RS 4
print the UUID of the subvolume\&.
.RE
.PP
\-q
.RS 4
print the parent UUID of the subvolume (\fIparent\fR
here means subvolume of which this subvolume is a snapshot)\&.
.RE
.PP
\-R
.RS 4
print the UUID of the sent subvolume, where the subvolume is the result of a receive operation\&.
.RE
.RE
.PP
Type filtering
.RS 4
.PP
\-s
.RS 4
only snapshot subvolumes in the filesystem will be listed\&.
.RE
.PP
\-r
.RS 4
only readonly subvolumes in the filesystem will be listed\&.
.RE
.PP
\-d
.RS 4
list deleted subvolumes that are not yet cleaned\&.
.RE
.RE
.PP
Other
.RS 4
.PP
\-t
.RS 4
print the result as a table\&.
.RE
.RE
.PP
Sorting
.RS 4
.PP
\-G [+|\-]\fI<value>\fR
.RS 4
list subvolumes in the filesystem that its generation is >=, \(la or = value\&. \*(Aq+\*(Aq means >= value, \*(Aq\-\*(Aq means <= value, If there is neither \*(Aq+\*(Aq nor \*(Aq\-\*(Aq, it means = value\&.
.RE
.PP
\-C [+|\-]\fI<value>\fR
.RS 4
list subvolumes in the filesystem that its ogeneration is >=, <= or = value\&. The usage is the same to
\fI\-G\fR
option\&.
.RE
.PP
\-\-sort=rootid,gen,ogen,path
.RS 4
list subvolumes in order by specified items\&. you can add \*(Aq+\*(Aq or \*(Aq\-\*(Aq in front of each items, \*(Aq+\*(Aq means ascending, \*(Aq\-\*(Aq means descending\&. The default is ascending\&.
.sp
for \-\-sort you can combine some items together by \*(Aq,\*(Aq, just like \-\-sort=+ogen,\-gen,path,rootid\&.
.RE
.RE
.RE
.PP
\fBset\-default\fR [\fI<subvolume>\fR|\fI<id>\fR \fI<path>\fR]
.RS 4
Set the default subvolume for the (mounted) filesystem\&.
.sp
Set the default subvolume for the (mounted) filesystem at
\fI<path>\fR\&. This will hide the top\-level subvolume (i\&.e\&. the one mounted with
\fIsubvol=/\fR
or
\fIsubvolid=5\fR)\&. Takes action on next mount\&.
.sp
There are two ways how to specify the subvolume, by
\fI<id>\fR
or by the
\fI<subvolume>\fR
path\&. The id can be obtained from
\fBbtrfs subvolume list\fR,
\fBbtrfs subvolume show\fR
or
\fBbtrfs inspect\-internal rootid\fR\&.
.RE
.PP
\fBshow\fR [options] \fI<path>\fR|\fI<mnt>\fR
.RS 4
Show information of a given subvolume in the
\fI<path>\fR\&.
.sp
\fBOptions\fR
.PP
\-r|\-\-rootid
.RS 4
rootid of the subvolume\&.
.PP
\-u|\-\-uuid
.RS 4
UUID of the subvolume\&.
.RE
.sp
If no option is specified, subvolume information of
\fI<path>\fR
is shown, otherwise the subvolume information of rootid or UUID in the filesystem is shown\&.
.RE
.RE
.PP
\fBsnapshot\fR [\-r|\-i \fI<qgroupid>\fR] \fI<source>\fR \fI<dest>\fR|[<dest>/]\fI<name>\fR
.RS 4
Create a snapshot of the subvolume
\fI<source>\fR
with the name
\fI<name>\fR
in the
\fI<dest>\fR
directory\&.
.sp
If only
\fI<dest>\fR
is given, the subvolume will be named the basename of
\fI<source>\fR\&. If
\fI<source>\fR
is not a subvolume, btrfs returns an error\&.
.sp
\fBOptions\fR
.PP
\-r
.RS 4
Make the new snapshot read only\&.
.RE
.PP
\-i \fI<qgroupid>\fR
.RS 4
Add the newly created subvolume to a qgroup\&. This option can be given multiple times\&.
.RE
.RE
.PP
\fBsync\fR \fI<path>\fR [subvolid\&...]
.RS 4
Wait until given subvolume(s) are completely removed from the filesystem after deletion\&. If no subvolume id is given, wait until all current deletion requests are completed, but do not wait for subvolumes deleted in the meantime\&.
.sp
\fBOptions\fR
.PP
\-s \fI<N>\fR
.RS 4
sleep N seconds between checks (default: 1)
.RE
.RE
.SH "EXIT STATUS"
.sp
\fBbtrfs subvolume\fR returns a zero exit status if it succeeds\&. A non\-zero value is returned in case of failure\&.
.SH "AVAILABILITY"
.sp
\fBbtrfs\fR is part of btrfs\-progs\&. Please refer to the btrfs wiki \m[blue]\fBhttp://btrfs\&.wiki\&.kernel\&.org\fR\m[] for further details\&.
.SH "SEE ALSO"
.sp
\fBmkfs\&.btrfs\fR(8), \fBmount\fR(8), \fBbtrfs\-quota\fR(8), \fBbtrfs\-qgroup\fR(8),