acc4e42941a277c46b5575babadaa8935f60ab49
[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 interrupted balance operation after mount.
318 May be resumed with *btrfs balance resume* or the paused state can be removed
319 by *btrfs balance cancel*. The default behaviour is to start interrutpd balance.
320
321 *space_cache*::
322 *space_cache='version'*::
323 *nospace_cache*::
324 ('nospace_cache' since: 3.2, 'space_cache=v1' and 'space_cache=v2' since 4.5, default: 'space_cache=v1')
325 +
326 Options to control the free space cache. The free space cache greatly improves
327 performance when reading block group free space into memory. However, managing
328 the space cache consumes some resources, including a small amount of disk
329 space.
330 +
331 There are two implementations of the free space cache. The original
332 implementation, 'v1', is the safe default. The 'v1' space cache can be disabled
333 at mount time with 'nospace_cache' without clearing.
334 +
335 On very large filesystems (many terabytes) and certain workloads, the
336 performance of the 'v1' space cache may degrade drastically. The 'v2'
337 implementation, which adds a new B-tree called the free space tree, addresses
338 this issue. Once enabled, the 'v2' space cache will always be used and cannot
339 be disabled unless it is cleared. Use 'clear_cache,space_cache=v1' or
340 'clear_cache,nospace_cache' to do so. If 'v2' is enabled, kernels without 'v2'
341 support will only be able to mount the filesystem in read-only mode. The
342 `btrfs(8)` command currently only has read-only support for 'v2'. A read-write
343 command may be run on a 'v2' filesystem by clearing the cache, running the
344 command, and then remounting with 'space_cache=v2'.
345 +
346 If a version is not explicitly specified, the default implementation will be
347 chosen, which is 'v1' as of 4.9.
348
349 *ssd*::
350 *nossd*::
351 *ssd_spread*::
352 (default: SSD autodetected)
353 +
354 Options to control SSD allocation schemes.  By default, BTRFS will
355 enable or disable SSD allocation heuristics depending on whether a
356 rotational or non-rotational disk is in use (contents of
357 '/sys/block/DEV/queue/rotational').  The 'ssd' and 'nossd' options
358 can override this autodetection.
359 +
360 The 'ssd_spread' mount option attempts to allocate into bigger and aligned
361 chunks of unused space, and may perform better on low-end SSDs.  'ssd_spread'
362 implies 'ssd', enabling all other SSD heuristics as well.
363
364 *subvol='path'*::
365 Mount subvolume from 'path' rather than the toplevel subvolume. The
366 'path' is absolute (ie. starts at the toplevel subvolume).
367 This mount option overrides the default subvolume set for the given filesystem.
368
369 *subvolid='subvolid'*::
370 Mount subvolume specified by a 'subvolid' number rather than the toplevel
371 subvolume.  You can use *btrfs subvolume list* to see subvolume ID numbers.
372 This mount option overrides the default subvolume set for the given filesystem.
373 +
374 NOTE: if both 'subvolid' and 'subvol' are specified, they must point at the
375 same subvolume, otherwise mount will fail.
376
377 *subvolrootid='objectid'*::
378 (irrelevant since: 3.2, formally deprecated since: 3.10)
379 +
380 A workaround option from times (pre 3.2) when it was not possible to mount a
381 subvolume that did not reside directly under the toplevel subvolume.
382
383 *thread_pool='number'*::
384 (default: min(NRCPUS + 2, 8) )
385 +
386 The number of worker threads to allocate. NRCPUS is number of on-line CPUs
387 detected at the time of mount. Small number leads to less parallelism in
388 processing data and metadata, higher numbers could lead to a performance hit
389 due to increased locking contention, cache-line bouncing or costly data
390 transfers between local CPU memories.
391
392 *treelog*::
393 *notreelog*::
394 (default: on)
395 +
396 Enable the tree logging used for 'fsync' and 'O_SYNC' writes. The tree log
397 stores changes without the need of a full filesystem sync. The log operations
398 are flushed at sync and transaction commit. If the system crashes between two
399 such syncs, the pending tree log operations are replayed during mount.
400 +
401 WARNING: currently, the tree log is replayed even with a read-only mount! To
402 disable that behaviour, mount also with 'nologreplay'.
403 +
404 The tree log could contain new files/directories, these would not exist on
405 a mounted filesystem if the log is not replayed.
406
407 *usebackuproot*::
408 *nousebackuproot*::
409 +
410 Enable autorecovery attempts if a bad tree root is found at mount time.
411 Currently this scans a backup list of several previous tree roots and tries to
412 use the first readable. This can be used with read-only mounts as well.
413 +
414 NOTE: This option has replaced 'recovery'.
415
416 *user_subvol_rm_allowed*::
417 (default: off)
418 +
419 Allow subvolumes to be deleted by their respective owner. Otherwise, only the
420 root user can do that.
421
422 FILESYSTEM FEATURES
423 -------------------
424
425 The basic set of filesystem features gets extended over time. The backward
426 compatibility is maintained and the features are optional, need to be
427 explicitly asked for so accidental use will not create incompatibilities.
428
429 There are several classes and the respective tools to manage the features:
430
431 at mkfs time only::
432 This is namely for core structures, like the b-tree nodesize, see
433 `mkfs.btrfs`(8) for more details.
434
435 after mkfs, on an unmounted filesystem::
436 Features that may optimize internal structures or add new structures to support
437 new functionality, see `btrfstune`(8). The command *btrfs inspect-internal
438 dump-super device* will dump a superblock, you can map the value of
439 'incompat_flags' to the features listed below
440
441 after mkfs, on a mounted filesystem::
442 The features of a filesystem (with a given UUID) are listed in
443 `/sys/fs/btrfs/UUID/features/`, one file per feature. The status of is stored
444 insid the file. The value '1' is for enabled, '0' means the feature had
445 been enabled at the mount time and turned off afterwards.
446 +
447 Whether a particular feature can be turned on a mounted filesystem can be found
448 in the directory `/sys/fs/btrfs/features/`, one file per feature. The value '1'
449 means the feature can be enabled.
450
451 List of features (see also `mkfs.btrfs`(8) section 'FILESYSTEM FEATURES'):
452
453 big_metadata::
454 (since: 3.4)
455 +
456 the filesystem uses 'nodesize' bigger than the page size
457 compress_lzo::
458 (since: 2.6.38)
459 +
460 the 'lzo' compression has been used on the filesystem, either as a mount option
461 or via *btrfs filesystem defrag*.
462
463 default_subvol::
464 (since: 2.6.34)
465 +
466 the default subvolume has been set on the filesystem
467
468 extended_iref::
469 (since: 3.7)
470 +
471 increased hardlink limit per file in a directory to 65536, older kernels
472 supported a varying number of hardlinks depending on the sum of all file name
473 sizes that can be stored into one metadata block
474
475 mixed_backref::
476 (since: 2.6.31)
477 +
478 the last major disk format change, improved backreferences
479
480 mixed_groups::
481 (since: 2.6.37)
482 +
483 mixed data and metadata block groups, ie. the data and metadata are not
484 separated and occupy the same block groups, this mode is suitable for small
485 volumes as there are no constraints how the remaining space should be used
486 (compared to the split mode, where empty metadata space cannot be used for data
487 and vice versa)
488 +
489 on the other hand, the final layout is quite unpredictable and possibly highly
490 fragmented, which means worse performance
491
492 no_holes::
493 (since: 3.14)
494 improved representation of file extents where holes are not explicitly
495 stored as an extent, saves a few percent of metadata if sparse files are used
496
497 raid56::
498 (since: 3.9)
499 +
500 the filesystem contains or contained a raid56 profile of block groups
501 +
502 skinny_metadata::
503 (since: 3.10)
504 +
505 reduced-size metadata for extent references, saves a few percent of metadata
506
507 FILE ATTRIBUTES
508 ---------------
509 The btrfs filesystem supports setting the following file attributes using the
510 `chattr`(1) utility:
511
512 *a*::
513 'append only', new writes are always written at the end of the file
514
515 *A*::
516 'no atime updates'
517
518 *c*::
519 'compress data', all data written after this attribute is set will be compressed.
520 Please note that compression is also affected by the mount options or the parent
521 directory attributes.
522 +
523 When set on a directory, all newly created files will inherit this attribute.
524
525 *C*::
526 'no copy-on-write', file modifications are done in-place
527 +
528 When set on a directory, all newly created files will inherit this attribute.
529 +
530 NOTE: due to implementation limitations, this flag can be set/unset only on
531 empty files.
532
533 *d*::
534 'no dump', makes sense with 3rd party tools like `dump`(8), on BTRFS the
535 attribute can be set/unset on no other special handling is done
536
537 *D*::
538 'synchronous directory updates', for more details search `open`(2) for 'O_SYNC'
539 and 'O_DSYNC'
540
541 *i*::
542 'immutable', no file data and metadata changes allowed even to the root user as
543 long as this attribute is set (obviously the exception is unsetting the attribute)
544
545 *S*::
546 'synchronous updates', for more details search `open`(2) for 'O_SYNC' and
547 'O_DSYNC'
548
549 *X*::
550 'no compression', permanently turn off compression on the given file, other
551 compression mount options will not affect that
552 +
553 When set on a directory, all newly created files will inherit this attribute.
554
555 No other attributes are supported.  For the complete list please refer to the
556 `chattr`(1) manual page.
557
558 CONTROL DEVICE
559 --------------
560
561 There's a character special device `/dev/btrfs-control` with major and minor
562 numbers 10 and 234 (the device can be found under the 'misc' category).
563
564 --------------------
565 $ ls -l /dev/btrfs-control
566 crw------- 1 root root 10, 234 Jan  1 12:00 /dev/btrfs-control
567 --------------------
568
569 The device accepts some ioctl calls that can perform following actions on the
570 filesyste module:
571
572 * scan devices for btrfs filesystem (ie. to let multi-device filesystems mount
573   automatically) and register them with the kernel module
574 * similar to scan, but also wait until the device scanning process is finished
575   for a given filesystem
576 * get the supported features (can be also found under '/sys/fs/btrfs/features')
577
578
579 The device is usually created by ..., but can be created manually:
580
581 --------------------
582 # mknod --mode=600 c 10 234 /dev/btrfs-control
583 --------------------
584
585 The device is not strictly required but the device scanning will not work and a
586 workaround would need to be used to mount a multi-device filesystem. The mount
587 option 'device' can trigger the device scanning during mount.
588
589 SEE ALSO
590 --------
591 `acl`(5),
592 `btrfs`(8),
593 `chattr`(1),
594 `fstrim`(8),
595 `ioctl`(2),
596 `mkfs.btrfs`(8),
597 `mount`(8)