btrfs-progs: docs: fix many typos, plus three edits for clarity
[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. filesystem features
16
17 3. file attributes
18
19 4. control device
20
21
22 MOUNT OPTIONS
23 -------------
24
25 This section describes mount options specific to BTRFS.  For the generic mount
26 options please refer to `mount`(8) manpage. The options are sorted alphabetically
27 (discarding the 'no' prefix).
28
29 *acl*::
30 *noacl*::
31 (default: on)
32 +
33 Enable/disable support for Posix Access Control Lists (ACLs).  See the
34 `acl`(5) manual page for more information about ACLs.
35 +
36 The support for ACL is build-time configurable (BTRFS_FS_POSIX_ACL) and
37 mount fails if 'acl' is requested but the feature is not compiled in.
38
39 *alloc_start='bytes'*::
40 (default: 1M, minimum: 1M)
41 +
42 Debugging option to force all block allocations above a certain
43 byte threshold on each block device.  The value is specified in
44 bytes, optionally with a K, M, or G suffix (case insensitive).
45 +
46 This option was used for testing and has no practical use, it's slated to be
47 removed in the future.
48
49 *autodefrag*::
50 *noautodefrag*::
51 (since: 3.0, default: off)
52 +
53 Enable automatic file defragmentation.
54 When enabled, small random writes into files (in a range of tens of kilobytes,
55 currently it's 64K) are detected and queued up for the defragmentation process.
56 Not well suited for large database workloads.
57 +
58 The read latency may increase due to reading the adjacent blocks that make up the
59 range for defragmentation, successive write will merge the blocks in the new
60 location.
61 +
62 WARNING: Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as
63 well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or
64 ≥ 3.13.4 will break up the ref-links of CoW data (for example files
65 copied with `cp --reflink`, snapshots or de-duplicated data).
66 This may cause considerable increase of space usage depending on the
67 broken up ref-links.
68
69 *barrier*::
70 *nobarrier*::
71 (default: on)
72 +
73 Ensure that all IO write operations make it through the device cache and are stored
74 permanently when the filesystem is at it's consistency checkpoint. This
75 typically means that a flush command is sent to the device that will
76 synchronize all pending data and ordinary metadata blocks, then writes the
77 superblock and issues another flush.
78 +
79 The write flushes incur a slight hit and also prevent the IO block
80 scheduler to reorder requests in a more effective way. Disabling barriers gets
81 rid of that penalty but will most certainly lead to a corrupted filesystem in
82 case of a crash or power loss. The ordinary metadata blocks could be yet
83 unwritten at the time the new superblock is stored permanently, expecting that
84 the block pointers to metadata were stored permanently before.
85 +
86 On a device with a volatile battery-backed write-back cache, the 'nobarrier'
87 option will not lead to filesystem corruption as the pending blocks are
88 supposed to make it to the permanent storage.
89
90 *check_int*::
91 *check_int_data*::
92 *check_int_print_mask='value'*::
93 (since: 3.0, default: off)
94 +
95 These debugging options control the behavior of the integrity checking
96 module (the BTRFS_FS_CHECK_INTEGRITY config option required). +
97 +
98 `check_int` enables the integrity checker module, which examines all
99 block write requests to ensure on-disk consistency, at a large
100 memory and CPU cost. +
101 +
102 `check_int_data` includes extent data in the integrity checks, and
103 implies the check_int option. +
104 +
105 `check_int_print_mask` takes a bitmask of BTRFSIC_PRINT_MASK_* values
106 as defined in 'fs/btrfs/check-integrity.c', to control the integrity
107 checker module behavior. +
108 +
109 See comments at the top of 'fs/btrfs/check-integrity.c'
110 for more info.
111
112 *clear_cache*::
113 Force clearing and rebuilding of the disk space cache if something
114 has gone wrong. See also: 'space_cache'.
115
116 *commit='seconds'*::
117 (since: 3.12, default: 30)
118 +
119 Set the interval of periodic commit. Higher
120 values defer data being synced to permanent storage with obvious
121 consequences when the system crashes. The upper bound is not forced,
122 but a warning is printed if it's more than 300 seconds (5 minutes).
123
124 *compress*::
125 *compress='type'*::
126 *compress-force*::
127 *compress-force='type'*::
128 (default: off)
129 +
130 Control BTRFS file data compression.  Type may be specified as 'zlib',
131 'lzo' or 'no' (for no compression, used for remounting).  If no type
132 is specified, 'zlib' is used.  If 'compress-force' is specified,
133 all files will be compressed, whether or not they compress well. Otherwise
134 some simple heuristics are applied to detect an incompressible file. If the
135 first blocks written to a file are not compressible, the whole file is
136 permanently marked to skip compression.
137 +
138 NOTE: If compression is enabled, 'nodatacow' and 'nodatasum' are disabled.
139
140 *datacow*::
141 *nodatacow*::
142 (default: on)
143 +
144 Enable data copy-on-write for newly created files.
145 'Nodatacow' implies 'nodatasum', and disables 'compression'. All files created
146 under 'nodatacow' are also set the NOCOW file attribute (see `chattr`(1)).
147 +
148 NOTE: If 'nodatacow' or 'nodatasum' are enabled, compression is disabled.
149
150 *datasum*::
151 *nodatasum*::
152 (default: on)
153 +
154 Enable data checksumming for newly created files.
155 'Datasum' implies 'datacow', ie. the normal mode of operation. All files created
156 under 'nodatasum' inherit the "no checksums" property, however there's no
157 corresponding file attribute (see `chattr`(1)).
158 +
159 NOTE: If 'nodatacow' or 'nodatasum' are enabled, compression is disabled.
160
161 *degraded*::
162 (default: off)
163 +
164 Allow mounts with less devices than the raid profile constraints
165 require.  A read-write mount (or remount) may fail with too many devices
166 missing, for example if a stripe member is completely missing from RAID0.
167
168 *device='devicepath'*::
169 Specify a path to a device that will be scanned for BTRFS filesystem during
170 mount. This is usually done automatically by a device manager (like udev) or
171 using the *btrfs device scan* command (eg. run from the initial ramdisk). In
172 cases where this is not possible the 'device' mount option can help.
173 +
174 NOTE: booting eg. a RAID1 system may fail even if all filesystem's 'device'
175 paths are provided as the actual device nodes may not be discovered by the
176 system at that point.
177
178 *discard*::
179 *nodiscard*::
180 (default: off)
181 +
182 Enable discarding of freed file blocks using TRIM operation.  This is useful
183 for SSD devices, thinly provisioned LUNs or virtual machine images where the
184 backing device understands the operation. Depending on support of the
185 underlying device, the operation may severely hurt performance in case the TRIM
186 operation is synchronous (eg. with SATA devices up to revision 3.0).
187 +
188 If discarding is not necessary to be done at the block freeing time, there's
189 `fstrim` tool that lets the filesystem discard all free blocks in a batch,
190 possibly not much interfering with other operations. Also, the the device may
191 ignore the TRIM command if the range is too small, so running the batch discard
192 can actually discard the blocks.
193
194 *enospc_debug*::
195 *noenospc_debug*::
196 (default: off)
197 +
198 Enable verbose output for some ENOSPC conditions. It's safe to use but can
199 be noisy if the system reaches near-full state.
200
201 *fatal_errors='action'*::
202 (since: 3.4, default: bug)
203 +
204 Action to take when encountering a fatal error.
205 +
206 *bug*::::
207 'BUG()' on a fatal error, the system will stay in the crashed state and may be
208 still partially usable, but reboot is required for full operation
209 +
210 *panic*::::
211 'panic()' on a fatal error, depending on other system configuration, this may
212 be followed by a reboot. Please refer to the documentation of kernel boot
213 parameters, eg. 'panic', 'oops' or 'crashkernel'.
214
215 *flushoncommit*::
216 *noflushoncommit*::
217 (default: off)
218 +
219 This option forces any data dirtied by a write in a prior transaction to commit
220 as part of the current commit, effectively a full filesystem sync.
221 +
222 This makes the committed state a fully consistent view of the file system from
223 the application's perspective (i.e., it includes all completed file system
224 operations). This was previously the behavior only when a snapshot was
225 created.
226 +
227 When off, the filesystem is consistent but buffered writes may last more than
228 one transaction commit.
229
230 *fragment='type'*::
231 (depends on compile-time option BTRFS_DEBUG, since: 4.4, default: off)
232 +
233 A debugging helper to intentionally fragment given 'type' of block groups. The
234 type can be 'data', 'metadata' or 'all'. This mount option should not be used
235 outside of debugging environments and is not recognized if the kernel config
236 option 'BTRFS_DEBUG' is not enabled.
237
238 *inode_cache*::
239 *noinode_cache*::
240 (since: 3.0, default: off)
241 +
242 Enable free inode number caching. Not recommended to use unless files on your
243 filesystem get assigned inode numbers that are approaching 2^64^. Normally, new
244 files in each subvolume get assigned incrementally (plus one from the last
245 time) and are not reused. The mount option turns on caching of the existing
246 inode numbers and reuse of inode numbers of deleted files.
247 +
248 This option may slow down your system at first run, or after mounting without
249 the option.
250 +
251 NOTE: Defaults to off due to a potential overflow problem when the free space
252 checksums don't fit inside a single page.
253
254 *logreplay*::
255 *nologreplay*::
256 (default: on, even read-only)
257 +
258 Enable/disable log replay at mount time. See also 'treelog'.
259 +
260 WARNING: currently, the tree log is replayed even with a read-only mount! To
261 disable that behaviour, mount also with 'nologreplay'.
262
263 *max_inline='bytes'*::
264 (default: min(2048, page size) )
265 +
266 Specify the maximum amount of space, in bytes, that can be inlined in
267 a metadata B-tree leaf.  The value is specified in bytes, optionally
268 with a K suffix (case insensitive).  In practice, this value
269 is limited by the filesystem block size (named 'sectorsize' at mkfs time),
270 and memory page size of the system. In case of sectorsize limit, there's
271 some space unavailable due to leaf headers.  For example, a 4k sectorsize,
272 maximum size of inline data is about 3900 bytes.
273 +
274 Inlining can be completely turned off by specifying 0. This will increase data
275 block slack if file sizes are much smaller than block size but will reduce
276 metadata consumption in return.
277 +
278 NOTE: the default value has changed to 2048 in kernel 4.6.
279
280 *metadata_ratio='value'*::
281 (default: 0, internal logic)
282 +
283 Specifies that 1 metadata chunk should be allocated after every 'value' data
284 chunks. Default behaviour depends on internal logic, some percent of unused
285 metadata space is attempted to be maintained but is not always possible if
286 there's not enough space left for chunk allocation. The option could be useful to
287 override the internal logic in favor of the metadata allocation if the expected
288 workload is supposed to be metadata intense (snapshots, reflinks, xattrs,
289 inlined files).
290
291 *recovery*::
292 (since: 3.2, default: off, deprecated since: 4.5)
293 +
294 NOTE: this option has been replaced by 'usebackuproot' and should not be used
295 but will work on 4.5+ kernels.
296
297 *norecovery*::
298 (since: 4.5, default: off)
299 +
300 Do not attempt any data recovery at mount time. This will disable 'logreplay'
301 and avoids other write operations.
302 +
303 NOTE: The opposite option 'recovery' used to have different meaning but was
304 changed for consistency with other filesystems, where 'norecovery' is used for
305 skipping log replay. BTRFS does the same and in general will try to avoid any
306 write operations.
307
308 *rescan_uuid_tree*::
309 (since: 3.12, default: off)
310 +
311 Force check and rebuild procedure of the UUID tree. This should not
312 normally be needed.
313
314 *skip_balance*::
315 (since: 3.3, default: off)
316 +
317 Skip automatic resume of an interrupted balance operation. The operation can
318 later be resumed with *btrfs balance resume*, or the paused state can be
319 removed with *btrfs balance cancel*. The default behaviour is to resume an
320 interrupted balance immediately after a volume is mounted.
321
322 *space_cache*::
323 *space_cache='version'*::
324 *nospace_cache*::
325 ('nospace_cache' since: 3.2, 'space_cache=v1' and 'space_cache=v2' since 4.5, default: 'space_cache=v1')
326 +
327 Options to control the free space cache. The free space cache greatly improves
328 performance when reading block group free space into memory. However, managing
329 the space cache consumes some resources, including a small amount of disk
330 space.
331 +
332 There are two implementations of the free space cache. The original
333 implementation, 'v1', is the safe default. The 'v1' space cache can be disabled
334 at mount time with 'nospace_cache' without clearing.
335 +
336 On very large filesystems (many terabytes) and certain workloads, the
337 performance of the 'v1' space cache may degrade drastically. The 'v2'
338 implementation, which adds a new B-tree called the free space tree, addresses
339 this issue. Once enabled, the 'v2' space cache will always be used and cannot
340 be disabled unless it is cleared. Use 'clear_cache,space_cache=v1' or
341 'clear_cache,nospace_cache' to do so. If 'v2' is enabled, kernels without 'v2'
342 support will only be able to mount the filesystem in read-only mode. The
343 `btrfs(8)` command currently only has read-only support for 'v2'. A read-write
344 command may be run on a 'v2' filesystem by clearing the cache, running the
345 command, and then remounting with 'space_cache=v2'.
346 +
347 If a version is not explicitly specified, the default implementation will be
348 chosen, which is 'v1' as of 4.9.
349
350 *ssd*::
351 *nossd*::
352 *ssd_spread*::
353 (default: SSD autodetected)
354 +
355 Options to control SSD allocation schemes.  By default, BTRFS will
356 enable or disable SSD allocation heuristics depending on whether a
357 rotational or non-rotational disk is in use (contents of
358 '/sys/block/DEV/queue/rotational').  The 'ssd' and 'nossd' options
359 can override this autodetection.
360 +
361 The 'ssd_spread' mount option attempts to allocate into bigger and aligned
362 chunks of unused space, and may perform better on low-end SSDs.  'ssd_spread'
363 implies 'ssd', enabling all other SSD heuristics as well.
364
365 *subvol='path'*::
366 Mount subvolume from 'path' rather than the toplevel subvolume. The
367 'path' is absolute (ie. starts at the toplevel subvolume).
368 This mount option overrides the default subvolume set for the given filesystem.
369
370 *subvolid='subvolid'*::
371 Mount subvolume specified by a 'subvolid' number rather than the toplevel
372 subvolume.  You can use *btrfs subvolume list* to see subvolume ID numbers.
373 This mount option overrides the default subvolume set for the given filesystem.
374 +
375 NOTE: if both 'subvolid' and 'subvol' are specified, they must point at the
376 same subvolume, otherwise mount will fail.
377
378 *subvolrootid='objectid'*::
379 (irrelevant since: 3.2, formally deprecated since: 3.10)
380 +
381 A workaround option from times (pre 3.2) when it was not possible to mount a
382 subvolume that did not reside directly under the toplevel subvolume.
383
384 *thread_pool='number'*::
385 (default: min(NRCPUS + 2, 8) )
386 +
387 The number of worker threads to allocate. NRCPUS is number of on-line CPUs
388 detected at the time of mount. Small number leads to less parallelism in
389 processing data and metadata, higher numbers could lead to a performance hit
390 due to increased locking contention, cache-line bouncing or costly data
391 transfers between local CPU memories.
392
393 *treelog*::
394 *notreelog*::
395 (default: on)
396 +
397 Enable the tree logging used for 'fsync' and 'O_SYNC' writes. The tree log
398 stores changes without the need of a full filesystem sync. The log operations
399 are flushed at sync and transaction commit. If the system crashes between two
400 such syncs, the pending tree log operations are replayed during mount.
401 +
402 WARNING: currently, the tree log is replayed even with a read-only mount! To
403 disable that behaviour, mount also with 'nologreplay'.
404 +
405 The tree log could contain new files/directories, these would not exist on
406 a mounted filesystem if the log is not replayed.
407
408 *usebackuproot*::
409 *nousebackuproot*::
410 +
411 Enable autorecovery attempts if a bad tree root is found at mount time.
412 Currently this scans a backup list of several previous tree roots and tries to
413 use the first readable. This can be used with read-only mounts as well.
414 +
415 NOTE: This option has replaced 'recovery'.
416
417 *user_subvol_rm_allowed*::
418 (default: off)
419 +
420 Allow subvolumes to be deleted by their respective owner. Otherwise, only the
421 root user can do that.
422
423 FILESYSTEM FEATURES
424 -------------------
425
426 The basic set of filesystem features gets extended over time. The backward
427 compatibility is maintained and the features are optional, need to be
428 explicitly asked for so accidental use will not create incompatibilities.
429
430 There are several classes and the respective tools to manage the features:
431
432 at mkfs time only::
433 This is namely for core structures, like the b-tree nodesize, see
434 `mkfs.btrfs`(8) for more details.
435
436 after mkfs, on an unmounted filesystem::
437 Features that may optimize internal structures or add new structures to support
438 new functionality, see `btrfstune`(8). The command *btrfs inspect-internal
439 dump-super device* will dump a superblock, you can map the value of
440 'incompat_flags' to the features listed below
441
442 after mkfs, on a mounted filesystem::
443 The features of a filesystem (with a given UUID) are listed in
444 `/sys/fs/btrfs/UUID/features/`, one file per feature. The status is stored
445 inside the file. The value '1' is for enabled and active, while '0' means the
446 feature was enabled at mount time but turned off afterwards.
447 +
448 Whether a particular feature can be turned on a mounted filesystem can be found
449 in the directory `/sys/fs/btrfs/features/`, one file per feature. The value '1'
450 means the feature can be enabled.
451
452 List of features (see also `mkfs.btrfs`(8) section 'FILESYSTEM FEATURES'):
453
454 big_metadata::
455 (since: 3.4)
456 +
457 the filesystem uses 'nodesize' bigger than the page size
458 compress_lzo::
459 (since: 2.6.38)
460 +
461 the 'lzo' compression has been used on the filesystem, either as a mount option
462 or via *btrfs filesystem defrag*.
463
464 default_subvol::
465 (since: 2.6.34)
466 +
467 the default subvolume has been set on the filesystem
468
469 extended_iref::
470 (since: 3.7)
471 +
472 increased hardlink limit per file in a directory to 65536, older kernels
473 supported a varying number of hardlinks depending on the sum of all file name
474 sizes that can be stored into one metadata block
475
476 mixed_backref::
477 (since: 2.6.31)
478 +
479 the last major disk format change, improved backreferences
480
481 mixed_groups::
482 (since: 2.6.37)
483 +
484 mixed data and metadata block groups, ie. the data and metadata are not
485 separated and occupy the same block groups, this mode is suitable for small
486 volumes as there are no constraints how the remaining space should be used
487 (compared to the split mode, where empty metadata space cannot be used for data
488 and vice versa)
489 +
490 on the other hand, the final layout is quite unpredictable and possibly highly
491 fragmented, which means worse performance
492
493 no_holes::
494 (since: 3.14)
495 improved representation of file extents where holes are not explicitly
496 stored as an extent, saves a few percent of metadata if sparse files are used
497
498 raid56::
499 (since: 3.9)
500 +
501 the filesystem contains or contained a raid56 profile of block groups
502 +
503 skinny_metadata::
504 (since: 3.10)
505 +
506 reduced-size metadata for extent references, saves a few percent of metadata
507
508 FILE ATTRIBUTES
509 ---------------
510 The btrfs filesystem supports setting the following file attributes using the
511 `chattr`(1) utility:
512
513 *a*::
514 'append only', new writes are always written at the end of the file
515
516 *A*::
517 'no atime updates'
518
519 *c*::
520 'compress data', all data written after this attribute is set will be compressed.
521 Please note that compression is also affected by the mount options or the parent
522 directory attributes.
523 +
524 When set on a directory, all newly created files will inherit this attribute.
525
526 *C*::
527 'no copy-on-write', file modifications are done in-place
528 +
529 When set on a directory, all newly created files will inherit this attribute.
530 +
531 NOTE: due to implementation limitations, this flag can be set/unset only on
532 empty files.
533
534 *d*::
535 'no dump', makes sense with 3rd party tools like `dump`(8), on BTRFS the
536 attribute can be set/unset on no other special handling is done
537
538 *D*::
539 'synchronous directory updates', for more details search `open`(2) for 'O_SYNC'
540 and 'O_DSYNC'
541
542 *i*::
543 'immutable', no file data and metadata changes allowed even to the root user as
544 long as this attribute is set (obviously the exception is unsetting the attribute)
545
546 *S*::
547 'synchronous updates', for more details search `open`(2) for 'O_SYNC' and
548 'O_DSYNC'
549
550 *X*::
551 'no compression', permanently turn off compression on the given file, other
552 compression mount options will not affect that
553 +
554 When set on a directory, all newly created files will inherit this attribute.
555
556 No other attributes are supported.  For the complete list please refer to the
557 `chattr`(1) manual page.
558
559 CONTROL DEVICE
560 --------------
561
562 There's a character special device `/dev/btrfs-control` with major and minor
563 numbers 10 and 234 (the device can be found under the 'misc' category).
564
565 --------------------
566 $ ls -l /dev/btrfs-control
567 crw------- 1 root root 10, 234 Jan  1 12:00 /dev/btrfs-control
568 --------------------
569
570 The device accepts some ioctl calls that can perform following actions on the
571 filesystem module:
572
573 * scan devices for btrfs filesystem (ie. to let multi-device filesystems mount
574   automatically) and register them with the kernel module
575 * similar to scan, but also wait until the device scanning process is finished
576   for a given filesystem
577 * get the supported features (can be also found under '/sys/fs/btrfs/features')
578
579
580 The device is usually created by ..., but can be created manually:
581
582 --------------------
583 # mknod --mode=600 c 10 234 /dev/btrfs-control
584 --------------------
585
586 The device is not strictly required but the device scanning will not work and a
587 workaround would need to be used to mount a multi-device filesystem. The mount
588 option 'device' can trigger the device scanning during mount.
589
590 SEE ALSO
591 --------
592 `acl`(5),
593 `btrfs`(8),
594 `chattr`(1),
595 `fstrim`(8),
596 `ioctl`(2),
597 `mkfs.btrfs`(8),
598 `mount`(8)