HACK: change version to work around mic bug
[platform/upstream/btrfs-progs.git] / Documentation / btrfs-subvolume.asciidoc
1 btrfs-subvolume(8)
2 ==================
3
4 NAME
5 ----
6 btrfs-subvolume - manage btrfs subvolumes
7
8 SYNOPSIS
9 --------
10 *btrfs subvolume* <subcommand> [<args>]
11
12 DESCRIPTION
13 -----------
14 *btrfs subvolume* is used to create/delete/list/show btrfs subvolumes and
15 snapshots.
16
17 SUBVOLUME AND SNAPSHOT
18 ----------------------
19
20 A subvolume is a part of filesystem with its own independent
21 file/directory hierarchy. Subvolumes can share file extents. A snapshot is
22 also subvolume, but with a given initial content of the original subvolume.
23
24 NOTE: A subvolume in btrfs is not like an LVM logical volume, which is
25 block-level snapshot while btrfs subvolumes are file extent-based.
26
27 A subvolume looks like a normal directory, with some additional operations
28 described below. Subvolumes can be renamed or moved, nesting subvolumes is not
29 restricted but has some implications regarding snapshotting.
30
31 A subvolume in btrfs can be accessed in two ways:
32
33 * like any other directory that is accessible to the user
34 * like a separately mounted filesystem (options 'subvol' or 'subvolid')
35
36 In the latter case the parent directory is not visible and accessible. This is
37 similar to a bind mount, and in fact the subvolume mount does exactly that.
38
39 A freshly created filesystem is also a subvolume, called 'top-level',
40 internally has an id 5. This subvolume cannot be removed or replaced by another
41 subvolume. This is also the subvolume that will be mounted by default, unless
42 the default subvolume has been changed (see subcommand 'set-default').
43
44 A snapshot is a subvolume like any other, with given initial content. By
45 default, snapshots are created read-write. File modifications in a snapshot
46 do not affect the files in the original subvolume.
47
48 SUBCOMMAND
49 -----------
50 *create* [-i <qgroupid>] [<dest>/]<name>::
51 Create a subvolume <name> in <dest>.
52 +
53 If <dest> is not given, subvolume <name> will be created in the current
54 directory.
55 +
56 `Options`
57 +
58 -i <qgroupid>::::
59 Add the newly created subvolume to a qgroup. This option can be given multiple
60 times.
61
62 *delete* [options] <subvolume> [<subvolume>...]::
63 Delete the subvolume(s) from the filesystem.
64 +
65 If <subvolume> is not a subvolume, btrfs returns an error but continues if
66 there are more arguments to process.
67 +
68 The corresponding directory is removed instantly but the data blocks are
69 removed later in the background. The command returns immediately. See `btrfs
70 subvolume sync` how to wait until the subvolume gets completely removed.
71 +
72 The deletion does not involve full transaction commit by default due to
73 performance reasons.  As a consequence, the subvolume may appear again after a
74 crash.  Use one of the '--commit' options to wait until the operation is
75 safely stored on the device.
76 +
77 `Options`
78 +
79 -c|--commit-after::::
80 wait for transaction commit at the end of the operation
81 +
82 -C|--commit-each::::
83 wait for transaction commit after deleting each subvolume
84
85 *find-new* <subvolume> <last_gen>::
86 List the recently modified files in a subvolume, after <last_gen> ID.
87
88 *get-default* <path>::
89 Get the default subvolume of the filesystem <path>.
90 +
91 The output format is similar to *subvolume list* command.
92
93 *list* [options] [-G [\+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>::
94 List the subvolumes present in the filesystem <path>.
95 +
96 For every subvolume the following information is shown by default. +
97 ID <ID> top level <ID> path <path> +
98 where path is the relative path of the subvolume to the top level subvolume.
99 The subvolume's ID may be used by the subvolume set-default command,
100 or at mount time via the subvolid= option.
101 If `-p` is given, then parent <ID> is added to the output between ID
102 and top level. The parent's ID may be used at mount time via the
103 `subvolrootid=` option.
104 +
105 `Options`
106 +
107 -p::::
108 print parent ID.
109 -a::::
110 print all the subvolumes in the filesystem and distinguish between
111 absolute and relative path with respect to the given <path>.
112 -c::::
113 print the ogeneration of the subvolume, aliases: ogen or origin generation.
114 -g::::
115 print the generation of the subvolume.
116 -o::::
117 print only subvolumes below specified <path>.
118 -u::::
119 print the UUID of the subvolume.
120 -q::::
121 print the parent uuid of subvolumes (and snapshots).
122 -R::::
123 print the UUID of the sent subvolume, where the subvolume is the result of a receive operation
124 -t::::
125 print the result as a table.
126 -s::::
127 only snapshot subvolumes in the filesystem will be listed.
128 -r::::
129 only readonly subvolumes in the filesystem will be listed.
130 -G [+|-]<value>::::
131 list subvolumes in the filesystem that its generation is
132 >=, \<= or = value. \'\+' means >= value, \'-' means \<= value, If there is
133 neither \'+' nor \'-', it means = value.
134 -C [+|-]<value>::::
135 list subvolumes in the filesystem that its ogeneration is
136 >=, \<= or = value. The usage is the same to '-G' option.
137 --sort=rootid,gen,ogen,path::::
138 list subvolumes in order by specified items.
139 you can add \'\+' or \'-' in front of each items, \'+' means ascending,
140 \'-' means descending. The default is ascending.
141 +
142 for --sort you can combine some items together by \',', just like
143 --sort=+ogen,-gen,path,rootid.
144
145 *set-default* [<subvolume>|<id> <path>]::
146 Set the default subvolume for the (mounted) filesystem.
147
148 Set the default subvolume for the (mounted) filesystem at <path>. This will hide
149 the top-level subvolume (ie. the one mounted with 'subvol=/' or 'subvolid=5').
150 Takes action on next mount.
151 +
152 There are two ways how to specify the subvolume, by <id> or by the <subvolume>
153 path.
154 The id can be obtained from *btrfs subvolume list*, *btrfs subvolume show* or
155 *btrfs inspect-internal rootid*.
156
157 *show* <path>::
158 Show information of a given subvolume in the <path>.
159
160 *snapshot* [-r] <source> <dest>|[<dest>/]<name>::
161 Create a snapshot of the subvolume <source> with the
162 name <name> in the <dest> directory.
163 +
164 If only <dest> is given, the subvolume will be named the basename of <source>.
165 If <source> is not a subvolume, btrfs returns an error.
166 +
167 `Options`
168 +
169 -r::::
170 Make the new snapshot read only.
171
172 *sync* <path> [subvolid...]::
173 Wait until given subvolume(s) are completely removed from the filesystem after
174 deletion. If no subvolume id is given, wait until all current deletion requests
175 are completed, but do not wait for subvolumes deleted in the meantime.
176 +
177 `Options`
178 +
179 -s <N>::::
180 sleep N seconds between checks (default: 1)
181
182 EXIT STATUS
183 -----------
184 *btrfs subvolume* returns a zero exit status if it succeeds. A non-zero value is
185 returned in case of failure.
186
187 AVAILABILITY
188 ------------
189 *btrfs* is part of btrfs-progs.
190 Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
191 further details.
192
193 SEE ALSO
194 --------
195 `mkfs.btrfs`(8),
196 `mount`(8),
197 `btrfs-quota`(8),
198 `btrfs-qgroup`(8),