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