a1f364e0fbd5691a97418e8ae4f6a6103e8f34c0
[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: on)
218 +
219 This option forces any data dirtied by a write in a prior transaction to commit
220 as part of the current commit.  This makes the committed state a fully
221 consistent view of the file system from the application's perspective (i.e., it
222 includes all completed file system operations).  This was previously the
223 behavior only when a snapshot was created.
224 +
225 Disabling flushing may improve performance but is not crash-safe.
226
227 *fragment='type'*::
228 (depends on compile-time option BTRFS_DEBUG, since: 4.4, default: off)
229 +
230 A debugging helper to intentionally fragment given 'type' of block groups. The
231 type can be 'data', 'metadata' or 'all'. This mount option should not be used
232 outside of debugging environments and is not recognized if the kernel config
233 option 'BTRFS_DEBUG' is not enabled.
234
235 *inode_cache*::
236 *noinode_cache*::
237 (since: 3.0, default: off)
238 +
239 Enable free inode number caching. Not recommended to use unless files on your
240 filesystem get assigned inode numbers that are approaching 2^64^. Normally, new
241 files in each subvolume get assigned incrementally (plus one from the last
242 time) and are not reused. The mount option turns on caching of the existing
243 inode numbers and reuse of inode numbers of deleted files.
244 +
245 This option may slow down your system at first run, or after mounting without
246 the option.
247 +
248 NOTE: Defaults to off due to a potential overflow problem when the free space
249 checksums don't fit inside a single page.
250
251 *logreplay*::
252 *nologreplay*::
253 (default: on, even read-only)
254 +
255 Enable/disable log replay at mount time. See also 'treelog'.
256 +
257 WARNING: currently, the tree log is replayed even with a read-only mount! To
258 disable that behaviour, mount also with 'nologreplay'.
259
260 *max_inline='bytes'*::
261 (default: min(2048, page size) )
262 +
263 Specify the maximum amount of space, in bytes, that can be inlined in
264 a metadata B-tree leaf.  The value is specified in bytes, optionally
265 with a K suffix (case insensitive).  In practice, this value
266 is limited by the filesystem block size (named 'sectorsize' at mkfs time),
267 and memory page size of the system. In case of sectorsize limit, there's
268 some space unavailable due to leaf headers.  For example, a 4k sectorsize,
269 maximum size of inline data is about 3900 bytes.
270 +
271 Inlining can be completely turned off by specifying 0. This will increase data
272 block slack if file sizes are much smaller than block size but will reduce
273 metadata consumption in return.
274 +
275 NOTE: the default value has changed to 2048 in kernel 4.6.
276
277 *metadata_ratio='value'*::
278 (default: 0, internal logic)
279 +
280 Specifies that 1 metadata chunk should be allocated after every 'value' data
281 chunks. Default behaviour depends on internal logic, some percent of unused
282 metadata space is attempted to be maintained but is not always possible if
283 there's not enough space left for chunk allocation. The option could be useful to
284 override the internal logic in favor of the metadata allocation if the expected
285 workload is supposed to be metadata intense (snapshots, reflinks, xattrs,
286 inlined files).
287
288 *recovery*::
289 (since: 3.2, default: off, deprecated since: 4.5)
290 +
291 NOTE: this option has been replaced by 'usebackuproot' and should not be used
292 but will work on 4.5+ kernels.
293
294 *norecovery*::
295 (since: 4.5, default: off)
296 +
297 Do not attempt any data recovery at mount time. This will disable 'logreplay'
298 and avoids other write operations.
299 +
300 NOTE: The opposite option 'recovery' used to have different meaning but was
301 changed for consistency with other filesystems, where 'norecovery' is used for
302 skipping log replay. BTRFS does the same and in general will try to avoid any
303 write operations.
304
305 *rescan_uuid_tree*::
306 (since: 3.12, default: off)
307 +
308 Force check and rebuild procedure of the UUID tree. This should not
309 normally be needed.
310
311 *skip_balance*::
312 (since: 3.3, default: off)
313 +
314 Skip automatic resume of interrupted balance operation after mount.
315 May be resumed with *btrfs balance resume* or the paused state can be removed
316 by *btrfs balance cancel*. The default behaviour is to start interrutpd balance.
317
318 *space_cache*::
319 *space_cache=v2*::
320 *nospace_cache*::
321 ('nospace_cache' since: 3.2, 'space_cache=v2' since 4.5, default: on)
322 +
323 Options to control the free space cache.  This affects performance as searching
324 for new free blocks could take longer if the space cache is not enabled. On the
325 other hand, managing the space cache consumes some resources.  It can be
326 disabled without clearing at mount time.
327 +
328 There are two implementations of how the space is tracked. The safe default is
329 'v1'.  On large filesystems (many-terabytes) and certain workloads the 'v1'
330 performance may degrade.  This problem is addressed by 'v2', that is based on
331 b-trees, sometimes referred to as 'free-space-tree'.
332 +
333 'Compatibility notes:'
334 +
335 * the 'v2' has to be enabled manually at mount time, once
336 * kernel without 'v2' support will be able to mount the filesystem in read-only mode
337 * 'v2' can be removed by mounting with 'clear_cache'
338
339 *ssd*::
340 *nossd*::
341 *ssd_spread*::
342 (default: SSD autodetected)
343 +
344 Options to control SSD allocation schemes.  By default, BTRFS will
345 enable or disable SSD allocation heuristics depending on whether a
346 rotational or non-rotational disk is in use (contents of
347 '/sys/block/DEV/queue/rotational').  The 'ssd' and 'nossd' options
348 can override this autodetection.
349 +
350 The 'ssd_spread' mount option attempts to allocate into bigger and aligned
351 chunks of unused space, and may perform better on low-end SSDs.  'ssd_spread'
352 implies 'ssd', enabling all other SSD heuristics as well.
353
354 *subvol='path'*::
355 Mount subvolume from 'path' rather than the toplevel subvolume. The
356 'path' is absolute (ie. starts at the toplevel subvolume).
357 This mount option overrides the default subvolume set for the given filesystem.
358
359 *subvolid='subvolid'*::
360 Mount subvolume specified by a 'subvolid' number rather than the toplevel
361 subvolume.  You can use *btrfs subvolume list* to see subvolume ID numbers.
362 This mount option overrides the default subvolume set for the given filesystem.
363 +
364 NOTE: if both 'subvolid' and 'subvol' are specified, they must point at the
365 same subvolume, otherwise mount will fail.
366
367 *subvolrootid='objectid'*::
368 (irrelevant since: 3.2, formally deprecated since: 3.10)
369 +
370 A workaround option from times (pre 3.2) when it was not possible to mount a
371 subvolume that did not reside directly under the toplevel subvolume.
372
373 *thread_pool='number'*::
374 (default: min(NRCPUS + 2, 8) )
375 +
376 The number of worker threads to allocate. NRCPUS is number of on-line CPUs
377 detected at the time of mount. Small number leads to less parallelism in
378 processing data and metadata, higher numbers could lead to a performance hit
379 due to increased locking contention, cache-line bouncing or costly data
380 transfers between local CPU memories.
381
382 *treelog*::
383 *notreelog*::
384 (default: on)
385 +
386 Enable the tree logging used for 'fsync' and 'O_SYNC' writes. The tree log
387 stores changes without the need of a full filesystem sync. The log operations
388 are flushed at sync and transaction commit. If the system crashes between two
389 such syncs, the pending tree log operations are replayed during mount.
390 +
391 WARNING: currently, the tree log is replayed even with a read-only mount! To
392 disable that behaviour, mount also with 'nologreplay'.
393 +
394 The tree log could contain new files/directories, these would not exist on
395 a mounted filesystem if the log is not replayed.
396
397 *usebackuproot*::
398 *nousebackuproot*::
399 +
400 Enable autorecovery attempts if a bad tree root is found at mount time.
401 Currently this scans a backup list of several previous tree roots and tries to
402 use the first readable. This can be used with read-only mounts as well.
403 +
404 NOTE: This option has replaced 'recovery'.
405
406 *user_subvol_rm_allowed*::
407 (default: off)
408 +
409 Allow subvolumes to be deleted by their respective owner. Otherwise, only the
410 root user can do that.
411
412 FILESYSTEM FEATURES
413 -------------------
414
415 The basic set of filesystem features gets extended over time. The backward
416 compatibility is maintained and the features are optional, need to be
417 explicitly asked for so accidental use will not create incompatibilities.
418
419 There are several classes and the respective tools to manage the features:
420
421 at mkfs time only::
422 This is namely for core structures, like the b-tree nodesize, see
423 `mkfs.btrfs`(8) for more details.
424
425 after mkfs, on an unmounted filesystem::
426 Features that may optimize internal structures or add new structures to support
427 new functionality, see `btrfstune`(8). The command *btrfs inspect-internal
428 dump-super device* will dump a superblock, you can map the value of
429 'incompat_flags' to the features listed below
430
431 after mkfs, on a mounted filesystem::
432 The features of a filesystem (with a given UUID) are listed in
433 `/sys/fs/btrfs/UUID/features/`, one file per feature. The status of is stored
434 insid the file. The value '1' is for enabled, '0' means the feature was had
435 been enabled at the mount time and turned off afterwards.
436 +
437 Whether a particular feature can be turned on a mounted filesystem can be found
438 in the directory `/sys/fs/btrfs/features/`, one file per feature. The value '1'
439 means the feature can be enabled.
440
441 List of features (see also `mkfs.btrfs`(8) section 'FILESYSTEM FEATURES'):
442
443 big_metadata::
444 (since: 3.4)
445 +
446 the filesystem uses 'nodesize' bigger than the page size
447 compress_lzo::
448 (since: 2.6.38)
449 +
450 the 'lzo' compression has been used on the filesystem, either as a mount option
451 or via *btrfs filesystem defrag*.
452
453 default_subvol::
454 (since: 2.6.34)
455 +
456 the default subvolume has been set on the filesystem
457
458 extended_iref::
459 (since: 3.7)
460 +
461 increased hardlink limit per file in a directory to 65536, older kernels
462 supported a varying number of hardlinks depending on the sum of all file name
463 sizes that can be stored into one metadata block
464
465 mixed_backref::
466 (since: 2.6.31)
467 +
468 the last major disk format change, improved backreferences
469
470 mixed_groups::
471 (since: 2.6.37)
472 +
473 mixed data and metadata block groups, ie. the data and metadata are not
474 separated and occupy the same block groups, this mode is suitable for small
475 volumes as there are no constraints how the remaining space should be used
476 (compared to the split mode, where empty metadata space cannot be used for data
477 and vice versa)
478 +
479 on the other hand, the final layout is quite unpredictable and possibly highly
480 fragmented, which means worse performance
481
482 no_holes::
483 (since: 3.14)
484 improved representation of file extents where holes are not explicitly
485 stored as an extent, saves a few percent of metadata if sparse files are used
486
487 raid56::
488 (since: 3.9)
489 +
490 the filesystem contains or contained a raid56 profile of block groups
491 +
492 skinny_metadata::
493 (since: 3.10)
494 +
495 reduced-size metadata for extent references, saves a few percent of metadata
496
497 FILE ATTRIBUTES
498 ---------------
499 The btrfs filesystem supports setting the following file attributes using the
500 `chattr`(1) utility:
501
502 *a*::
503 'append only', new writes are always written at the end of the file
504
505 *A*::
506 'no atime updates'
507
508 *c*::
509 'compress data', all data written after this attribute is set will be compressed.
510 Please note that compression is also affected by the mount options or the parent
511 directory attributes.
512 +
513 When set on a directory, all newly created files will inherit this attribute.
514
515 *C*::
516 'no copy-on-write', file modifications are done in-place
517 +
518 When set on a directory, all newly created files will inherit this attribute.
519 +
520 NOTE: due to implementation limitations, this flag can be set/unset only on
521 empty files.
522
523 *d*::
524 'no dump', makes sense with 3rd party tools like `dump`(8), on BTRFS the
525 attribute can be set/unset on no other special handling is done
526
527 *D*::
528 'synchronous directory updates', for more details search `open`(2) for 'O_SYNC'
529 and 'O_DSYNC'
530
531 *i*::
532 'immutable', no file data and metadata changes allowed even to the root user as
533 long as this attribute is set (obviously the exception is unsetting the attribute)
534
535 *S*::
536 'synchronous updates', for more details search `open`(2) for 'O_SYNC' and
537 'O_DSYNC'
538
539 *X*::
540 'no compression', permanently turn off compression on the given file, other
541 compression mount options will not affect that
542 +
543 When set on a directory, all newly created files will inherit this attribute.
544
545 No other attributes are supported.  For the complete list please refer to the
546 `chattr`(1) manual page.
547
548 CONTROL DEVICE
549 --------------
550
551 There's a character special device `/dev/btrfs-control` with major and minor
552 numbers 10 and 234 (the device can be found under the 'misc' category).
553
554 --------------------
555 $ ls -l /dev/btrfs-control
556 crw------- 1 root root 10, 234 Jan  1 12:00 /dev/btrfs-control
557 --------------------
558
559 The device accepts some ioctl calls that can perform following actions on the
560 filesyste module:
561
562 * scan devices for btrfs filesytem (ie. to let multi-device filesystems mount
563   automatically) and register them with the kernel module
564 * similar to scan, but also wait until the device scanning process is finished
565   for a given filesystem
566 * get the supported features (can be also found under '/sys/fs/btrfs/features')
567
568
569 The device is usually created by ..., but can be created manually:
570
571 --------------------
572 # mknod --mode=600 c 10 234 /dev/btrfs-control
573 --------------------
574
575 The device is not strictly required but the device scanning will not work and a
576 workaround would need to be used to mount a multi-device filesystem. The mount
577 option 'device' can trigger the device scanning during mount.
578
579 SEE ALSO
580 --------
581 `acl`(5),
582 `btrfs`(8),
583 `chattr`(1),
584 `fstrim`(8),
585 `ioctl`(2),
586 `mkfs.btrfs`(8),
587 `mount`(8)