info > BTRFS

📛 NAME

btrfs – a toolbox to manage btrfs filesystems

🚀 Quick Reference

Use CaseCommandDescription
Scan for devicesbtrfs device scanScan all devices for BTRFS filesystems
Show filesystem infobtrfs filesystem showDisplay basic information about BTRFS filesystems
Disk usage overviewbtrfs filesystem df /mntShow space usage per block group
Start balancebtrfs balance start /mntRe‑distribute chunks across devices
Convert data profilebtrfs balance start -dconvert=raid1 /mntChange data profile with balancing
Add a devicebtrfs device add /dev/sdb /mntAdd a new device to the filesystem
Remove a devicebtrfs device delete /dev/sdb /mntRemove a device (data will be relocated)
Replace a devicebtrfs replace start /dev/old /dev/new /mntReplace a failing device
Offline checkbtrfs check /dev/sdaCheck and optionally repair a filesystem
Scrubbtrfs scrub start /mntVerify data integrity and repair if possible
Create subvolumebtrfs subvolume create /mnt/@dataCreate a new subvolume
Delete subvolumebtrfs subvolume delete /mnt/@dataDelete a subvolume
List subvolumesbtrfs subvolume list /mntList all subvolumes of a filesystem
Snapshotbtrfs subvolume snapshot /mnt/@src /mnt/@snapCreate a read‑write snapshot
Send / receivebtrfs send /mnt/@snap | btrfs receive /backupSend snapshot incrementally to another location
Mount with compressionmount -o compress=zstd /dev/sda /mntEnable transparent compression
Mount subvolumemount -o subvol=@ /dev/sda /mntMount a specific subvolume
Mount degradedmount -o degraded /dev/sda /mntAllow mount with missing devices
Create swapfiletruncate -s 0 swapfile && chattr +C swapfile && fallocate -l 2G swapfile && mkswap swapfile && swapon swapfilePrepare and activate a swapfile on BTRFS

📖 SYNOPSIS

btrfs <command> [<args>]

📚 DESCRIPTION

The btrfs utility is a toolbox for managing btrfs filesystems. There are command groups to work with subvolumes, devices, for whole filesystem or other specific actions. See section COMMANDS.

There are also standalone tools for some tasks like btrfs-convert or btrfstune that were separate historically and/or haven’t been merged to the main utility. See section STANDALONE TOOLS for more details.

For other topics (mount options, etc) please refer to the separate manual page btrfs(5).

💬 COMMAND SYNTAX

Any command name can be shortened so long as the shortened form is unambiguous, however it is recommended to use full command names in scripts. All command groups have their manual page named btrfs-<group>.

For example: it is possible to run btrfs sub snaps instead of btrfs subvolume snapshot. But btrfs file s is not allowed, because file s may be interpreted both as filesystem show and as filesystem sync.

If the command name is ambiguous, the list of conflicting options is printed.

For an overview of a given command use btrfs command --help or btrfs [command...] --help --full to print all available options.

🛠️ COMMANDS

🔧 STANDALONE TOOLS

New functionality could be provided using a standalone tool. If the functionality proves to be useful, then the standalone tool is declared obsolete and its functionality is copied to the main tool. Obsolete tools are removed after a long (years) depreciation period.

Tools that are still in active use without an equivalent in btrfs:

Deprecated and obsolete tools:

For space‑constrained environments, it’s possible to build a single binary with functionality of several standalone tools. This follows the concept of busybox where the file name selects the functionality. This works for symlinks or hardlinks. The full list can be obtained by btrfs help --box.

🚪 EXIT STATUS

btrfs returns a zero exit status if it succeeds. Non zero is returned in case of failure.

🌐 AVAILABILITY

btrfs is part of btrfs-progs. Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for further details.

📚 SEE ALSO

btrfs(5), btrfs-balance(8), btrfs-check(8), btrfs-convert(8), btrfs-device(8), btrfs-filesystem(8), btrfs-inspect-internal(8), btrfs-property(8), btrfs-qgroup(8), btrfs-quota(8), btrfs-receive(8), btrfs-replace(8), btrfs-rescue(8), btrfs-restore(8), btrfs-scrub(8), btrfs-send(8), btrfs-subvolume(8), btrfstune(8), mkfs.btrfs(8)


📛 NAME

btrfs‑man5 – topics about the BTRFS filesystem (mount options, supported file attributes and other)

📚 DESCRIPTION

This document describes topics related to BTRFS that are not specific to the tools. Currently covers:

  1. mount options
  2. filesystem features
  3. checksum algorithms
  4. compression
  5. filesystem exclusive operations
  6. filesystem limits
  7. bootloader support
  8. file attributes
  9. zoned mode
  10. control device
  11. filesystems with multiple block group profiles
  12. seeding device
  13. raid56 status and recommended practices
  14. storage model
  15. hardware considerations

⚙️ MOUNT OPTIONS

This section describes mount options specific to BTRFS. For generic mount options please refer to mount(8). Options are sorted alphabetically (discarding the no prefix).

Note — most mount options apply to the whole filesystem and only options in the first mounted subvolume will take effect. This is due to lack of implementation and may change in the future. This means that (for example) you can’t set per‑subvolume nodatacow, nodatasum, or compress using mount options. This should eventually be fixed, but it has proved to be difficult to implement correctly within the Linux VFS framework.

Mount options are processed in order, only the last occurrence of an option takes effect and may disable other options due to constraints (see eg. nodatacow and compress). The output of mount command shows which options have been applied.

🔑 acl, noacl

(default: on)

Enable/disable support for Posix Access Control Lists (ACLs). See the acl(5) manual page for more information about ACLs.

The support for ACL is build‑time configurable (BTRFS_FS_POSIX_ACL) and mount fails if acl is requested but the feature is not compiled in.

🧩 autodefrag, noautodefrag

(since: 3.0, default: off)

Enable automatic file defragmentation. When enabled, small random writes into files (in a range of tens of kilobytes, currently it’s 64K) are detected and queued up for the defragmentation process. Not well suited for large database workloads.

The read latency may increase due to reading the adjacent blocks that make up the range for defragmentation, successive write will merge the blocks in the new location.

Warning — Defragmenting with Linux kernel versions < 3.9 or >= 3.14‑rc2 as well as with Linux stable kernel versions >= 3.10.31, >= 3.12.12 or >= 3.13.4 will break up the reflinks of COW data (for example files copied with cp --reflink, snapshots or de‑duplicated data). This may cause considerable increase of space usage depending on the broken up reflinks.

🛡️ barrier, nobarrier

(default: on)

Ensure that all IO write operations make it through the device cache and are stored permanently when the filesystem is at its consistency checkpoint. This typically means that a flush command is sent to the device that will synchronize all pending data and ordinary metadata blocks, then writes the superblock and issues another flush.

The write flushes incur a slight hit and also prevent the IO block scheduler to reorder requests in a more effective way. Disabling barriers gets rid of that penalty but will most certainly lead to a corrupted filesystem in case of a crash or power loss. The ordinary metadata blocks could be yet unwritten at the time the new superblock is stored permanently, expecting that the block pointers to metadata were stored permanently before.

On a device with a volatile battery‑backed write‑back cache, the nobarrier option will not lead to filesystem corruption as the pending blocks are supposed to make it to the permanent storage.

🔍 check_int, check_int_data, check_int_print_mask=value

(since: 3.0, default: off)

These debugging options control the behavior of the integrity checking module (the BTRFS_FS_CHECK_INTEGRITY config option required). The main goal is to verify that all blocks from a given transaction period are properly linked.

check_int enables the integrity checker module, which examines all block write requests to ensure on‑disk consistency, at a large memory and CPU cost.

check_int_data includes extent data in the integrity checks, and implies the check_int option.

check_int_print_mask takes a bitmask of BTRFSIC_PRINT_MASK_* values as defined in fs/btrfs/check-integrity.c, to control the integrity checker module behavior.

🧹 clear_cache

Force clearing and rebuilding of the disk space cache if something has gone wrong. See also: space_cache.

⏱️ commit=seconds

(since: 3.12, default: 30)

Set the interval of periodic transaction commit when data are synchronized to permanent storage. Higher interval values lead to larger amount of unwritten data, which has obvious consequences when the system crashes. The upper bound is not forced, but a warning is printed if it’s more than 300 seconds (5 minutes). Use with care.

🗜️ compress, compress=type[:level], compress‑force, compress‑force=type[:level]

(default: off, level support since: 5.1)

Control BTRFS file data compression. Type may be specified as zlib, lzo, zstd or no (for no compression, used for remounting). If no type is specified, zlib is used. If compress‑force is specified, then compression will always be attempted, but the data may end up uncompressed if the compression would make them larger.

Both zlib and zstd (since version 5.1) expose the compression level as a tunable knob. Zlib accepts the range [1, 9] and zstd accepts [1, 15]. If no level is set, both use a default level of 3. The value 0 is an alias for the default level.

Otherwise some simple heuristics are applied to detect an incompressible file. If the first blocks written to a file are not compressible, the whole file is permanently marked to skip compression. As this is too simple, the compress‑force is a workaround that will compress most of the files at the cost of some wasted CPU cycles on failed attempts. Since kernel 4.15, a set of heuristic algorithms have been improved by using frequency sampling, repeated pattern detection and Shannon entropy calculation to avoid that.

Note — If compression is enabled, nodatacow and nodatasum are disabled.

🐄 datacow, nodatacow

(default: on)

Enable data copy‑on‑write for newly created files. Nodatacow implies nodatasum, and disables compression. All files created under nodatacow are also set the NOCOW file attribute (see chattr(1)).

Note — If nodatacow or nodatasum are enabled, compression is disabled. Updates in‑place improve performance for workloads that do frequent overwrites, at the cost of potential partial writes, in case the write is interrupted (system crash, device failure).

✅ datasum, nodatasum

(default: on)

Enable data checksumming for newly created files. Datasum implies datacow, ie. the normal mode of operation. All files created under nodatasum inherit the “no checksums” property, however there’s no corresponding file attribute (see chattr(1)).

Note — If nodatacow or nodatasum are enabled, compression is disabled. There is a slight performance gain when checksums are turned off, the corresponding metadata blocks holding the checksums do not need to be updated. The cost of checksumming of the blocks in memory is much lower than the IO, modern CPUs feature hardware support of the checksumming algorithm.

⚠️ degraded

(default: off)

Allow mounts with less devices than the RAID profile constraints require. A read‑write mount (or remount) may fail when there are too many devices missing, for example if a stripe member is completely missing from RAID0.

Since 4.14, the constraint checks have been improved and are verified on the chunk level, not at the device level. This allows degraded mounts of filesystems with mixed RAID profiles for data and metadata, even if the device number constraints would not be satisfied for some of the profiles.

Example: metadata – raid1, data – single, devices – /dev/sda, /dev/sdb. Suppose the data are completely stored on sda, then missing sdb will not prevent the mount, even if 1 missing device would normally prevent (any) single profile to mount. In case some of the data chunks are stored on sdb, then the constraint of single/data is not satisfied and the filesystem cannot be mounted.

🔌 device=devicepath

Specify a path to a device that will be scanned for BTRFS filesystem during mount. This is usually done automatically by a device manager (like udev) or using the btrfs device scan command (eg. run from the initial ramdisk). In cases where this is not possible the device mount option can help.

Note — booting eg. a RAID1 system may fail even if all filesystem’s device paths are provided as the actual device nodes may not be discovered by the system at that point.

🗑️ discard, discard=sync, discard=async, nodiscard

(default: off, async support since: 5.6)

Enable discarding of freed file blocks. This is useful for SSD devices, thinly provisioned LUNs, or virtual machine images; however, every storage layer must support discard for it to work.

In the synchronous mode (sync or without option value), lack of asynchronous queued TRIM on the backing device TRIM can severely degrade performance, because a synchronous TRIM operation will be attempted instead. Queued TRIM requires newer than SATA revision 3.1 chipsets and devices.

The asynchronous mode (async) gathers extents in larger chunks before sending them to the devices for TRIM. The overhead and performance impact should be negligible compared to the previous mode and it’s supposed to be the preferred mode if needed.

If it is not necessary to immediately discard freed blocks, then the fstrim tool can be used to discard all free blocks in a batch. Scheduling a TRIM during a period of low system activity will prevent latent interference with the performance of other operations.

📢 enospc_debug, noenospc_debug

(default: off)

Enable verbose output for some ENOSPC conditions. It’s safe to use but can be noisy if the system reaches near‑full state.

💥 fatal_errors=action

(since: 3.4, default: bug)

Action to take when encountering a fatal error.

📦 flushoncommit, noflushoncommit

(default: off)

This option forces any data dirtied by a write in a prior transaction to commit as part of the current commit, effectively a full filesystem sync.

This makes the committed state a fully consistent view of the file system from the application’s perspective (i.e. it includes all completed file system operations). This was previously the behavior only when a snapshot was created.

When off, the filesystem is consistent but buffered writes may last more than one transaction commit.

🧨 fragment=type

(depends on compile‑time option BTRFS_DEBUG, since: 4.4, default: off)

A debugging helper to intentionally fragment given type of block groups. The type can be data, metadata or all. This mount option should not be used outside of debugging environments.

🚫 nologreplay

(default: off, even read‑only)

The tree‑log contains pending updates to the filesystem until the full commit. The log is replayed on next mount, this can be disabled by this option. See also treelog. Note that nologreplay is the same as norecovery.

Warning — currently, the tree log is replayed even with a read‑only mount! To disable that behaviour, mount also with nologreplay.

📏 max_inline=bytes

(default: min(2048, page size))

Specify the maximum amount of space that can be inlined in a metadata B‑tree leaf. The value is specified in bytes, optionally with a K suffix (case insensitive). In practice this value is limited by the filesystem block size (named sectorsize at mkfs time) and memory page size of the system. In case of sectorsize limit, there’s some space unavailable due to leaf headers. For example, a 4k sectorsize, maximum size of inline data is about 3900 bytes.

Inlining can be completely turned off by specifying 0. This will increase data block slack if file sizes are much smaller than block size but will reduce metadata consumption in return.

📊 metadata_ratio=value

(default: 0, internal logic)

Specifies that 1 metadata chunk should be allocated after every value data chunks. Default behaviour depends on internal logic, some percent of unused metadata space is attempted to be maintained but is not always possible if there’s not enough space left for chunk allocation. The option could be useful to override the internal logic in favor of the metadata allocation if the expected workload is supposed to be metadata intense (snapshots, reflinks, xattrs, inlined files).

🛑 norecovery

(since: 4.5, default: off)

Do not attempt any data recovery at mount time. This will disable logreplay and avoids other write operations. Note that this option is the same as nologreplay.

🔄 rescan_uuid_tree

(since: 3.12, default: off)

Force check and rebuild procedure of the UUID tree. This should not normally be needed.

🚑 rescue

(since: 5.9)

Modes allowing mount with damaged filesystem structures.

⏸️ skip_balance

(since: 3.3, default: off)

Skip automatic resume of an interrupted balance operation. The operation can later be resumed with btrfs balance resume, or the paused state can be removed with btrfs balance cancel. The default behaviour is to resume an interrupted balance immediately after a volume is mounted.

💾 space_cache, space_cache=version, nospace_cache

(nospace_cache since: 3.2, space_cache=v1 and space_cache=v2 since 4.5, default: space_cache=v1)

Options to control the free space cache. The free space cache greatly improves performance when reading block group free space into memory. However, managing the space cache consumes some resources, including a small amount of disk space.

There are two implementations. The original v1 is the safe default. The v1 space cache can be disabled at mount time with nospace_cache without clearing.

On very large filesystems (many terabytes) and certain workloads, the performance of the v1 space cache may degrade drastically. The v2 implementation adds a new B‑tree called the free space tree. Once enabled, the v2 space cache will always be used and cannot be disabled unless it is cleared. Use clear_cache,space_cache=v1 or clear_cache,nospace_cache. If v2 is enabled, kernels without v2 support will only be able to mount the filesystem in read‑only mode.

The btrfs-check(8) and mkfs.btrfs(8) commands have full v2 free space cache support since v4.19.

💿 ssd, ssd_spread, nossd, nossd_spread

(default: SSD autodetected)

Options to control SSD allocation schemes. By default, BTRFS will enable or disable SSD optimizations depending on whether a device reports as rotational (contents of /sys/block/DEV/queue/rotational). If it is 0, the ssd option is turned on.

The ssd_spread mount option attempts to allocate into bigger and aligned chunks of unused space, and may perform better on low‑end SSDs. ssd_spread implies ssd. The option nossd will disable all SSD options while nossd_spread only disables ssd_spread.

📂 subvol=path

Mount subvolume from path rather than the toplevel subvolume. The path is always treated as relative to the toplevel subvolume. This mount option overrides the default subvolume set for the given filesystem.

🆔 subvolid=subvolid

Mount subvolume specified by a subvolid number rather than the toplevel subvolume. You can use btrfs subvolume list or btrfs subvolume show to see subvolume ID numbers. This mount option overrides the default subvolume set for the given filesystem.

Note — if both subvolid and subvol are specified, they must point at the same subvolume, otherwise the mount will fail.

🧵 thread_pool=number

(default: min(NRCPUS + 2, 8))

The number of worker threads to start. NRCPUS is number of on‑line CPUs detected at the time of mount. Small number leads to less parallelism in processing data and metadata, higher numbers could lead to a performance hit due to increased locking contention, process scheduling, cache‑line bouncing or costly data transfers between local CPU memories.

📝 treelog, notreelog

(default: on)

Enable the tree logging used for fsync and O_SYNC writes. The tree log stores changes without the need of a full filesystem sync. The log operations are flushed at sync and transaction commit. If the system crashes between two such syncs, the pending tree log operations are replayed during mount.

Warning — currently, the tree log is replayed even with a read‑only mount! To disable that behaviour, also mount with nologreplay.

🪄 usebackuproot

(since: 4.6, default: off)

Enable autorecovery attempts if a bad tree root is found at mount time. Currently this scans a backup list of several previous tree roots and tries to use the first readable. This can be used with read‑only mounts as well.

👤 user_subvol_rm_allowed

(default: off)

Allow subvolumes to be deleted by their respective owner. Otherwise, only the root user can do that.

Note — historically, any user could create a snapshot even if he was not owner of the source subvolume, the subvolume deletion has been restricted for that reason. The subvolume creation has been restricted but this mount option is still required. Since 4.18, the rmdir(2) syscall can delete an empty subvolume just like an ordinary directory.

🕰️ DEPRECATED MOUNT OPTIONS

List of mount options that have been removed, kept for backward compatibility.

recovery

(since: 3.2, default: off, deprecated since: 4.5)

Note — this option has been replaced by usebackuproot and should not be used but will work on 4.5+ kernels.

inode_cache, noinode_cache

(removed in: 5.11, since: 3.0, default: off)

Note — the functionality has been removed in 5.11, any stale data created by previous use of the inode_cache option can be removed by btrfs check --clear-ino-cache.

📝 NOTES ON GENERIC MOUNT OPTIONS

Some general mount options from mount(8) that affect BTRFS and are worth mentioning.

noatime — under read intensive workloads, specifying noatime significantly improves performance because no new access time information needs to be written. Without this option, the default is relatime, which only reduces the number of inode atime updates. The worst case for atime updates under relatime occurs when many files are read whose atime is older than 24h and which are freshly snapshotted. In that case the atime is updated and COW happens – for each file – in bulk. Note that noatime may break applications that rely on atime uptimes like the venerable Mutt (unless you use maildir mailboxes).

🛠️ FILESYSTEM FEATURES

The basic set of filesystem features gets extended over time. Backward compatibility is maintained and the features are optional, need to be explicitly asked for so accidental use will not create incompatibilities.

There are several classes and the respective tools to manage the features:

List of features (see also mkfs.btrfs(8) section FILESYSTEM FEATURES):

🔄 SWAPFILE SUPPORT

The swapfile is supported since kernel 5.0. Use swapon(8) to activate it. There are some limitations:

The limitations come from the COW‑based design and mapping layer that allows advanced features. With active swapfiles, the following whole‑filesystem operations will skip swapfile extents or may fail:

To create and activate a swapfile run:

# truncate -s 0 swapfile
# chattr +C swapfile
# fallocate -l 2G swapfile
# chmod 0600 swapfile
# mkswap swapfile
# swapon swapfile

Add the following entry to /etc/fstab:

/path/swapfile        none        swap        defaults      0 0

🔐 CHECKSUM ALGORITHMS

Several checksum algorithms are supported. The default and backward compatible is crc32c. Since kernel 5.5 there are three more with different characteristics.

The digest size affects overall size of data block checksums stored. The metadata blocks have a fixed area up to 256bits, so no increase.

Approximate relative performance (measured against CRC32C using reference software implementations on a 3.5GHz intel CPU):

DigestCycles/4KiBRatioImplementation
CRC32C17001.00CPU instruction
XXHASH25001.44reference impl.
SHA25610500061reference impl.
SHA2563600021libgcrypt/AVX2
SHA2566300037libsodium/AVX2
BLAKE2b2200013reference impl.
BLAKE2b1900011libgcrypt/AVX2
BLAKE2b1900011libsodium/AVX2

Many kernels are configured with SHA256 as built‑in and not as a module. Accelerated versions are provided by modules and must be loaded explicitly (modprobe sha256) before mounting the filesystem.

🗜️ COMPRESSION

Btrfs supports transparent file compression. Three algorithms are available: ZLIB, LZO and ZSTD (since v4.14). Compression is on a file by file basis.

To enable compression, mount with compress or compress‑force. Please refer to section MOUNT OPTIONS.

Basic characteristics:

AlgorithmPropertiesDetails
ZLIBslower, higher compression ratiolevels: 1‑9, default 3; good backward compatibility
LZOfaster compression and decompression, worse rationo levels; good backward compatibility
ZSTDcompression comparable to zlib with higher speedslevels: 1‑15; since 4.14, levels since 5.1

📦 INCOMPRESSIBLE DATA

If the first portion of data being compressed is not smaller than the original, compression of the file is disabled – unless the filesystem is mounted with compress‑force. A flag (NOCOMPRESS) is set and it’s sticky. The flag can also be set by chattr +m or by properties.

🧠 PRE‑COMPRESSION HEURISTICS

The heuristics perform quick statistical tests on the data before compressing: data sampling, long repeated pattern detection, byte frequency, Shannon entropy.

🔗 COMPATIBILITY WITH OTHER FEATURES

Compression is done using the COW mechanism so it’s incompatible with nodatacow. Direct IO works on compressed files but will fall back to buffered writes. Currently nodatasum and compression don’t work together.

🔒 FILESYSTEM EXCLUSIVE OPERATIONS

There are several operations that affect the whole filesystem and cannot be run in parallel. Attempt to start one while another is running will fail.

Since kernel 5.10 the currently running operation can be obtained from /sys/fs/UUID/exclusive_operation with values:

Enqueuing is supported for several btrfs subcommands so they can be started at once and then serialized.

📏 FILESYSTEM LIMITS

💻 BOOTLOADER SUPPORT

GRUB2 (https://www.gnu.org/software/grub) has the most advanced support of booting from BTRFS.

U‑boot (https://www.denx.de/wiki/U-Boot/) has decent support but not all BTRFS features are implemented.

EXTLINUX (from https://syslinux.org) can boot but does not support all features.

The first 1MiB on each device is unused with the exception of primary superblock at offset 64KiB spanning 4KiB.

🏷️ FILE ATTRIBUTES

The btrfs filesystem supports setting file attributes or flags. There are old and new interfaces:

ATTRIBUTES

No other attributes are supported. For the complete list please refer to the chattr(1) manual page.

XFLAGS

Overlap of letters assigned to the bits with attributes, this list refers to what xfs_io(8) provides:

🗂️ ZONED MODE

Since version 5.12 btrfs supports so called zoned mode. This is a special on‑disk format and allocation/write strategy that’s friendly to zoned devices (SMR/ZBC/ZNS in host‑managed mode). The zone size depends on the device, typical sizes are 256MiB or 1GiB, and must be a power of two.

REQUIREMENTS, LIMITATIONS

INCOMPATIBLE FEATURES

The main constraint of zoned devices is lack of in‑place update, incompatible with:

Initial support lacks some features: only single profile is supported, and fstrim due to dependency on v1 free space cache.

SUPER BLOCK

The super block is handled as a ring buffer in two consecutive zones, starting from offsets 0, 512G and 4TiB. Each new super block is appended to the end of the zone; once filled, the zone is reset and writes continue to the next one.

🎛️ CONTROL DEVICE

There’s a character special device /dev/btrfs‑control with major/minor 10 and 234.

$ ls -l /dev/btrfs-control
crw------- 1 root root 10, 234 Jan  1 12:00 /dev/btrfs-control

The device accepts ioctl calls for: scanning devices, waiting for scan finish, getting supported features. It is created when btrfs is initialized. If accidentally deleted, it can be recreated by:

# mknod --mode=600 /dev/btrfs-control c 10 234

or (since 5.11) by # btrfs rescue create-control-device.

🔀 FILESYSTEM WITH MULTIPLE PROFILES

It is possible that a btrfs filesystem contains multiple block group profiles of the same type. This could happen when a profile conversion using balance filters is interrupted. Some btrfs commands print a warning like:

WARNING: Multiple block group profiles detected, see 'man btrfs(5)'.
WARNING:   Data: single, raid1
WARNING:   Metadata: single, raid1

The corresponding output of btrfs filesystem df might show multiple lines per type. This state is OK but most likely needs the user to finish the interrupted tasks. Restarting the balance with convert=raid1 will continue and end up with all block group profiles RAID1.

Note — If you’re familiar with balance filters, you can use convert=raid1,profiles=single,soft to only convert the unconverted single profiles, speeding up the conversion.

Having just one profile is desired as this also clearly defines the profile of newly allocated block groups. When multiple profiles are present, the order of selection is RAID6, RAID5, RAID10, RAID1, RAID0 as long as device number constraints are satisfied.

🌱 SEEDING DEVICE

The COW mechanism and multiple devices enable a seeding device: extending a read‑only filesystem with another device that captures all writes. The seeding device starts as a normal filesystem, once the contents is ready, btrfstune -S 1 flags it as a seeding device. Mounting such device will not allow any writes, except adding a new device by btrfs device add. Then the filesystem can be remounted as read‑write.

Example:

# mkfs.btrfs /dev/sda
# mount /dev/sda /mnt/mnt1
# ... fill mnt1 with data
# umount /mnt/mnt1
# btrfstune -S 1 /dev/sda
# mount /dev/sda /mnt/mnt1
# btrfs device add /dev/sdb /mnt
# mount -o remount,rw /mnt/mnt1
# ... /mnt/mnt1 is now writable

The writable device can be decoupled from the seeding device and used independently:

# btrfs device delete /dev/sda /mnt/mnt1

Several things to note: it’s recommended to use only single device for the seeding device; block group profiles single and dup support the usecases above; the label is copied from the seeding device and can be changed; each new mount of the seeding device gets a new random UUID.

⚠️ RAID56 STATUS AND RECOMMENDED PRACTICES

The RAID56 feature provides striping and parity over several devices, same as traditional RAID5/6. There are some implementation and design deficiencies that make it unreliable for some corner cases and the feature should not be used in production, only for evaluation or testing. The power failure safety for metadata with RAID56 is not 100%.

Metadata

Do not use raid5 nor raid6 for metadata. Use raid1 or raid1c3 respectively. Recovering from one missing device will only need to access the remaining copy, unlike striped profiles that would need all devices all the time.

Missing/incomplete support

When RAID56 is on the same filesystem with different raid profiles, the space reporting may be inaccurate. Scrub on a RAID56 filesystem is started on all devices, degrading performance; workaround is to start it on each device separately. The write hole problem.

💾 STORAGE MODEL

A storage model captures key physical aspects of data structure in a data store. BTRFS is based on a COW (copy on write) mode, not updating data in place but writing a new copy and atomically switching pointers.

The following assumptions about storage devices are considered (sorted by importance):

  1. atomicity of reads and writes of blocks/sectors
  2. a flush command that instructs the device to forcibly order writes before and after the command
  3. data sent to write to a given device offset will be written without further changes to the data and to the offset
  4. writes can be reordered by the device, unless explicitly serialized by the flush command
  5. reads and writes can be freely reordered and interleaved

WHEN THINGS GO WRONG

No or partial atomicity (1) — Problem: partial block contents (torn write). Detection: checksum mismatch on read. Repair: use another copy or rebuild from multiple blocks.

The flush command does not flush (2) — the most serious problem, impossible to mitigate perfectly. Writes from one generation could bleed to another, leaving data inconsistent after a crash.

Data get silently changed on write (3) — Detection: checksum mismatch. Repair: use another copy or rebuild.

Data written to another offset (ghost write) — filesystem has no information when it happens. Metadata blocks have an embedded block number for verification.

🖥️ HARDWARE CONSIDERATIONS

MAIN MEMORY

Data structures and raw data blocks are temporarily stored in computer memory before writing. Memory bit flips can have vast consequences. ECC memory lowers the chances, but not always available. Run memtest, particularly under heavy load.

DIRECT MEMORY ACCESS (DMA)

DMA transfers performed by device drivers may accidentally corrupt other pages. Use up‑to‑date kernels; quirks are added when found.

ROTATIONAL DISKS (HDD)

Rotational HDDs typically fail at the level of individual sectors. Read failures return EIO. Check smartctl for potential issues. Cables can cause problems if not attached properly.

SOLID STATE DRIVES (SSD)

Data stored in cells grouped in blocks with limited number of resets. Firmware tries to avoid unnecessary resets. Observations show that the whole electronic fails at once or affects a lot of data. Run smartctl or self‑tests. Metadata writes tend to be the biggest component of lifetime writes; DUP profiles may affect reliability in both ways depending on device class.

NVM EXPRESS (NVMe)

Persistent memory usually connected over a system bus, an order of magnitude faster than SSD. Errors may exhibit as random bit flips or IO failures. Self‑tests via smartctl can help.

DRIVE FIRMWARE

Firmware bugs can cause a wide range of corruptions. Check for firmware updates, use up‑to‑date kernels.

SD FLASH CARDS

Low power flash memory in detachable card package. Adding redundancy like DUP profiles can help, but a full backup may be the best option once problems appear.

HARDWARE AS THE MAIN SOURCE OF FILESYSTEM CORRUPTIONS

If you use unreliable hardware and don’t know about that, don’t blame the filesystem when it tells you.

📚 SEE ALSO

acl(5), btrfs(8), chattr(1), fstrim(8), ioctl(2), mkfs.btrfs(8), mount(8), swapon(8)

BTRFS
📛 NAME 🚀 Quick Reference 📖 SYNOPSIS 📚 DESCRIPTION 💬 COMMAND SYNTAX 🛠️ COMMANDS 🔧 STANDALONE TOOLS 🚪 EXIT STATUS 🌐 AVAILABILITY 📚 SEE ALSO 📛 NAME 📚 DESCRIPTION ⚙️ MOUNT OPTIONS
🔑 acl, noacl 🧩 autodefrag, noautodefrag 🛡️ barrier, nobarrier 🔍 check_int, check_int_data, check_int_print_mask=value 🧹 clear_cache ⏱️ commit=seconds 🗜️ compress, compress=type[:level], compress‑force, compress‑force=type[:level] 🐄 datacow, nodatacow ✅ datasum, nodatasum ⚠️ degraded 🔌 device=devicepath 🗑️ discard, discard=sync, discard=async, nodiscard 📢 enospc_debug, noenospc_debug 💥 fatal_errors=action 📦 flushoncommit, noflushoncommit 🧨 fragment=type 🚫 nologreplay 📏 max_inline=bytes 📊 metadata_ratio=value 🛑 norecovery 🔄 rescan_uuid_tree 🚑 rescue ⏸️ skip_balance 💾 space_cache, space_cache=version, nospace_cache 💿 ssd, ssd_spread, nossd, nossd_spread 📂 subvol=path 🆔 subvolid=subvolid 🧵 thread_pool=number 📝 treelog, notreelog 🪄 usebackuproot 👤 user_subvol_rm_allowed 🕰️ DEPRECATED MOUNT OPTIONS 📝 NOTES ON GENERIC MOUNT OPTIONS
🛠️ FILESYSTEM FEATURES
🔄 SWAPFILE SUPPORT
🔐 CHECKSUM ALGORITHMS 🗜️ COMPRESSION
📦 INCOMPRESSIBLE DATA 🧠 PRE‑COMPRESSION HEURISTICS 🔗 COMPATIBILITY WITH OTHER FEATURES
🔒 FILESYSTEM EXCLUSIVE OPERATIONS 📏 FILESYSTEM LIMITS 💻 BOOTLOADER SUPPORT 🏷️ FILE ATTRIBUTES
ATTRIBUTES XFLAGS
🗂️ ZONED MODE
REQUIREMENTS, LIMITATIONS INCOMPATIBLE FEATURES SUPER BLOCK
🎛️ CONTROL DEVICE 🔀 FILESYSTEM WITH MULTIPLE PROFILES 🌱 SEEDING DEVICE ⚠️ RAID56 STATUS AND RECOMMENDED PRACTICES
Metadata Missing/incomplete support
💾 STORAGE MODEL
WHEN THINGS GO WRONG
🖥️ HARDWARE CONSIDERATIONS
MAIN MEMORY DIRECT MEMORY ACCESS (DMA) ROTATIONAL DISKS (HDD) SOLID STATE DRIVES (SSD) NVM EXPRESS (NVMe) DRIVE FIRMWARE SD FLASH CARDS HARDWARE AS THE MAIN SOURCE OF FILESYSTEM CORRUPTIONS
📚 SEE ALSO

Generated by phpman v4.9.26-1-g511901d Author: Che Dong Under GNU General Public License
2026-08-09 09:59 @2600:1f28:365:80b0:50b3:453e:ff52:20f7
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format