mkfs.bcachefs
Create a new bcachefs filesystem
TLDR
Create a bcachefs filesystem inside partition Y on a device X
Create a bcachefs filesystem with a volume label
SYNOPSIS
mkfs.bcachefs [OPTIONS] <device> [<device>...]
PARAMETERS
<device>
One or more block devices (e.g., /dev/sda, /dev/nvme0n1) to be formatted as part of the bcachefs filesystem. Multiple devices will be configured for multi-device operation based on internal defaults or explicit options.
-f, --force
Force the creation of the filesystem, overwriting any existing filesystem or data on the specified devices without prompting.
-L <label>, --label <label>
Set a human-readable label for the new bcachefs filesystem. This label can be used to identify and mount the filesystem.
-U <uuid>, --uuid <uuid>
Set a specific Universally Unique Identifier (UUID) for the new bcachefs filesystem. If not specified, a random UUID will be generated.
-b <size>, --block-size <size>
Specify the default data block size for the filesystem. Common values include 4k, 8k, 16k, etc. Larger block sizes can improve performance for large files but may waste space for small files.
-c <alg>, --compression <alg>
Set the default compression algorithm for data written to the filesystem. Supported algorithms often include lz4, zstd, and none. This can be overridden per file or directory.
-C <alg>, --checksum <alg>
Set the default checksum algorithm for data and metadata integrity. Common choices include crc32c, xxh3, and none.
-R <num>, --replicas <num>
Set the default number of data replicas across devices. This effectively configures the filesystem's RAID level for data, e.g., 2 for RAID1-like mirroring.
--foreground
Run the formatting process in the foreground, rather than daemonizing. Useful for scripting or debugging.
--wipe-bcache
Wipe any existing bcache (the original caching layer) metadata from the specified devices. Useful when reusing devices that were previously part of a bcache setup.
DESCRIPTION
The mkfs.bcachefs command initializes and formats one or more block devices to create a new bcachefs filesystem. bcachefs is a modern copy-on-write (CoW) filesystem designed for high performance, scalability, and robust data integrity, developed by Kent Overstreet. It integrates concepts from ZFS and Btrfs, offering advanced features like caching, snapshots, checksumming, and various RAID levels. When invoked, mkfs.bcachefs sets up the fundamental on-disk structures, metadata, and default parameters for the filesystem, preparing the devices for data storage. It's crucial for establishing the initial state of a bcachefs volume before it can be mounted and used.
CAVEATS
bcachefs is a relatively new and actively developed filesystem. While it has undergone extensive testing, its stability and feature set may evolve. Users should ensure they are running a sufficiently new kernel that supports bcachefs. Data recovery tools and advanced administration utilities might be less mature compared to older, well-established filesystems.
DEVICE ROLES AND TIERS
bcachefs supports different device roles and tiers within a single filesystem, allowing users to combine fast SSDs for metadata and/or caching with slower HDDs for bulk data storage. While mkfs.bcachefs initializes the basic structure, advanced device role assignment and tiering are typically managed after creation using bcachefs command-line tools.
ONLINE RESIZING AND FEATURES
Like other modern CoW filesystems, bcachefs is designed to support online filesystem resizing (adding/removing devices) and enabling/disabling certain features (like compression or encryption) after initial creation, offering significant flexibility in managing storage volumes.
HISTORY
bcachefs was created by Kent Overstreet, the original author of the Linux kernel's bcache caching layer. Development began around 2015 with the goal of creating a modern copy-on-write filesystem that combined the best features of ZFS and Btrfs with advanced caching capabilities directly integrated into the filesystem itself, rather than as a separate layer. It has been a long-running project, meticulously developed and refined, and is poised for inclusion in the mainline Linux kernel, marking a significant milestone in its journey.