1BTRFS-MAN5(5)                    Btrfs Manual                    BTRFS-MAN5(5)
2
3
4

NAME

6       btrfs-man5 - topics about the BTRFS filesystem (mount options,
7       supported file attributes and other)
8

DESCRIPTION

10       This document describes topics related to BTRFS that are not specific
11       to the tools. Currently covers:
12
13        1. mount options
14
15        2. filesystem features
16
17        3. checksum algorithms
18
19        4. filesystem exclusive operations
20
21        5. filesystem limits
22
23        6. bootloader support
24
25        7. file attributes
26
27        8. control device
28
29        9. filesystems with multiple block group profiles
30

MOUNT OPTIONS

32       This section describes mount options specific to BTRFS. For the generic
33       mount options please refer to mount(8) manpage. The options are sorted
34       alphabetically (discarding the no prefix).
35
36           Note
37           most mount options apply to the whole filesystem and only options
38           in the first mounted subvolume will take effect. This is due to
39           lack of implementation and may change in the future. This means
40           that (for example) you can’t set per-subvolume nodatacow,
41           nodatasum, or compress using mount options. This should eventually
42           be fixed, but it has proved to be difficult to implement correctly
43           within the Linux VFS framework.
44
45       Mount options are processed in order, only the last occurrence of an
46       option takes effect and may disable other options due to constraints
47       (see eg. nodatacow and compress). The output of mount command shows
48       which options have been applied.
49
50       acl, noacl
51           (default: on)
52
53           Enable/disable support for Posix Access Control Lists (ACLs). See
54           the acl(5) manual page for more information about ACLs.
55
56           The support for ACL is build-time configurable (BTRFS_FS_POSIX_ACL)
57           and mount fails if acl is requested but the feature is not compiled
58           in.
59
60       autodefrag, noautodefrag
61           (since: 3.0, default: off)
62
63           Enable automatic file defragmentation. When enabled, small random
64           writes into files (in a range of tens of kilobytes, currently it’s
65           64K) are detected and queued up for the defragmentation process.
66           Not well suited for large database workloads.
67
68           The read latency may increase due to reading the adjacent blocks
69           that make up the range for defragmentation, successive write will
70           merge the blocks in the new location.
71
72               Warning
73               Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as
74               well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12
75               or ≥ 3.13.4 will break up the reflinks of COW data (for example
76               files copied with cp --reflink, snapshots or de-duplicated
77               data). This may cause considerable increase of space usage
78               depending on the broken up reflinks.
79
80       barrier, nobarrier
81           (default: on)
82
83           Ensure that all IO write operations make it through the device
84           cache and are stored permanently when the filesystem is at its
85           consistency checkpoint. This typically means that a flush command
86           is sent to the device that will synchronize all pending data and
87           ordinary metadata blocks, then writes the superblock and issues
88           another flush.
89
90           The write flushes incur a slight hit and also prevent the IO block
91           scheduler to reorder requests in a more effective way. Disabling
92           barriers gets rid of that penalty but will most certainly lead to a
93           corrupted filesystem in case of a crash or power loss. The ordinary
94           metadata blocks could be yet unwritten at the time the new
95           superblock is stored permanently, expecting that the block pointers
96           to metadata were stored permanently before.
97
98           On a device with a volatile battery-backed write-back cache, the
99           nobarrier option will not lead to filesystem corruption as the
100           pending blocks are supposed to make it to the permanent storage.
101
102       check_int, check_int_data, check_int_print_mask=value
103           (since: 3.0, default: off)
104
105           These debugging options control the behavior of the integrity
106           checking module (the BTRFS_FS_CHECK_INTEGRITY config option
107           required). The main goal is to verify that all blocks from a given
108           transaction period are properly linked.
109
110           check_int enables the integrity checker module, which examines all
111           block write requests to ensure on-disk consistency, at a large
112           memory and CPU cost.
113
114           check_int_data includes extent data in the integrity checks, and
115           implies the check_int option.
116
117           check_int_print_mask takes a bitmask of BTRFSIC_PRINT_MASK_* values
118           as defined in fs/btrfs/check-integrity.c, to control the integrity
119           checker module behavior.
120
121           See comments at the top of fs/btrfs/check-integrity.c for more
122           information.
123
124       clear_cache
125           Force clearing and rebuilding of the disk space cache if something
126           has gone wrong. See also: space_cache.
127
128       commit=seconds
129           (since: 3.12, default: 30)
130
131           Set the interval of periodic transaction commit when data are
132           synchronized to permanent storage. Higher interval values lead to
133           larger amount of unwritten data, which has obvious consequences
134           when the system crashes. The upper bound is not forced, but a
135           warning is printed if it’s more than 300 seconds (5 minutes). Use
136           with care.
137
138       compress, compress=type[:level], compress-force,
139       compress-force=type[:level]
140           (default: off, level support since: 5.1)
141
142           Control BTRFS file data compression. Type may be specified as zlib,
143           lzo, zstd or no (for no compression, used for remounting). If no
144           type is specified, zlib is used. If compress-force is specified,
145           then compression will always be attempted, but the data may end up
146           uncompressed if the compression would make them larger.
147
148           Both zlib and zstd (since version 5.1) expose the compression level
149           as a tunable knob with higher levels trading speed and memory
150           (zstd) for higher compression ratios. This can be set by appending
151           a colon and the desired level. Zlib accepts the range [1, 9] and
152           zstd accepts [1, 15]. If no level is set, both currently use a
153           default level of 3. The value 0 is an alias for the default level.
154
155           Otherwise some simple heuristics are applied to detect an
156           incompressible file. If the first blocks written to a file are not
157           compressible, the whole file is permanently marked to skip
158           compression. As this is too simple, the compress-force is a
159           workaround that will compress most of the files at the cost of some
160           wasted CPU cycles on failed attempts. Since kernel 4.15, a set of
161           heuristic algorithms have been improved by using frequency
162           sampling, repeated pattern detection and Shannon entropy
163           calculation to avoid that.
164
165               Note
166               If compression is enabled, nodatacow and nodatasum are
167               disabled.
168
169       datacow, nodatacow
170           (default: on)
171
172           Enable data copy-on-write for newly created files.  Nodatacow
173           implies nodatasum, and disables compression. All files created
174           under nodatacow are also set the NOCOW file attribute (see
175           chattr(1)).
176
177               Note
178               If nodatacow or nodatasum are enabled, compression is disabled.
179           Updates in-place improve performance for workloads that do frequent
180           overwrites, at the cost of potential partial writes, in case the
181           write is interrupted (system crash, device failure).
182
183       datasum, nodatasum
184           (default: on)
185
186           Enable data checksumming for newly created files.  Datasum implies
187           datacow, ie. the normal mode of operation. All files created under
188           nodatasum inherit the "no checksums" property, however there’s no
189           corresponding file attribute (see chattr(1)).
190
191               Note
192               If nodatacow or nodatasum are enabled, compression is disabled.
193           There is a slight performance gain when checksums are turned off,
194           the corresponding metadata blocks holding the checksums do not need
195           to updated. The cost of checksumming of the blocks in memory is
196           much lower than the IO, modern CPUs feature hardware support of the
197           checksumming algorithm.
198
199       degraded
200           (default: off)
201
202           Allow mounts with less devices than the RAID profile constraints
203           require. A read-write mount (or remount) may fail when there are
204           too many devices missing, for example if a stripe member is
205           completely missing from RAID0.
206
207           Since 4.14, the constraint checks have been improved and are
208           verified on the chunk level, not an the device level. This allows
209           degraded mounts of filesystems with mixed RAID profiles for data
210           and metadata, even if the device number constraints would not be
211           satisfied for some of the profiles.
212
213           Example: metadata — raid1, data — single, devices — /dev/sda,
214           /dev/sdb
215
216           Suppose the data are completely stored on sda, then missing sdb
217           will not prevent the mount, even if 1 missing device would normally
218           prevent (any) single profile to mount. In case some of the data
219           chunks are stored on sdb, then the constraint of single/data is not
220           satisfied and the filesystem cannot be mounted.
221
222       device=devicepath
223           Specify a path to a device that will be scanned for BTRFS
224           filesystem during mount. This is usually done automatically by a
225           device manager (like udev) or using the btrfs device scan command
226           (eg. run from the initial ramdisk). In cases where this is not
227           possible the device mount option can help.
228
229               Note
230               booting eg. a RAID1 system may fail even if all filesystem’s
231               device paths are provided as the actual device nodes may not be
232               discovered by the system at that point.
233
234       discard, discard=sync, discard=async, nodiscard
235           (default: off, async support since: 5.6)
236
237           Enable discarding of freed file blocks. This is useful for SSD
238           devices, thinly provisioned LUNs, or virtual machine images;
239           however, every storage layer must support discard for it to work.
240
241           In the synchronous mode (sync or without option value), lack of
242           asynchronous queued TRIM on the backing device TRIM can severely
243           degrade performance, because a synchronous TRIM operation will be
244           attempted instead. Queued TRIM requires newer than SATA revision
245           3.1 chipsets and devices.
246
247           The asynchronous mode (async) gathers extents in larger chunks
248           before sending them to the devices for TRIM. The overhead and
249           performance impact should be negligible compared to the previous
250           mode and it’s supposed to be the preferred mode if needed.
251
252           If it is not necessary to immediately discard freed blocks, then
253           the fstrim tool can be used to discard all free blocks in a batch.
254           Scheduling a TRIM during a period of low system activity will
255           prevent latent interference with the performance of other
256           operations. Also, a device may ignore the TRIM command if the range
257           is too small, so running a batch discard has a greater probability
258           of actually discarding the blocks.
259
260       enospc_debug, noenospc_debug
261           (default: off)
262
263           Enable verbose output for some ENOSPC conditions. It’s safe to use
264           but can be noisy if the system reaches near-full state.
265
266       fatal_errors=action
267           (since: 3.4, default: bug)
268
269           Action to take when encountering a fatal error.
270
271           bug
272               BUG() on a fatal error, the system will stay in the crashed
273               state and may be still partially usable, but reboot is required
274               for full operation
275
276           panic
277               panic() on a fatal error, depending on other system
278               configuration, this may be followed by a reboot. Please refer
279               to the documentation of kernel boot parameters, eg.  panic,
280               oops or crashkernel.
281
282       flushoncommit, noflushoncommit
283           (default: off)
284
285           This option forces any data dirtied by a write in a prior
286           transaction to commit as part of the current commit, effectively a
287           full filesystem sync.
288
289           This makes the committed state a fully consistent view of the file
290           system from the application’s perspective (i.e. it includes all
291           completed file system operations). This was previously the behavior
292           only when a snapshot was created.
293
294           When off, the filesystem is consistent but buffered writes may last
295           more than one transaction commit.
296
297       fragment=type
298           (depends on compile-time option BTRFS_DEBUG, since: 4.4, default:
299           off)
300
301           A debugging helper to intentionally fragment given type of block
302           groups. The type can be data, metadata or all. This mount option
303           should not be used outside of debugging environments and is not
304           recognized if the kernel config option BTRFS_DEBUG is not enabled.
305
306       inode_cache, noinode_cache
307           (since: 3.0, default: off)
308
309           Enable free inode number caching. Not recommended to use unless
310           files on your filesystem get assigned inode numbers that are
311           approaching 2^64. Normally, new files in each subvolume get
312           assigned incrementally (plus one from the last time) and are not
313           reused. The mount option turns on caching of the existing inode
314           numbers and reuse of inode numbers of deleted files.
315
316           This option may slow down your system at first run, or after
317           mounting without the option.
318
319               Note
320               Defaults to off due to a potential overflow problem when the
321               free space checksums don’t fit inside a single page.
322           Don’t use this option unless you really need it. The inode number
323           limit on 64bit system is 2^64, which is practically enough for the
324           whole filesystem lifetime. Due to implementation of linux VFS
325           layer, the inode numbers on 32bit systems are only 32 bits wide.
326           This lowers the limit significantly and makes it possible to reach
327           it. In such case, this mount option will help. Alternatively, files
328           with high inode numbers can be copied to a new subvolume which will
329           effectively start the inode numbers from the beginning again.
330
331       nologreplay
332           (default: off, even read-only)
333
334           The tree-log contains pending updates to the filesystem until the
335           full commit. The log is replayed on next mount, this can be
336           disabled by this option. See also treelog. Note that nologreplay is
337           the same as norecovery.
338
339               Warning
340               currently, the tree log is replayed even with a read-only
341               mount! To disable that behaviour, mount also with nologreplay.
342
343       max_inline=bytes
344           (default: min(2048, page size) )
345
346           Specify the maximum amount of space, that can be inlined in a
347           metadata B-tree leaf. The value is specified in bytes, optionally
348           with a K suffix (case insensitive). In practice, this value is
349           limited by the filesystem block size (named sectorsize at mkfs
350           time), and memory page size of the system. In case of sectorsize
351           limit, there’s some space unavailable due to leaf headers. For
352           example, a 4k sectorsize, maximum size of inline data is about 3900
353           bytes.
354
355           Inlining can be completely turned off by specifying 0. This will
356           increase data block slack if file sizes are much smaller than block
357           size but will reduce metadata consumption in return.
358
359               Note
360               the default value has changed to 2048 in kernel 4.6.
361
362       metadata_ratio=value
363           (default: 0, internal logic)
364
365           Specifies that 1 metadata chunk should be allocated after every
366           value data chunks. Default behaviour depends on internal logic,
367           some percent of unused metadata space is attempted to be maintained
368           but is not always possible if there’s not enough space left for
369           chunk allocation. The option could be useful to override the
370           internal logic in favor of the metadata allocation if the expected
371           workload is supposed to be metadata intense (snapshots, reflinks,
372           xattrs, inlined files).
373
374       norecovery
375           (since: 4.5, default: off)
376
377           Do not attempt any data recovery at mount time. This will disable
378           logreplay and avoids other write operations. Note that this option
379           is the same as nologreplay.
380
381               Note
382               The opposite option recovery used to have different meaning but
383               was changed for consistency with other filesystems, where
384               norecovery is used for skipping log replay. BTRFS does the same
385               and in general will try to avoid any write operations.
386
387       rescan_uuid_tree
388           (since: 3.12, default: off)
389
390           Force check and rebuild procedure of the UUID tree. This should not
391           normally be needed.
392
393       skip_balance
394           (since: 3.3, default: off)
395
396           Skip automatic resume of an interrupted balance operation. The
397           operation can later be resumed with btrfs balance resume, or the
398           paused state can be removed with btrfs balance cancel. The default
399           behaviour is to resume an interrupted balance immediately after a
400           volume is mounted.
401
402       space_cache, space_cache=version, nospace_cache
403           (nospace_cache since: 3.2, space_cache=v1 and space_cache=v2 since
404           4.5, default: space_cache=v1)
405
406           Options to control the free space cache. The free space cache
407           greatly improves performance when reading block group free space
408           into memory. However, managing the space cache consumes some
409           resources, including a small amount of disk space.
410
411           There are two implementations of the free space cache. The original
412           one, referred to as v1, is the safe default. The v1 space cache can
413           be disabled at mount time with nospace_cache without clearing.
414
415           On very large filesystems (many terabytes) and certain workloads,
416           the performance of the v1 space cache may degrade drastically. The
417           v2 implementation, which adds a new B-tree called the free space
418           tree, addresses this issue. Once enabled, the v2 space cache will
419           always be used and cannot be disabled unless it is cleared. Use
420           clear_cache,space_cache=v1 or clear_cache,nospace_cache to do so.
421           If v2 is enabled, kernels without v2 support will only be able to
422           mount the filesystem in read-only mode. The btrfs(8) command
423           currently only has read-only support for v2. A read-write command
424           may be run on a v2 filesystem by clearing the cache, running the
425           command, and then remounting with space_cache=v2.
426
427           If a version is not explicitly specified, the default
428           implementation will be chosen, which is v1.
429
430       ssd, ssd_spread, nossd, nossd_spread
431           (default: SSD autodetected)
432
433           Options to control SSD allocation schemes. By default, BTRFS will
434           enable or disable SSD optimizations depending on status of a device
435           with respect to rotational or non-rotational type. This is
436           determined by the contents of /sys/block/DEV/queue/rotational). If
437           it is 0, the ssd option is turned on. The option nossd will disable
438           the autodetection.
439
440           The optimizations make use of the absence of the seek penalty
441           that’s inherent for the rotational devices. The blocks can be
442           typically written faster and are not offloaded to separate threads.
443
444               Note
445               Since 4.14, the block layout optimizations have been dropped.
446               This used to help with first generations of SSD devices. Their
447               FTL (flash translation layer) was not effective and the
448               optimization was supposed to improve the wear by better
449               aligning blocks. This is no longer true with modern SSD devices
450               and the optimization had no real benefit. Furthermore it caused
451               increased fragmentation. The layout tuning has been kept intact
452               for the option ssd_spread.
453           The ssd_spread mount option attempts to allocate into bigger and
454           aligned chunks of unused space, and may perform better on low-end
455           SSDs.  ssd_spread implies ssd, enabling all other SSD heuristics as
456           well. The option nossd will disable all SSD options while
457           nossd_spread only disables ssd_spread.
458
459       subvol=path
460           Mount subvolume from path rather than the toplevel subvolume. The
461           path is always treated as relative to the toplevel subvolume. This
462           mount option overrides the default subvolume set for the given
463           filesystem.
464
465       subvolid=subvolid
466           Mount subvolume specified by a subvolid number rather than the
467           toplevel subvolume. You can use btrfs subvolume list of btrfs
468           subvolume show to see subvolume ID numbers. This mount option
469           overrides the default subvolume set for the given filesystem.
470
471               Note
472               if both subvolid and subvol are specified, they must point at
473               the same subvolume, otherwise the mount will fail.
474
475       thread_pool=number
476           (default: min(NRCPUS + 2, 8) )
477
478           The number of worker threads to start. NRCPUS is number of on-line
479           CPUs detected at the time of mount. Small number leads to less
480           parallelism in processing data and metadata, higher numbers could
481           lead to a performance hit due to increased locking contention,
482           process scheduling, cache-line bouncing or costly data transfers
483           between local CPU memories.
484
485       treelog, notreelog
486           (default: on)
487
488           Enable the tree logging used for fsync and O_SYNC writes. The tree
489           log stores changes without the need of a full filesystem sync. The
490           log operations are flushed at sync and transaction commit. If the
491           system crashes between two such syncs, the pending tree log
492           operations are replayed during mount.
493
494               Warning
495               currently, the tree log is replayed even with a read-only
496               mount! To disable that behaviour, also mount with nologreplay.
497           The tree log could contain new files/directories, these would not
498           exist on a mounted filesystem if the log is not replayed.
499
500       usebackuproot
501           (since: 4.6, default: off)
502
503           Enable autorecovery attempts if a bad tree root is found at mount
504           time. Currently this scans a backup list of several previous tree
505           roots and tries to use the first readable. This can be used with
506           read-only mounts as well.
507
508               Note
509               This option has replaced recovery.
510
511       user_subvol_rm_allowed
512           (default: off)
513
514           Allow subvolumes to be deleted by their respective owner.
515           Otherwise, only the root user can do that.
516
517               Note
518               historically, any user could create a snapshot even if he was
519               not owner of the source subvolume, the subvolume deletion has
520               been restricted for that reason. The subvolume creation has
521               been restricted but this mount option is still required. This
522               is a usability issue. Since 4.18, the rmdir(2) syscall can
523               delete an empty subvolume just like an ordinary directory.
524               Whether this is possible can be detected at runtime, see
525               rmdir_subvol feature in FILESYSTEM FEATURES.
526
527   DEPRECATED MOUNT OPTIONS
528       List of mount options that have been removed, kept for backward
529       compatibility.
530
531       recovery
532           (since: 3.2, default: off, deprecated since: 4.5)
533
534               Note
535               this option has been replaced by usebackuproot and should not
536               be used but will work on 4.5+ kernels.
537
538   NOTES ON GENERIC MOUNT OPTIONS
539       Some of the general mount options from mount(8) that affect BTRFS and
540       are worth mentioning.
541
542       noatime
543           under read intensive work-loads, specifying noatime significantly
544           improves performance because no new access time information needs
545           to be written. Without this option, the default is relatime, which
546           only reduces the number of inode atime updates in comparison to the
547           traditional strictatime. The worst case for atime updates under
548           relatime occurs when many files are read whose atime is older than
549           24 h and which are freshly snapshotted. In that case the atime is
550           updated and COW happens - for each file - in bulk. See also
551           https://lwn.net/Articles/499293/ - Atime and btrfs: a bad
552           combination? (LWN, 2012-05-31).
553
554           Note that noatime may break applications that rely on atime uptimes
555           like the venerable Mutt (unless you use maildir mailboxes).
556

FILESYSTEM FEATURES

558       The basic set of filesystem features gets extended over time. The
559       backward compatibility is maintained and the features are optional,
560       need to be explicitly asked for so accidental use will not create
561       incompatibilities.
562
563       There are several classes and the respective tools to manage the
564       features:
565
566       at mkfs time only
567           This is namely for core structures, like the b-tree nodesize or
568           checksum algorithm, see mkfs.btrfs(8) for more details.
569
570       after mkfs, on an unmounted filesystem
571           Features that may optimize internal structures or add new
572           structures to support new functionality, see btrfstune(8). The
573           command btrfs inspect-internal dump-super device will dump a
574           superblock, you can map the value of incompat_flags to the features
575           listed below
576
577       after mkfs, on a mounted filesystem
578           The features of a filesystem (with a given UUID) are listed in
579           /sys/fs/btrfs/UUID/features/, one file per feature. The status is
580           stored inside the file. The value 1 is for enabled and active,
581           while 0 means the feature was enabled at mount time but turned off
582           afterwards.
583
584           Whether a particular feature can be turned on a mounted filesystem
585           can be found in the directory /sys/fs/btrfs/features/, one file per
586           feature. The value 1 means the feature can be enabled.
587
588       List of features (see also mkfs.btrfs(8) section FILESYSTEM FEATURES):
589
590       big_metadata
591           (since: 3.4)
592
593           the filesystem uses nodesize for metadata blocks, this can be
594           bigger than the page size
595
596       compress_lzo
597           (since: 2.6.38)
598
599           the lzo compression has been used on the filesystem, either as a
600           mount option or via btrfs filesystem defrag.
601
602       compress_zstd
603           (since: 4.14)
604
605           the zstd compression has been used on the filesystem, either as a
606           mount option or via btrfs filesystem defrag.
607
608       default_subvol
609           (since: 2.6.34)
610
611           the default subvolume has been set on the filesystem
612
613       extended_iref
614           (since: 3.7)
615
616           increased hardlink limit per file in a directory to 65536, older
617           kernels supported a varying number of hardlinks depending on the
618           sum of all file name sizes that can be stored into one metadata
619           block
620
621       free_space_tree
622           (since: 4.5)
623
624           free space representation using a dedicated b-tree, successor of v1
625           space cache
626
627       metadata_uuid
628           (since: 5.0)
629
630           the main filesystem UUID is the metadata_uuid, which stores the new
631           UUID only in the superblock while all metadata blocks still have
632           the UUID set at mkfs time, see btrfstune(8) for more
633
634       mixed_backref
635           (since: 2.6.31)
636
637           the last major disk format change, improved backreferences, now
638           default
639
640       mixed_groups
641           (since: 2.6.37)
642
643           mixed data and metadata block groups, ie. the data and metadata are
644           not separated and occupy the same block groups, this mode is
645           suitable for small volumes as there are no constraints how the
646           remaining space should be used (compared to the split mode, where
647           empty metadata space cannot be used for data and vice versa)
648
649           on the other hand, the final layout is quite unpredictable and
650           possibly highly fragmented, which means worse performance
651
652       no_holes
653           (since: 3.14)
654
655           improved representation of file extents where holes are not
656           explicitly stored as an extent, saves a few percent of metadata if
657           sparse files are used
658
659       raid1c34
660           (since: 5.5)
661
662           extended RAID1 mode with copies on 3 or 4 devices respectively
663
664       raid56
665           (since: 3.9)
666
667           the filesystem contains or contained a raid56 profile of block
668           groups
669
670       rmdir_subvol
671           (since: 4.18)
672
673           indicate that rmdir(2) syscall can delete an empty subvolume just
674           like an ordinary directory. Note that this feature only depends on
675           the kernel version.
676
677       skinny_metadata
678           (since: 3.10)
679
680           reduced-size metadata for extent references, saves a few percent of
681           metadata
682
683       supported_checksums
684           (since: 5.5)
685
686           list of checksum algorithms supported by the kernel module, the
687           respective modules or built-in implementing the algorithms need to
688           be present to mount the filesystem
689
690   SWAPFILE SUPPORT
691       The swapfile is supported since kernel 5.0. Use swapon(8) to activate
692       the swapfile. There are some limitations of the implementation in btrfs
693       and linux swap subsystem:
694
695       ·   filesystem - must be only single device
696
697       ·   filesystem - must have only single data profile
698
699       ·   swapfile - the containing subvolume cannot be snapshotted
700
701       ·   swapfile - must be preallocated
702
703       ·   swapfile - must be nodatacow (ie. also nodatasum)
704
705       ·   swapfile - must not be compressed
706
707       The limitations come namely from the COW-based design and mapping layer
708       of blocks that allows the advanced features like relocation and
709       multi-device filesystems. However, the swap subsystem expects simpler
710       mapping and no background changes of the file blocks once they’ve been
711       attached to swap.
712
713       With active swapfiles, the following whole-filesystem operations will
714       skip swapfile extents or may fail:
715
716       ·   balance - block groups with swapfile extents are skipped and
717           reported, the rest will be processed normally
718
719       ·   resize grow - unaffected
720
721       ·   resize shrink - works as long as the extents are outside of the
722           shrunk range
723
724       ·   device add - a new device does not interfere with existing swapfile
725           and this operation will work, though no new swapfile can be
726           activated afterwards
727
728       ·   device delete - if the device has been added as above, it can be
729           also deleted
730
731       ·   device replace - ditto
732
733       When there are no active swapfiles and a whole-filesystem exclusive
734       operation is running (ie. balance, device delete, shrink), the
735       swapfiles cannot be temporarily activated. The operation must finish
736       first.
737
738           # truncate -s 0 swapfile
739           # chattr +C swapfile
740           # fallocate -l 2G swapfile
741           # chmod 0600 swapfile
742           # mkswap swapfile
743           # swapon swapfile
744

CHECKSUM ALGORITHMS

746       There are several checksum algorithms supported. The default and
747       backward compatible is crc32c. Since kernel 5.5 there are three more
748       with different characteristics and trade-offs regarding speed and
749       strength. The following list may help you to decide which one to
750       select.
751
752       CRC32C (32bit digest)
753           default, best backward compatibility, very fast, modern CPUs have
754           instruction-level support, not collision-resistant but still good
755           error detection capabilities
756
757       XXHASH (64bit digest)
758           can be used as CRC32C successor, very fast, optimized for modern
759           CPUs utilizing instruction pipelining, good collision resistance
760           and error detection
761
762       SHA256 (256bit digest)
763           a cryptographic-strength hash, relatively slow but with possible
764           CPU instruction acceleration or specialized hardware cards, FIPS
765           certified and in wide use
766
767       BLAKE2b (256bit digest)
768           a cryptographic-strength hash, relatively fast with possible CPU
769           acceleration using SIMD extensions, not standardized but based on
770           BLAKE which was a SHA3 finalist, in wide use, the algorithm used is
771           BLAKE2b-256 that’s optimized for 64bit platforms
772
773       The digest size affects overall size of data block checksums stored in
774       the filesystem. The metadata blocks have a fixed area up to 256bits (32
775       bytes), so there’s no increase. Each data block has a separate checksum
776       stored, with additional overhead of the b-tree leaves.
777
778       Approximate relative performance of the algorithms, measured against
779       CRC32C using reference software implementations on a 3.5GHz intel CPU:
780
781       ┌────────┬─────────────┬───────┐
782       │        │             │       │
783Digest  Cycles/4KiB Ratio 
784       ├────────┼─────────────┼───────┤
785       │        │             │       │
786       │CRC32C  │        1700 │  1.00 │
787       ├────────┼─────────────┼───────┤
788       │        │             │       │
789       │XXHASH  │        2500 │  1.44 │
790       ├────────┼─────────────┼───────┤
791       │        │             │       │
792       │SHA256  │      105000 │    61 │
793       ├────────┼─────────────┼───────┤
794       │        │             │       │
795       │BLAKE2b │       22000 │    13 │
796       └────────┴─────────────┴───────┘
797

FILESYSTEM EXCLUSIVE OPERATIONS

799       There are several operations that affect the whole filesystem and
800       cannot be run in parallel. Attempt to start one while another is
801       running will fail.
802
803       Since kernel 5.10 the currently running operation can be obtained from
804       /sys/fs/UUID/exclusive_operation with following values and operations:
805
806       ·   balance
807
808       ·   device add
809
810       ·   device delete
811
812       ·   device replace
813
814       ·   resize
815
816       ·   swapfile activate
817
818       ·   none
819
820       Enqueuing is supported for several btrfs subcommands so they can be
821       started at once and then serialized.
822

FILESYSTEM LIMITS

824       maximum file name length
825           255
826
827       maximum symlink target length
828           depends on the nodesize value, for 4k it’s 3949 bytes, for larger
829           nodesize it’s 4095 due to the system limit PATH_MAX
830
831           The symlink target may not be a valid path, ie. the path name
832           components can exceed the limits (NAME_MAX), there’s no content
833           validation at symlink(3) creation.
834
835       maximum number of inodes
836           2^64 but depends on the available metadata space as the inodes are
837           created dynamically
838
839       inode numbers
840           minimum number: 256 (for subvolumes), regular files and
841           directories: 257
842
843       maximum file length
844           inherent limit of btrfs is 2^64 (16 EiB) but the linux VFS limit is
845           2^63 (8 EiB)
846
847       maximum number of subvolumes
848           the subvolume ids can go up to 2^64 but the number of actual
849           subvolumes depends on the available metadata space, the space
850           consumed by all subvolume metadata includes bookkeeping of shared
851           extents can be large (MiB, GiB)
852
853       maximum number of hardlinks of a file in a directory
854           65536 when the extref feature is turned on during mkfs (default),
855           roughly 100 otherwise
856
857       minimum filesystem size
858           the minimal size of each device depends on the mixed-bg feature,
859           without that (the default) it’s about 109MiB, with mixed-bg it’s is
860           16MiB
861

BOOTLOADER SUPPORT

863       GRUB2 (https://www.gnu.org/software/grub) has the most advanced support
864       of booting from BTRFS with respect to features.
865
866       U-boot (https://www.denx.de/wiki/U-Boot/) has decent support for
867       booting but not all BTRFS features are implemented, check the
868       documentation.
869
870       EXTLINUX (from the https://syslinux.org project) can boot but does not
871       support all features. Please check the upstream documentation before
872       you use it.
873
874       The first 1MiB on each device is unused with the exception of primary
875       superblock that is on the offset 64KiB and spans 4KiB.
876

FILE ATTRIBUTES

878       The btrfs filesystem supports setting file attributes or flags. Note
879       there are old and new interfaces, with confusing names. The following
880       list should clarify that:
881
882       ·   attributes: chattr(1) or lsattr(1) utilities (the ioctls are
883           FS_IOC_GETFLAGS and FS_IOC_SETFLAGS), due to the ioctl names the
884           attributes are also called flags
885
886       ·   xflags: to distinguish from the previous, it’s extended flags, with
887           tunable bits similar to the attributes but extensible and new bits
888           will be added in the future (the ioctls are FS_IOC_FSGETXATTR and
889           FS_IOC_FSSETXATTR but they are not related to extended attributes
890           that are also called xattrs), there’s no standard tool to change
891           the bits, there’s support in xfs_io(8) as command xfs_io -c chattr
892
893   ATTRIBUTES
894       a
895           append only, new writes are always written at the end of the file
896
897       A
898           no atime updates
899
900       c
901           compress data, all data written after this attribute is set will be
902           compressed. Please note that compression is also affected by the
903           mount options or the parent directory attributes.
904
905           When set on a directory, all newly created files will inherit this
906           attribute.
907
908       C
909           no copy-on-write, file data modifications are done in-place
910
911           When set on a directory, all newly created files will inherit this
912           attribute.
913
914               Note
915               due to implementation limitations, this flag can be set/unset
916               only on empty files.
917
918       d
919           no dump, makes sense with 3rd party tools like dump(8), on BTRFS
920           the attribute can be set/unset but no other special handling is
921           done
922
923       D
924           synchronous directory updates, for more details search open(2) for
925           O_SYNC and O_DSYNC
926
927       i
928           immutable, no file data and metadata changes allowed even to the
929           root user as long as this attribute is set (obviously the exception
930           is unsetting the attribute)
931
932       S
933           synchronous updates, for more details search open(2) for O_SYNC and
934           O_DSYNC
935
936       X
937           no compression, permanently turn off compression on the given file.
938           Any compression mount options will not affect this file.
939
940           When set on a directory, all newly created files will inherit this
941           attribute.
942
943       No other attributes are supported. For the complete list please refer
944       to the chattr(1) manual page.
945
946   XFLAGS
947       There’s overlap of letters assigned to the bits with the attributes,
948       this list refers to what xfs_io(8) provides:
949
950       i
951           immutable, same as the attribute
952
953       a
954           append only, same as the attribute
955
956       s
957           synchronous updates, same as the attribute S
958
959       A
960           no atime updates, same as the attribute
961
962       d
963           no dump, same as the attribute
964

CONTROL DEVICE

966       There’s a character special device /dev/btrfs-control with major and
967       minor numbers 10 and 234 (the device can be found under the misc
968       category).
969
970           $ ls -l /dev/btrfs-control
971           crw------- 1 root root 10, 234 Jan  1 12:00 /dev/btrfs-control
972
973       The device accepts some ioctl calls that can perform following actions
974       on the filesystem module:
975
976       ·   scan devices for btrfs filesystem (ie. to let multi-device
977           filesystems mount automatically) and register them with the kernel
978           module
979
980       ·   similar to scan, but also wait until the device scanning process is
981           finished for a given filesystem
982
983       ·   get the supported features (can be also found under
984           /sys/fs/btrfs/features)
985
986       The device is usually created by a system device node manager (eg.
987       udev), but can be created manually:
988
989           # mknod --mode=600 /dev/btrfs-control c 10 234
990
991       The control device is not strictly required but the device scanning
992       will not work and a workaround would need to be used to mount a
993       multi-device filesystem. The mount option device can trigger the device
994       scanning during mount.
995

FILESYSTEM WITH MULTIPLE PROFILES

997       It is possible that a btrfs filesystem contains multiple block group
998       profiles of the same type. This could happen when a profile conversion
999       using balance filters is interrupted (see btrfs-balance(8)). Some btrfs
1000       commands perform a test to detect this kind of condition and print a
1001       warning like this:
1002
1003           WARNING: Multiple block group profiles detected, see 'man btrfs(5)'.
1004           WARNING:   Data: single, raid1
1005           WARNING:   Metadata: single, raid1
1006
1007       The corresponding output of btrfs filesystem df might look like:
1008
1009           WARNING: Multiple block group profiles detected, see 'man btrfs(5)'.
1010           WARNING:   Data: single, raid1
1011           WARNING:   Metadata: single, raid1
1012           Data, RAID1: total=832.00MiB, used=0.00B
1013           Data, single: total=1.63GiB, used=0.00B
1014           System, single: total=4.00MiB, used=16.00KiB
1015           Metadata, single: total=8.00MiB, used=112.00KiB
1016           Metadata, RAID1: total=64.00MiB, used=32.00KiB
1017           GlobalReserve, single: total=16.25MiB, used=0.00B
1018
1019       There’s more than one line for type Data and Metadata, while the
1020       profiles are single and RAID1.
1021
1022       This state of the filesystem OK but most likely needs the
1023       user/administrator to take an action and finish the interrupted tasks.
1024       This cannot be easily done automatically, also the user knows the
1025       expected final profiles.
1026
1027       In the example above, the filesystem started as a single device and
1028       single block group profile. Then another device was added, followed by
1029       balance with convert=raid1 but for some reason hasn’t finished.
1030       Restarting the balance with convert=raid1 will continue and end up with
1031       filesystem with all block group profiles RAID1.
1032
1033           Note
1034           If you’re familiar with balance filters, you can use
1035           convert=raid1,profiles=single,soft, which will take only the
1036           unconverted single profiles and convert them to raid1. This may
1037           speed up the conversion as it would not try to rewrite the already
1038           convert raid1 profiles.
1039
1040       Having just one profile is desired as this also clearly defines the
1041       profile of newly allocated block groups, otherwise this depends on
1042       internal allocation policy. When there are multiple profiles present,
1043       the order of selection is RAID6, RAID5, RAID10, RAID1, RAID0 as long as
1044       the device number constraints are satisfied.
1045
1046       Commands that print the warning were chosen so they’re brought to user
1047       attention when the filesystem state is being changed in that regard.
1048       This is: device add, device delete, balance cancel, balance pause.
1049       Commands that report space usage: filesystem df, device usage. The
1050       command filesystem usage provides a line in the overall summary:
1051
1052               Multiple profiles:                 yes (data, metadata)
1053

SEE ALSO

1055       acl(5), btrfs(8), chattr(1), fstrim(8), ioctl(2), mkfs.btrfs(8),
1056       mount(8), swapon(8)
1057
1058
1059
1060Btrfs v5.10                       01/19/2021                     BTRFS-MAN5(5)
Impressum