mkfs.btrfs(8) ============= NAME ---- mkfs.btrfs - create a btrfs filesystem SYNOPSIS -------- *mkfs.btrfs* [options] [...] DESCRIPTION ----------- *mkfs.btrfs* is used to create the btrfs filesystem on a single or multiple devices. is typically a block device but can be a file-backed image as well. Multiple devices are grouped by UUID of the filesystem. Before mounting such filesystem, the kernel module must know all the devices either via preceding execution of *btrfs device scan* or using the *device* mount option. See section *MULTIPLE DEVICES* for more details. The default block group profiles for data and metadata depend on number of devices and possibly other factors. It's recommended to use specific profiles but the defaults should be OK and allowing future conversions to other profiles. Please see options '-d' and '-m' for further detals and `btrfs-balance`(8) for the profile conversion post mkfs. OPTIONS ------- *-b|--byte-count *:: Specify the size of the filesystem. If this option is not used, then mkfs.btrfs uses the entire device space for the filesystem. *--csum *:: *--checksum *:: Specify the checksum algorithm. Default is 'crc32c'. Valid values are 'crc32c', 'xxhash', 'sha256' or 'blake2'. To mount such filesystem kernel must support the checksums as well. See 'CHECKSUM ALGORITHMS' in `btrfs`(5). *-d|--data *:: Specify the profile for the data block groups. Valid values are 'raid0', 'raid1', 'raid1c3', 'raid1c4', 'raid5', 'raid6', 'raid10' or 'single' or 'dup' (case does not matter). + See 'DUP PROFILES ON A SINGLE DEVICE' for more details. + On multiple devices, the default was 'raid0' until version 5.7, while it is 'single' since version 5.8. You can still select raid0 manually, but it was not suitable as default. *-m|--metadata *:: Specify the profile for the metadata block groups. Valid values are 'raid0', 'raid1', 'raid1c3', 'raid1c4', 'raid5', 'raid6', 'raid10', 'single' or 'dup' (case does not matter). + Default on a single device filesystem is 'DUP' and is recommended for metadata in general. The duplication might not be necessary in some use cases and it's up to the user to changed that at mkfs time or later. This depends on hardware that could potentially deduplicate the blocks again but this cannot be detected at mkfs time. + [NOTE] .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 file `/sys/block/DEV/queue/rotational`) that used to select 'single'. This has changed in version 5.15 to be always 'dup'. Note 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 additonal device mapper layer, etc). It's recommended to always set the options '--data/--metadata' to avoid confusion and unexpected results. See 'DUP PROFILES ON A SINGLE DEVICE' for more details. ==== + On multiple devices the default is 'raid1'. *-M|--mixed*:: Normally the data and metadata block groups are isolated. The 'mixed' mode will remove the isolation and store both types in the same block group type. This helps to utilize the free space regardless of the purpose and is suitable for small devices. The separate allocation of block groups leads to a situation where the space is reserved for the other block group type, is not available for allocation and can lead to ENOSPC state. + The recommended size for the mixed mode is for filesystems less than 1GiB. The soft recommendation is to use it for filesystems smaller than 5GiB. The 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. *-l|--leafsize *:: Alias for --nodesize. Deprecated. *-n|--nodesize *:: Specify the nodesize, the tree block size in which btrfs stores metadata. The default value is 16KiB (16384) or the page size, whichever is bigger. Must be a multiple of the sectorsize and a power of 2, but not larger than 64KiB (65536). Leafsize always equals nodesize and 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. + NOTE: versions up to 3.11 set the nodesize to 4k. *-s|--sectorsize *:: Specify the sectorsize, the minimum data block allocation unit. + The default value is the page size and is autodetected. If the sectorsize differs from the page size, the created filesystem may not be mountable by the running kernel. Therefore it is not recommended to use this option unless you are going to mount it on a system with the appropriate page size. *-L|--label *:: Specify a label for the filesystem. The 'string' should be less than 256 bytes and must not contain newline characters. *-K|--nodiscard*:: Do not perform whole device TRIM operation on devices that are capable of that. This does not affect discard/trim operation when the filesystem is mounted. Please see the mount option 'discard' for that in `btrfs`(5). *-r|--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. + 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. *--shrink*:: Shrink the filesystem to its minimal size, only works with '--rootdir' option. + 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 using 'btrfs filesystem resize'. + NOTE: prior to version 4.14.1, the shrinking was done automatically. *-O|--features [,...]*:: A list of filesystem features turned on at mkfs time. Not all features are supported by old kernels. To disable a feature, prefix it with '^'. + See section *FILESYSTEM FEATURES* for more details. To see all available features that mkfs.btrfs supports run: + +mkfs.btrfs -O list-all+ *-R|--runtime-features [,...]*:: A list of features that be can enabled at mkfs time, otherwise would have to be turned on a mounted filesystem. Although no runtime feature is enabled by default, to disable a feature, prefix it with '^'. + See section *RUNTIME FEATURES* for more details. To see all available runtime features that mkfs.btrfs supports run: + +mkfs.btrfs -R list-all+ *-f|--force*:: Forcibly overwrite the block devices when an existing filesystem is detected. By default, mkfs.btrfs will utilize 'libblkid' to check for any known filesystem on the devices. Alternatively you can use the `wipefs` utility to clear the devices. *-q|--quiet*:: Print only error or warning messages. Options --features or --help are unaffected. Resets any previous effects of '--verbose'. *-U|--uuid *:: Create the filesystem with the given 'UUID'. The UUID must not exist on any filesystem currently present. *-v|--verbose*:: Increase verbosity level, default is 1. *-V|--version*:: Print the *mkfs.btrfs* version and exit. *--help*:: Print help. 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. 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). 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: that this means only scanning, if the devices do not exist in the system, mount will fail anyway. This can happen on systems without initramfs/initrd and 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 the initramfs/initrd systems. RAID5/6 has known problems and should not be used in production. FILESYSTEM FEATURES ------------------- Features that can be enabled during creation time. See also `btrfs`(5) section 'FILESYSTEM FEATURES'. *mixed-bg*:: (kernel support since 2.6.37) + mixed data and metadata block groups, also set by option '--mixed' *extref*:: (default since btrfs-progs 3.12, kernel support since 3.7) + increased hardlink limit per file in a directory to 65536, 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 since 3.9) + extended format for RAID5/6, also enabled if raid5 or raid6 block groups are selected *skinny-metadata*:: (default since btrfs-progs 3.18, kernel support since 3.10) + reduced-size metadata for extent references, saves a few percent of metadata *no-holes*:: (default since btrfs-progs 5.15, kernel support since 3.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 since 5.12) + zoned mode, data allocation and write friendly to zoned/SMR/ZBC/ZNS devices, see 'ZONED MODE' in `btrfs`(5), the mode is automatically selected when a zoned device is detected RUNTIME FEATURES ---------------- Features that are typically enabled on a mounted filesystem, eg. by a mount option or by an ioctl. Some of them can be enabled early, at mkfs time. This applies to features that need to be enabled once and then the status is permanent, this does not replace mount options. *quota*:: (kernel support since 3.4) + Enable quota support (qgroups). The qgroup accounting will be consistent, can be used together with '--rootdir'. See also `btrfs-quota`(8). *free-space-tree*:: (default since btrfs-progs 5.15, kernel support since 4.5) + Enable the free space tree (mount option space_cache=v2) for persisting the free space cache. 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 -------- There are the following block group types available: [ cols="<,^,^,^,>,^",width="60%" ] |============================================================= .2+^.