btrfs-progs: docs: update btrfs-man5
[platform/upstream/btrfs-progs.git] / Documentation / btrfs-man5.asciidoc
1 btrfs-man5(5)
2 ==============
3
4 NAME
5 ----
6 btrfs-man5 - topics about the BTRFS filesystem (mount options, supported file attributes and other)
7
8 DESCRIPTION
9 -----------
10 This document describes topics related to BTRFS that are not specific to the
11 tools.  Currently covers:
12
13 1. mount options
14
15 2. file attributes
16
17 MOUNT OPTIONS
18 -------------
19
20 This section describes mount options specific to BTRFS.  For the generic mount
21 options please refer to `mount`(8) manpage. The options are sorted alphabetically
22 (discarding the 'no' prefix).
23
24 *acl*::
25 *noacl*::
26 (default: on)
27 +
28 Enable/disable support for Posix Access Control Lists (ACLs).  See the
29 `acl`(5) manual page for more information about ACLs.
30 +
31 The support for ACL is build-time configurable (BTRFS_FS_POSIX_ACL) and
32 mount fails if 'acl' is requested but the feature is not compiled in.
33
34 *alloc_start='bytes'*::
35 (default: 1M, minimum: 1M)
36 +
37 Debugging option to force all block allocations above a certain
38 byte threshold on each block device.  The value is specified in
39 bytes, optionally with a K, M, or G suffix (case insensitive).
40 +
41 This option was used for testing and has no practical use, it's slated to be
42 removed in the future.
43
44 *autodefrag*::
45 *noautodefrag*::
46 (since: 3.0, default: off)
47 +
48 Enable automatic file defragmentation.
49 When enabled, small random writes into files (in a range of tens of kilobytes,
50 currently it's 64K) are detected and queued up for the defragmentation process.
51 Not well suited for large database workloads.
52 +
53 The read latency may increase due to reading the adjacent blocks that make up the
54 range for defragmentation, successive write will merge the blocks in the new
55 location.
56 +
57 WARNING: Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as
58 well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or
59 ≥ 3.13.4 will break up the ref-links of CoW data (for example files
60 copied with `cp --reflink`, snapshots or de-duplicated data).
61 This may cause considerable increase of space usage depending on the
62 broken up ref-links.
63
64 *barrier*::
65 *nobarrier*::
66 (default: on)
67 +
68 Ensure that all IO write operations make it through the device cache and are stored
69 permanently when the filesystem is at it's consistency checkpoint. This
70 typically means that a flush command is sent to the device that will
71 synchronize all pending data and ordinary metadata blocks, then writes the
72 superblock and issues another flush.
73 +
74 The write flushes incur a slight hit and also prevent the IO block
75 scheduler to reorder requests in a more effective way. Disabling barriers gets
76 rid of that penalty but will most certainly lead to a corrupted filesystem in
77 case of a crash or power loss. The ordinary metadata blocks could be yet
78 unwritten at the time the new superblock is stored permanently, expecting that
79 the block pointers to metadata were stored permanently before.
80 +
81 On a device with a volatile battery-backed write-back cache, the 'nobarrier'
82 option will not lead to filesystem corruption as the pending blocks are
83 supposed to make it to the permanent storage.
84
85 *check_int*::
86 *check_int_data*::
87 *check_int_print_mask='value'*::
88 (since: 3.0, default: off)
89 +
90 These debugging options control the behavior of the integrity checking
91 module (the BTRFS_FS_CHECK_INTEGRITY config option required). +
92 +
93 `check_int` enables the integrity checker module, which examines all
94 block write requests to ensure on-disk consistency, at a large
95 memory and CPU cost. +
96 +
97 `check_int_data` includes extent data in the integrity checks, and
98 implies the check_int option. +
99 +
100 `check_int_print_mask` takes a bitmask of BTRFSIC_PRINT_MASK_* values
101 as defined in 'fs/btrfs/check-integrity.c', to control the integrity
102 checker module behavior. +
103 +
104 See comments at the top of 'fs/btrfs/check-integrity.c'
105 for more info.
106
107 *clear_cache*::
108 Force clearing and rebuilding of the disk space cache if something
109 has gone wrong. See also: 'space_cache'.
110
111 *commit='seconds'*::
112 (since: 3.12, default: 30)
113 +
114 Set the interval of periodic commit. Higher
115 values defer data being synced to permanent storage with obvious
116 consequences when the system crashes. The upper bound is not forced,
117 but a warning is printed if it's more than 300 seconds (5 minutes).
118
119 *compress*::
120 *compress='type'*::
121 *compress-force*::
122 *compress-force='type'*::
123 (default: off)
124 +
125 Control BTRFS file data compression.  Type may be specified as 'zlib',
126 'lzo' or 'no' (for no compression, used for remounting).  If no type
127 is specified, 'zlib' is used.  If 'compress-force' is specified,
128 all files will be compressed, whether or not they compress well. Otherwise
129 some simple heuristics are applied to detect an incompressible file. If the
130 first blocks written to a file are not compressible, the whole file is
131 permanently marked to skip compression.
132 +
133 NOTE: If compression is enabled, 'nodatacow' and 'nodatasum' are disabled.
134
135 *datacow*::
136 *nodatacow*::
137 (default: on)
138 +
139 Enable data copy-on-write for newly created files.
140 'Nodatacow' implies 'nodatasum', and disables 'compression'. All files created
141 under 'nodatacow' are also set the NOCOW file attribute (see `chattr`(1)).
142
143 *datasum*::
144 *nodatasum*::
145 (default: on)
146 +
147 Enable data checksumming for newly created files.
148 'Datasum' implies 'datacow', ie. the normal mode of operation. All files created
149 under 'nodatasum' inherit the "no checksums" property, however there's no
150 corresponding file attribute (see `chattr`(1)).
151
152 *degraded*::
153 (default: off)
154 +
155 Allow mounts with less devices than the raid profile constraints
156 require.  A read-write mount (or remount) may fail with too many devices
157 missing, for example if a stripe member is completely missing from RAID0.
158
159 *device='devicepath'*::
160 Specify a path to a device that will be scanned for BTRFS filesystem during
161 mount. This is usually done automatically by a device manager (like udev) or
162 using the *btrfs device scan* command (eg. run from the initial ramdisk). In
163 cases where this is not possible the 'device' mount option can help.
164 +
165 NOTE: booting eg. a RAID1 system may fail even if all filesystem's 'device'
166 paths are provided as the actual device nodes may not be discovered by the
167 system at that point.
168
169 *discard*::
170 *nodiscard*::
171 (default: off)
172 +
173 Enable discarding of freed file blocks using TRIM operation.  This is useful
174 for SSD devices, thinly provisioned LUNs or virtual machine images where the
175 backing device understands the operation. Depending on support of the
176 underlying device, the operation may severely hurt performance in case the TRIM
177 operation is synchronous (eg. with SATA devices up to revision 3.0).
178 +
179 If discarding is not necessary to be done at the block freeing time, there's
180 `fstrim` tool that lets the filesystem discard all free blocks in a batch,
181 possibly not much interfering with other operations. Also, the the device may
182 ignore the TRIM command if the range is too small, so running the batch discard
183 can actually discard the blocks.
184
185 *enospc_debug*::
186 *noenospc_debug*::
187 (default: off)
188 +
189 Enable verbose output for some ENOSPC conditions. It's safe to use but can
190 be noisy if the system reaches near-full state.
191
192 *fatal_errors='action'*::
193 (since: 3.4, default: bug)
194 +
195 Action to take when encountering a fatal error.
196 +
197 *bug*::::
198 'BUG()' on a fatal error, the system will stay in the crashed state and may be
199 still partially usable, but reboot is required for full operation
200 +
201 *panic*::::
202 'panic()' on a fatal error, depending on other system configuration, this may
203 be followed by a reboot. Please refer to the documentation of kernel boot
204 parameters, eg. 'panic', 'oops' or 'crashkernel'.
205
206 *flushoncommit*::
207 *noflushoncommit*::
208 (default: on)
209 +
210 This option forces any data dirtied by a write in a prior transaction to commit
211 as part of the current commit.  This makes the committed state a fully
212 consistent view of the file system from the application's perspective (i.e., it
213 includes all completed file system operations).  This was previously the
214 behavior only when a snapshot was created.
215 +
216 Disabling flushing may improve performance but is not crash-safe.
217
218 *fragment='type'*::
219 (depends on compile-time option BTRFS_DEBUG, since: 4.4, default: off)
220 +
221 A debugging helper to intentionally fragment given 'type' of block groups. The
222 type can be 'data', 'metadata' or 'all'. This mount option should not be used
223 outside of debugging environments and is not recognized if the kernel config
224 option 'BTRFS_DEBUG' is not enabled.
225
226 *inode_cache*::
227 *noinode_cache*::
228 (since: 3.0, default: off)
229 +
230 Enable free inode number caching. Not recommended to use unless files on your
231 filesystem get assigned inode numbers that are approaching 2^64^. Normally, new
232 files in each subvolume get assigned incrementally (plus one from the last
233 time) and are not reused. The mount option turns on caching of the existing
234 inode numbers and reuse of inode numbers of deleted files.
235 +
236 This option may slow down your system at first run, or after mounting without
237 the option.
238 +
239 NOTE: Defaults to off due to a potential overflow problem when the free space
240 checksums don't fit inside a single page.
241
242 *logreplay*::
243 *nologreplay*::
244 (default: on, even read-only)
245 +
246 Enable/disable log replay at mount time. See also 'treelog'.
247 +
248 WARNING: currently, the tree log is replayed even with a read-only mount! To
249 disable that behaviour, mount also with 'nologreplay'.
250
251 *max_inline='bytes'*::
252 (default: min(2048, page size) )
253 +
254 Specify the maximum amount of space, in bytes, that can be inlined in
255 a metadata B-tree leaf.  The value is specified in bytes, optionally
256 with a K suffix (case insensitive).  In practice, this value
257 is limited by the filesystem block size (named 'sectorsize' at mkfs time),
258 and memory page size of the system. In case of sectorsize limit, there's
259 some space unavailable due to leaf headers.  For example, a 4k sectorsize,
260 maximum size of inline data is about 3900 bytes.
261 +
262 Inlining can be completely turned off by specifying 0. This will increase data
263 block slack if file sizes are much smaller than block size but will reduce
264 metadata consumption in return.
265 +
266 NOTE: the default value has changed to 2048 in kernel 4.6.
267
268 *metadata_ratio='value'*::
269 (default: 0, internal logic)
270 +
271 Specifies that 1 metadata chunk should be allocated after every 'value' data
272 chunks. Default behaviour depends on internal logic, some percent of unused
273 metadata space is attempted to be maintained but is not always possible if
274 there's not enough space left for chunk allocation. The option could be useful to
275 override the internal logic in favor of the metadata allocation if the expected
276 workload is supposed to be metadata intense (snapshots, reflinks, xattrs,
277 inlined files).
278
279 *recovery*::
280 (since: 3.2, default: off, deprecated since: 4.5)
281 +
282 NOTE: this option has been replaced by 'usebackuproot' and should not be used
283 but will work on 4.5+ kernels.
284
285 *norecovery*::
286 (since: 4.5, default: off)
287 +
288 Do not attempt any data recovery at mount time. This will disable 'logreplay'
289 and avoids other write operations.
290 +
291 NOTE: The opposite option 'recovery' used to have different meaning but was
292 changed for consistency with other filesystems, where 'norecovery' is used for
293 skipping log replay. BTRFS does the same and in general will try to avoid any
294 write operations.
295
296 *rescan_uuid_tree*::
297 (since: 3.12, default: off)
298 +
299 Force check and rebuild procedure of the UUID tree. This should not
300 normally be needed.
301
302 *skip_balance*::
303 (since: 3.3, default: off)
304 +
305 Skip automatic resume of interrupted balance operation after mount.
306 May be resumed with *btrfs balance resume* or the paused state can be removed
307 by *btrfs balance cancel*. The default behaviour is to start interrutpd balance.
308
309 *space_cache*::
310 *space_cache=v2*::
311 *nospace_cache*::
312 ('nospace_cache' since: 3.2, 'space_cache=v2' since 4.5, default: on)
313 +
314 Options to control the free space cache.  This affects performance as searching
315 for new free blocks could take longer if the space cache is not enabled. On the
316 other hand, managing the space cache consumes some resources.  It can be
317 disabled without clearing at mount time.
318 +
319 There are two implementations of how the space is tracked. The safe default is
320 'v1'.  On large filesystems (many-terabytes) and certain workloads the 'v1'
321 performance may degrade.  This problem is addressed by 'v2', that is based on
322 b-trees, sometimes referred to as 'free-space-tree'.
323 +
324 'Compatibility notes:'
325 +
326 * the 'v2' has to be enabled manually at mount time, once
327 * kernel without 'v2' support will be able to mount the filesystem in read-only mode
328 * 'v2' can be removed by mounting with 'clear_cache'
329
330 *ssd*::
331 *nossd*::
332 *ssd_spread*::
333 (default: SSD autodetected)
334 +
335 Options to control SSD allocation schemes.  By default, BTRFS will
336 enable or disable SSD allocation heuristics depending on whether a
337 rotational or non-rotational disk is in use (contents of
338 '/sys/block/DEV/queue/rotational').  The 'ssd' and 'nossd' options
339 can override this autodetection.
340 +
341 The 'ssd_spread' mount option attempts to allocate into bigger and aligned
342 chunks of unused space, and may perform better on low-end SSDs.  'ssd_spread'
343 implies 'ssd', enabling all other SSD heuristics as well.
344
345 *subvol='path'*::
346 Mount subvolume from 'path' rather than the toplevel subvolume. The
347 'path' is absolute (ie. starts at the toplevel subvolume).
348 This mount option overrides the default subvolume set for the given filesystem.
349
350 *subvolid='subvolid'*::
351 Mount subvolume specified by a 'subvolid' number rather than the toplevel
352 subvolume.  You can use *btrfs subvolume list* to see subvolume ID numbers.
353 This mount option overrides the default subvolume set for the given filesystem.
354 +
355 NOTE: if both 'subvolid' and 'subvol' are specified, they must point at the
356 same subvolume, otherwise mount will fail.
357
358 *subvolrootid='objectid'*::
359 (irrelevant since: 3.2, formally deprecated since: 3.10)
360 +
361 A workaround option from times (pre 3.2) when it was not possible to mount a
362 subvolume that did not reside directly under the toplevel subvolume.
363
364 *thread_pool='number'*::
365 (default: min(NRCPUS + 2, 8) )
366 +
367 The number of worker threads to allocate. NRCPUS is number of on-line CPUs
368 detected at the time of mount. Small number leads to less parallelism in
369 processing data and metadata, higher numbers could lead to a performance hit
370 due to increased locking contention, cache-line bouncing or costly data
371 transfers between local CPU memories.
372
373 *treelog*::
374 *notreelog*::
375 (default: on)
376 +
377 Enable the tree logging used for 'fsync' and 'O_SYNC' writes. The tree log
378 stores changes without the need of a full filesystem sync. The log operations
379 are flushed at sync and transaction commit. If the system crashes between two
380 such syncs, the pending tree log operations are replayed during mount.
381 +
382 WARNING: currently, the tree log is replayed even with a read-only mount! To
383 disable that behaviour, mount also with 'nologreplay'.
384 +
385 The tree log could contain new files/directories, these would not exist on
386 a mounted filesystem if the log is not replayed.
387
388 *usebackuproot*::
389 *nousebackuproot*::
390 +
391 Enable autorecovery attempts if a bad tree root is found at mount time.
392 Currently this scans a backup list of several previous tree roots and tries to
393 use the first readable. This can be used with read-only mounts as well.
394 +
395 NOTE: This option has replaced 'recovery'.
396
397 *user_subvol_rm_allowed*::
398 (default: off)
399 +
400 Allow subvolumes to be deleted by their respective owner. Otherwise, only the
401 root user can do that.
402
403 FILE ATTRIBUTES
404 ---------------
405 The btrfs filesystem supports setting the following file attributes using the
406 `chattr`(1) utility:
407
408 *a*::
409 'append only', new writes are always written at the end of the file
410
411 *A*::
412 'no atime updates'
413
414 *c*::
415 'compress data', all data written after this attribute is set will be compressed.
416 Please note that compression is also affected by the mount options or the parent
417 directory attributes.
418 +
419 When set on a directory, all newly created files will inherit this attribute.
420
421 *C*::
422 'no copy-on-write', file modifications are done in-place
423 +
424 When set on a directory, all newly created files will inherit this attribute.
425 +
426 NOTE: due to implementation limitations, this flag can be set/unset only on
427 empty files.
428
429 *d*::
430 'no dump', makes sense with 3rd party tools like `dump`(8), on BTRFS the
431 attribute can be set/unset on no other special handling is done
432
433 *D*::
434 'synchronous directory updates', for more details search `open`(2) for 'O_SYNC'
435 and 'O_DSYNC'
436
437 *i*::
438 'immutable', no file data and metadata changes allowed even to the root user as
439 long as this attribute is set (obviously the exception is unsetting the attribute)
440
441 *S*::
442 'synchronous updates', for more details search `open`(2) for 'O_SYNC' and
443 'O_DSYNC'
444
445 *X*::
446 'no compression', permanently turn off compression on the given file, other
447 compression mount options will not affect that
448 +
449 When set on a directory, all newly created files will inherit this attribute.
450
451 No other attributes are supported.  For the complete list please refer to the
452 `chattr`(1) manual page.
453
454 SEE ALSO
455 --------
456 `acl`(5),
457 `btrfs`(8),
458 `chattr`(1),
459 `fstrim`(8),
460 `mkfs.btrfs`(8),
461 `mount`(8)