MKFS.BTRFS(8)
๐ mkfs.btrfs(8) ๐
okay bestie, settle in, because this is the page for mkfs.btrfs โ yes, that's section 8 of the BTRFS manual, and yes, we're about to make an entire filesystem out of thin air. this one's long so buckle up ๐ฆ
๐ NAME ๐
mkfs.btrfs โ create a btrfs filesystem โจ
๐ธ SYNOPSIS ๐ธ
mkfs.btrfs [options] <device> [<device>...]
๐ซ DESCRIPTION ๐ซ
so here's the vibe: mkfs.btrfs is the tool that creates the btrfs filesystem on one device or, like, a whole lil squad of devices. the device is usually a block device, but it can absolutely be a file-backed image too, no gatekeeping. when you've got multiple devices, they get grouped together by the UUID of the filesystem. iconic. ๐
before you can mount a filesystem like that, the kernel module has to know about all the devices โ either by running btrfs device scan beforehand, or by using the device mount option. the MULTIPLE DEVICES section has the full tea. ๐
the default block group profiles for data and metadata depend on how many devices you have and possibly other factors. it's recommended to pick specific profiles, but honestly the defaults should be OK and they leave room for future conversions to other profiles. for the deep dive check out the options -d and -m, and for converting profiles after mkfs, go see btrfs-balance(8). ๐ซถ
โจ OPTIONS โจ
-b,--byte-count <size>โ sets the size of each device as seen by the filesystem. if you don't set it, the entire device size is used. the total filesystem size ends up being the sum of all the device sizes, so for a single-device filesystem this option basically just says "hey, the filesystem is this big." ๐--csum <type>,--checksum <type>โ pick your checksum algorithm. default iscrc32c. valid values arecrc32c,xxhash,sha256orblake2. to mount a filesystem like this, the kernel has to support the checksums too, so don't get cute. see the CHECKSUM ALGORITHMS section inbtrfs(5). ๐-d,--data <profile>โ sets the profile for the data block groups. valid values areraid0,raid1,raid1c3,raid1c4,raid5,raid6,raid10orsingleordup(case does not matter, we're chill like that). check the DUP PROFILES ON A SINGLE DEVICE section for more.
on multiple devices, the default was raid0 until version 5.7, while it's single since version 5.8. you can still select raid0 manually, but ngl it was not suitable as default. ๐
-m,--metadata <profile>โ sets the profile for the metadata block groups. valid values areraid0,raid1,raid1c3,raid1c4,raid5,raid6,raid10,singleordup(case does not matter).
the default on a single device filesystem is DUP and it's recommended for metadata in general. the duplication might not be necessary in some use cases and it's up to the user to change that at mkfs time or later. this depends on hardware that could potentially deduplicate the blocks again, but that cannot be detected at mkfs time. ๐คท
Note: up to version 5.14 there was a detection of a SSD device (more precisely if it's a rotational device, determined by the contents of the file/sys/block/DEV/queue/rotational) that used to selectsingle. this changed in version 5.15 to be alwaysdup. heads up that the rotational status can be arbitrarily set by the underlying block device driver and may not reflect the true status (network block device, memory-backed SCSI devices, real block device behind some additional device mapper layer, etc). it's recommended to always set the options--data/--metadatato avoid confusion and unexpected results. see the DUP PROFILES ON A SINGLE DEVICE section for more details.
on multiple devices the default is raid1. ๐ซ
-M,--mixedโ normally the data and metadata block groups are isolated. mixed mode removes that isolation and stores both types in the same block group type. this helps you use the free space regardless of its purpose and is suitable for small devices. the separate allocation of block groups leads to a situation where space reserved for the other block group type is not available for allocation, which can lead to anENOSPCstate. ๐ญ
the recommended size for mixed mode is for filesystems less than 1GiB. the soft recommendation is to use it for filesystems smaller than 5GiB. mixed mode may lead to degraded performance on larger filesystems, but is otherwise usable, even on multiple devices.
the nodesize and sectorsize must be equal, and the block group types must match.
Note: versions up to 4.2.x forced the mixed mode for devices smaller than 1GiB. this has been removed in 4.3+ as it caused some usability issues. mixed profile cannot be used together with other profiles. it can only be set at creation time. conversion to or from mixed profile is not implemented. periodt. ๐ซ
-n,--nodesize <size>โ sets thenodesize, the tree block size in which btrfs stores metadata. default value is16KiB(16384) or the page size, whichever is bigger. it must be a multiple of thesectorsizeand a power of 2, but not larger than64KiB(65536).Leafsizealways equalsnodesizeand the options are aliases. ๐ฏ
smaller node size increases fragmentation but leads to taller b-trees, which in turn leads to lower locking contention. higher node sizes give better packing and less fragmentation, at the cost of more expensive memory operations while updating the metadata blocks. tradeoffs, bestie, tradeoffs. โ๏ธ
Note: versions up to 3.11 set thenodesizeto4KiB.
-s,--sectorsize <size>โ sets thesectorsize, the minimum data block allocation unit.
Note: versions prior to 6.7 set thesectorsizematching the host CPU page size, and starting in 6.7 this is4KiBfor cross-architecture compatibility. please read more about the subpage block size support and its status (status-subpage-block-size).
by default, the value is 4KiB, but it can be manually set to match the system page size (e.g. using the command getconf PAGE_SIZE). however, if the sector size is different from the page size, the resulting filesystem may not be mountable by the current kernel โ apart from the default 4KiB. so yeah, using this option is not advised unless you intend to mount it on a system with the suitable page size. ๐
in experimental build the size 2K (2048) is also allowed and needs a kernel that also allows that value, and then it works in the subpage mode. ๐งช
-L,--label <string>โ give the filesystem a label, because naming things is self care. ๐ the string should be less than 256 bytes and must not contain newline characters.-K,--nodiscardโ do not perform the whole device TRIM operation on devices that are capable of it. note that this does not affect discard/trim operation when the filesystem is mounted โ for that, go peek at the mount optiondiscardinbtrfs(5). ๐งน-r,--rootdir <rootdir>โ populate the toplevel subvolume with files from rootdir. this does not require root permissions to write the new files or to mount the filesystem. ๐
directories can be created as subvolumes, see also option --subvol. hardlinks are detected and created in the filesystem image. ๐
Note: this option may enlarge the image or file to ensure it's big enough to contain the files from rootdir. since version 4.14.1 the filesystem size is not minimized. please see option --shrink if you need that functionality.
--compress <algo>[:<level>]โ try to compress files when using--rootdir. supported values for algo areno(the default),zstd,lzoorzlib. the optional value level is a compression level,1..15forzstd,1..9forzlib. ๐๏ธ
it's recommended to use the highest level to achieve maximum space savings. compression at mkfs time is not as constrained as in kernel, where it's desirable to use less CPU load. otherwise the default level is 3.
as with the kernel, mkfs.btrfs won't write compressed extents when they would be larger than the uncompressed versions, and will set the file attribute NOCOMPRESS if its beginning is found to be incompressible. it knows when to not bother. ๐
Note: the support for ZSTD and LZO is a compile-time option, please check the output of mkfs.btrfs --version for the actual support.
-u,--subvol <type>:<subdir>โ says that subdir is to be created as a subvolume rather than a regular directory. the option--rootdirmust also be specified, and subdir must be an existing subdirectory within it. this option can be specified multiple times. ๐
the type is an optional additional modifier. valid choices are:
default: create as default subvolumero: create as read-only subvolumerw: create as read-write subvolume (the default)default-ro: create as read-only default subvolume
only one of default and default-ro may be specified.
if you wish to create a subvolume with a name containing a colon and you don't want this to be parsed as containing a modifier, you can prefix the path with ./:
$ mkfs.btrfs --rootdir dir --subvol ./ro:subdir /dev/loop0
if there are hardlinks inside rootdir and subdir will split the subvolumes, like the following case:
rootdir/
|- hardlink1
|- hardlink2
|- subdir/ <- will be a subvolume
|- hardlink3
in that case we cannot create hardlink3 as hardlinks of hardlink1 and hardlink2 because hardlink3 will be inside a new subvolume. rip to that hardlink fr. ๐
--inode-flags <flags>:<path>โ says that path is to have inode flags, other than the default one (which implies data COW and data checksum). the option--rootdirmust also be specified. this option can be specified multiple times. ๐ท๏ธ
the supported flag(s) are:
nodatacow: disable data COW, impliesnodatasumfor regular files.nodatasum: disable data checksum only.
flags can be separated by comma (,).
children inodes will inherit the flags from their parent inodes, like the following case:
rootdir/
|- file1
|- file2
|- dir/
|- file3
in that case, if --inode-flags nodatacow:dir is specified, both dir and file3 will have the nodatacow flag. the family tree passes down its traits, as families do. ๐
ok and one more lil thing about that same option: it also works with the --subvol option, BUT โ and this is important bestie โ the inode flag of each subvolume is independent and will not inherit from the parent directory. (Literally the same as the kernel behavior. ๐
)
--reflinkโ when you use it with--rootdir, it tries to clone file extents using theFICLONERANGEioctl instead of straight-up copying the bytes. ๐ Catch: this requires the source files AND the final image to live on the same filesystem. Same filesystem or it's not happening, no cap.--shrinkโ shrinks the filesystem down to its minimal size. Only works with the--rootdiroption, so keep that in mind. โจ If the destination block device is a regular file, this option will also truncate the file to the minimal size. Otherwise it will reduce the filesystem available space. Extra space will not be usable unless the filesystem is mounted and resized usingbtrfs filesystem resize.
Note: prior to version 4.14.1, the shrinking was done automatically. iykyk.
-O|--features <feature1>[,<feature2>...]โ a list of filesystem features turned on at mkfs time. Not all features are supported by old kernels, so heads up. To disable a feature, prefix it with^. ๐ฆ
See the section FILESYSTEM FEATURES for more details. And to see all the available features that mkfs.btrfs supports, just run:
$ mkfs.btrfs -O list-all
-f|--forceโ forcibly overwrite the block devices when an existing filesystem is detected. ๐ By default,mkfs.btrfswill utilizelibblkidto check for any known filesystem on the devices. Alternatively you can use thewipefsutility to clear the devices.-q|--quietโ print only error or warning messages. Options--featuresor--helpare unaffected. Resets any previous effects of--verbose. ๐คซ-U|--uuid <UUID>โ create the filesystem with the given UUID. For a single-device filesystem, you can duplicate the UUID. However, for a multi-device filesystem, the UUID must not already exist on any currently present filesystem. โ ๏ธ--device-uuid <UUID>โ create the filesystem with the given device-uuid UUID (also known asUUID_SUBin blkid). For a single device filesystem, you can duplicate the device-uuid. However, used for a multi-device filesystem this option will not work at the moment. ๐-v|--verboseโ increase verbosity level, default is1.-V|--versionโ print themkfs.btrfsversion, builtin features and exit.--helpโ print help.
๐ DEPRECATED OPTIONS ๐
-R|--runtime-features <feature1>[,<feature2>...]โ removed in6.3, was used to specify features not affecting on-disk format. Now all such features are merged into the-O|--featuresoption. The option-Rwill stay for backward compatibility. rip to a real one, but she lives on for the legacy girlies.
๐ SIZE UNITS ๐
The default unit is byte. All size parameters accept suffixes in the 1024 base. The recognized suffixes are: k, m, g, t, p, e โ both uppercase and lowercase, so yes you can scream them and it still works. ๐ซถ
๐ MULTIPLE DEVICES ๐
Before mounting a multiple device filesystem, the kernel module must know the association of the block devices that are attached to the filesystem UUID.
There is typically no action needed from the user. On a system that utilizes a udev-like daemon, any new block device is automatically registered โ the rules call btrfs device scan. โจ
The same command can be used to trigger the device scanning if the btrfs kernel module is reloaded. (Naturally all previous information about the device registration is lost, bestie. ๐ญ)
Another possibility is to use the mount options device to specify the list of devices to scan at the time of mount.
# mount -o device=/dev/sdb,device=/dev/sdc /dev/sda /mnt
Note: this means only scanning โ if the devices do not exist in the system, mount will fail anyway. This can happen on systems withoutinitramfs/initrdand root partition created with RAID1/10/5/6 profiles. The mount action can happen before all block devices are discovered. The waiting is usually done on theinitramfs/initrdsystems.
Warning: RAID5/6 has known problems and should not be used in production. fr fr, do not do it. ๐
โจ FILESYSTEM FEATURES โจ
Features that can be enabled during creation time. See also btrfs(5) section FILESYSTEM FEATURES.
mixed-bgโ (kernel support since2.6.37) mixed data and metadata block groups, also set by option--mixed.extrefโ (default since btrfs-progs3.12, kernel support since3.7) increased hardlink limit per file in a directory to65536; older kernels supported a varying number of hardlinks depending on the sum of all file name sizes that can be stored into one metadata block. ๐raid56โ (kernel support since3.9) extended format for RAID5/6, also enabled if RAID5 or RAID6 block groups are selected.skinny-metadataโ (default since btrfs-progs3.18, kernel support since3.10) reduced-size metadata for extent references, saves a few percent of metadata. ๐no-holesโ (default since btrfs-progs5.15, kernel support since3.14) improved representation of file extents where holes are not explicitly stored as an extent, saves a few percent of metadata if sparse files are used.zonedโ (kernel support since5.12) zoned mode, data allocation and write friendly to zoned/SMR/ZBC/ZNS devices, see ZONED MODE inbtrfs(5). The mode is automatically selected when a zoned device is detected. ๐quotaโ (kernel support since3.4) Enable quota support (qgroups). The qgroup accounting will be consistent, can be used together with--rootdir. See alsobtrfs-quota(8).free-space-treeโ (default since btrfs-progs5.15, kernel support since4.5) Enable the free space tree (mount optionspace_cache=v2) for persisting the free space cache in a b-tree. This is built on top of the COW mechanism and has better performance than v1. ๐
Offline conversion from filesystems that don't have this feature enabled at mkfs time is possible, see btrfstune(8).
Online conversion can be done by mounting with space_cache=v2, this is sufficient to be done one time. โจ
block-group-treeโ (default since btrfs-progsv6.19, kernel support since6.1) Enable a dedicated b-tree for block group items; this greatly reduces mount time for large filesystems due to better data locality that avoids seeking. On rotational devices the large size is considered starting from the2-4TiB. Can be used on other types of devices (SSD, NVMe, ...) as well. ๐
Offline conversion from filesystems that don't have this feature enabled at mkfs time is possible, see btrfstune(8). Online conversion is not possible.
Note: this feature requiresno-holesandfree-space-treefeatures, if these dependency features are disabled,block-group-treefeature will also be disabled automatically. The way it just quietly leavesโฆ ๐ญ
raid-stripe-treeโ (kernel support since6.7,CONFIG_BTRFS_DEBUG/CONFIG_BTRFS_EXPERIMENTAL) Separate tree for logical file extent mapping where the physical mapping may not match on multiple devices. This is now used in zoned mode to implement RAID0/RAID1* profiles, but can be used in non-zoned mode as well. The support for RAID56 is in development and will eventually fix the problems with the current implementation. This is a backward incompatible feature and has to be enabled at mkfs time. โ ๏ธ
Note: due to the status of implementation it is enabled only in builds withCONFIG_BTRFS_DEBUG/CONFIG_BTRFS_EXPERIMENTAL. Support by the kernel module can be found in the sysfs feature list.
squotaโ (kernel support since6.7) Enable simple quota accounting (squotas). This is an alternative to qgroups with a smaller performance impact but no notion of shared vs. exclusive usage. ๐ธ
๐ง BLOCK GROUPS, CHUNKS, RAID ๐ง
The highlevel organizational units of a filesystem are block groups of three types: data, metadata and system.
DATAโ store data blocks and nothing else. ๐METADATAโ store internal metadata in b-trees, can store file data if they fit into the inline limit.SYSTEMโ store structures that describe the mapping between the physical devices and the linear logical space representing the filesystem.
Other terms commonly used:
- block group, chunk โ a logical range of space of a given profile, stores data, metadata or both; sometimes the terms are used interchangeably. ๐ค
A typical size of metadata block group is 256MiB (filesystem smaller than 50GiB) and 1GiB (larger than 50GiB), for data it's 1GiB. The system block group size is a few megabytes.
- RAID โ a block group profile type that utilizes RAID-like features on multiple devices: striping, mirroring, parity.
- profile โ when used in connection with block groups refers to the allocation strategy and constraints, see the section PROFILES for more details.
โจ PROFILES โจ
okay bestie, this is the part where it gets GOOD. so btrfs has these block group types, and here's the whole lineup ๐
singleโ redundancy copies:1. parity: (none). striping: (none). space utilization:100%. min/max devices:1/any.DUPโ copies:2 / 1 device. parity: (none). striping: (none). space utilization:50%. min/max devices:1/any(see note 1).RAID0โ copies:1. parity: (none). striping:1 to N. space utilization:100%. min/max devices:1/any(see note 5).RAID1โ copies:2. parity: (none). striping: (none). space utilization:50%. min/max devices:2/any.RAID1C3โ copies:3. parity: (none). striping: (none). space utilization:33%. min/max devices:3/any.RAID1C4โ copies:4. parity: (none). striping: (none). space utilization:25%. min/max devices:4/any.RAID10โ copies:2. parity: (none). striping:1 to N. space utilization:50%. min/max devices:2/any(see note 5).RAID5โ copies:1. parity:1. striping:2 to N-1. space utilization:(N-1)/N. min/max devices:2/any(see note 2).RAID6โ copies:1. parity:2. striping:3 to N-2. space utilization:(N-2)/N. min/max devices:3/any(see note 3).
Warning: it's genuinely not recommended to create filesystems withRAID0/1/10/5/6profiles on partitions from the same device. you get neither the redundancy NOR the performance boost. like, why would you. ๐
Note 1: DUP may exist on more than 1 device if it starts on a single device and another one is added. Since version 4.5.1, mkfs.btrfs will let you create DUP on multiple devices without restrictions.
Note 2: not recommended to use 2 devices with RAID5. in that case, the parity stripe will contain the same data as the data stripe, making RAID5 degraded to RAID1 with more overhead. ๐
Note 3: also not recommended to use 3 devices with RAID6, unless you want to get effectively 3 copies in a RAID1-like manner (but not exactly that).
Note 4: since kernel 5.5 it's possible to use RAID1C3 as a replacement for RAID6. higher space cost but reliable. slay. ๐
Note 5: since kernel 5.15 it's possible to use (mount, convert profiles) RAID0 on one device and RAID10 on two devices.
๐ธ PROFILE LAYOUT ๐ธ
for the examples below, bestie, just assume: devices are numbered 1, 2, 3 and 4, data or metadata blocks are A, B, C, D, and there might be stripes like A1, A2 that would logically still be A, etc. for the parity profiles, PA and QA are parity and syndrome, associated with the given stripe. the simple layouts single and DUP are left out here. where the blocks physically land on the devices depends on the current state of the free/allocated space and may look totally random. all devices are assumed to be present at the time the blocks would have been written. โจ
๐ RAID1
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ device 1 โ device 2 โ device 3 โ device 4 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ A โ D โ โ โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ B โ โ โ C โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ C โ โ โ โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ D โ A โ B โ โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐ฆ RAID1C3
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ device 1 โ device 2 โ device 3 โ device 4 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ A โ A โ D โ โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ B โ โ B โ โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ C โ โ A โ C โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ D โ D โ C โ B โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐ RAID0
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ device 1 โ device 2 โ device 3 โ device 4 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ A2 โ C3 โ A3 โ C2 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ B1 โ A1 โ D2 โ B3 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ C1 โ D3 โ B4 โ D1 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ D4 โ B2 โ C4 โ A4 โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐ RAID5
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ device 1 โ device 2 โ device 3 โ device 4 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ A2 โ C3 โ A3 โ C2 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ B1 โ A1 โ D2 โ B3 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ C1 โ D3 โ PB โ D1 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ PD โ B2 โ PC โ PA โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐ฆ RAID6 ๐ฆ
okay so picture four devices holding stripes, and the Q blocks are the second parity layer โ the whole thing can survive two dead devices at once, which is giving unstoppable final-boss energy:
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ device 1 โ device 2 โ device 3 โ device 4 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ A2 โ QC โ QA โ C2 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ B1 โ A1 โ D2 โ QB โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ C1 โ QD โ PB โ D1 โ
โโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ PD โ B2 โ PC โ PA โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโ
๐ DUP PROFILES ON A SINGLE DEVICE ๐
So bestie, mkfs will absolutely let you make a filesystem with profiles that write the logical blocks to 2 physical locations. But whether there are actually two physical copies? That highly depends on the underlying device type. It's giving "the vibes say redundant but the hardware said no" ๐ญ
For example, a SSD drive can remap the blocks internally to a single copy โ thus deduplicating them. Which negates the entire purpose of increased redundancy and just wastes filesystem space without providing the expected level of redundancy. Not slay. ๐
The duplicated data/metadata may still be useful to statistically improve the chances on a device that might perform some internal optimizations. The actual details are not usually disclosed by vendors. For example we could expect that not all blocks get deduplicated. This will provide a non-zero probability of recovery compared to a zero chance if the single profile is used. The user should make the tradeoff decision. The deduplication in SSDs is thought to be widely available, so the reason behind the mkfs default is to not give a false sense of redundancy. ๐ฏ
As another example, the widely used USB flash or SD cards use a translation layer between the logical and physical view of the device. The data lifetime may be affected by frequent plugging. The memory cells could get damaged, hopefully not destroying both copies of particular data in case of DUP. ๐ฅฒ
The wear levelling techniques can also lead to reduced redundancy, even if the device does not do any deduplication. The controllers may put data written in a short time span into the same physical storage unit (cell, block etc). In case this unit dies, both copies are lost. BTRFS does not add any artificial delay between metadata writes. Periodt.
The traditional rotational hard drives usually fail at the sector level.
๐จ In any case, a device that starts to misbehave and repairs from the DUP copy should be replaced! DUP is not backup. Read that again, bestie. ๐ค
๐ KNOWN ISSUES ๐
๐ธ SMALL FILESYSTEMS AND LARGE NODESIZE ๐ธ
The combination of small filesystem size and large nodesize is not recommended in general and can lead to various ENOSPC-related issues during mount time or runtime. it's giving "why is there no space, I literally just made you" ๐
Since mixed block group creation is optional, we allow small filesystem instances with differing values for sectorsize and nodesize to be created and could end up in the following situation:
# mkfs.btrfs -f -n 65536 /dev/loop0
btrfs-progs v3.19-rc2-405-g976307c
See https://btrfs.readthedocs.io for more information.
Performing full device TRIM (512.00MiB) ...
Label: (null)
UUID: 49fab72e-0c8b-466b-a3ca-d1bfe56475f0
Node size: 65536
Sector size: 4096
Filesystem size: 512.00MiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 40.00MiB
System: DUP 12.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Number of devices: 1
Devices:
ID SIZE PATH
1 512.00MiB /dev/loop0
# mount /dev/loop0 /mnt/
mount: mount /dev/loop0 on /mnt failed: No space left on device
The ENOSPC occurs during the creation of the UUID tree. This is caused by large metadata blocks and space reservation strategy that allocates more than can fit into the filesystem. (the math simply was not mathing โ)
โจ ENVIRONMENT โจ
mkfs.btrfs honors two environment variables that make image creation reproducible, so that the same inputs produce a byte-for-byte identical image. same in, same out, no surprises, iconic behavior fr fr ๐ซถ
๐ฅ SOURCE_DATE_EPOCH ๐ฅ
A decimal count of seconds since the Unix epoch (reproducible-builds.org), used in place of the current time for the timestamps written into the image: the root-item and inode times of the created trees. With --rootdir, each copied file's ctime and atime are set to this value. Its mtime is taken from the source but clamped to it, so nothing in the image is newer than the source date. ๐
- An empty value is treated as unset.
- A value that is not a non-negative integer fitting in the platform time type is a hard error.
๐ฅ DETERMINISTIC_SEED ๐ฅ
When set to 1, the internal UUIDs that are otherwise random (the chunk-tree UUID, each device UUID and each subvolume UUID) are instead derived deterministically from the filesystem UUID. A fixed filesystem UUID must be supplied with -U; without it mkfs.btrfs exits with an error rather than emit a random image. Any value other than 1 leaves UUID generation random. ๐ฒ๐ซ
To create a reproducible image, pin the filesystem UUID with -U, set SOURCE_DATE_EPOCH and DETERMINISTIC_SEED, normalize source ownership, and start with a fresh target file. mkfs.btrfs copies uid and gid from the source tree and, like other mkfs tools, does not zero space it does not write:
$ chown -R 0:0 ./rootdir
$ truncate -s 1G image.btrfs
$ SOURCE_DATE_EPOCH=1700000000 DETERMINISTIC_SEED=1 \
mkfs.btrfs -U <uuid> --rootdir ./rootdir image.btrfs
๐ AVAILABILITY ๐
btrfs is part of btrfs-progs. Please refer to the documentation at <https://btrfs.readthedocs.io>. go read it, it's free, it's educational, it's a whole vibe ๐โจ
๐ซถ SEE ALSO ๐ซถ
and that's a wrap on the whole page, bestie!! ๐ this was btrfs-progs version 7.3, dated Oct 24, 2026, living its life under the name MKFS.BTRFS(8) โ go forth and make filesystems, but like, responsibly. mwah ๐๐โจ
๐ฆ where this page comes from
- arch rolling: btrfs-progs 7.3-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms