Linux command
mkfs.bcachefs 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Example
sudo mkfs.bcachefs [/dev/sdXY]
Example
sudo mkfs.bcachefs -L [volume_label] [/dev/sdXY]
Example
sudo mkfs.bcachefs --compression=zstd [/dev/sdXY]
Example
sudo mkfs.bcachefs --encrypted [/dev/sdXY]
Example
sudo mkfs.bcachefs --replicas=2 [/dev/sdX] [/dev/sdY]
Example
sudo mkfs.bcachefs -f [/dev/sdXY]
说明
mkfs.bcachefs creates a bcachefs filesystem on one or more devices. It is equivalent to bcachefs format. Bcachefs is a modern copy-on-write filesystem for Linux with features including checksumming, compression, encryption, snapshots, reflinks, and multi-device support with storage tiering. The filesystem can span multiple devices with configurable replication, providing RAID-like redundancy without a separate volume manager. Different storage tiers (e.g. fast NVMe SSD and slow HDD) can be combined in a single filesystem using the target options (--foreground_target, --promote_target, --background_target). All persistent filesystem-wide options can be set at format time and many can also be changed later with bcachefs set-fs-option.
参数
- -L, --fs_label=_label_
- Set the filesystem volume label
- -U, --uuid=_uuid_
- Create the filesystem with the specified UUID
- -f, --force
- Force the filesystem to be created, even if the device already contains a filesystem
- -q, --quiet
- Only print errors
- -v, --verbose
- Verbose filesystem initialization
- --replicas=_n_
- Set both data and metadata replicas (shorthand for setting both at once)
- --data_replicas=_n_
- Number of data replicas
- --metadata_replicas=_n_
- Number of metadata replicas
- --metadata_checksum=_type_
- Metadata checksum algorithm (none, crc32c, crc64, xxhash); default: crc32c
- --data_checksum=_type_
- Data checksum algorithm (none, crc32c, crc64, xxhash); default: crc32c
- --compression=_type_
- Foreground compression algorithm (none, lz4, gzip, zstd); default: none
- --background_compression=_type_
- Background compression algorithm applied to existing data (none, lz4, gzip, zstd)
- --encrypted
- Enable whole-filesystem encryption (chacha20/poly1305); passphrase will be prompted for
- --no_passphrase
- When used with --encrypted, do not encrypt the master encryption key
- --nocow
- Enable no-copy-on-write mode: writes are done in-place when possible. Implicitly disables checksumming, compression, and encryption. Snapshots and reflinks still use COW.
- --errors=_action_
- Action to take on filesystem error: continue, ro, or panic
- --metadata_target=_target_
- Device or label to prefer for metadata writes (used in multi-device tiered setups)
- --foreground_target=_target_
- Device or label to prefer for foreground (synchronous) writes
- --background_target=_target_
- Device or label to move data to in the background
- --promote_target=_target_
- Device or label to promote data to on read (SSD caching tier)
- --discard
- Enable discard/TRIM support on the device
- --fs_size=_size_
- Limit the filesystem to _size_ bytes on the subsequent device
- --bucket=_size_
- Bucket size for the device; must be greater than the btree node size
- --durability=_n_
- Consider data written to this device as already replicated _n_ times
FAQ
What is the mkfs.bcachefs command used for?
mkfs.bcachefs creates a bcachefs filesystem on one or more devices. It is equivalent to bcachefs format. Bcachefs is a modern copy-on-write filesystem for Linux with features including checksumming, compression, encryption, snapshots, reflinks, and multi-device support with storage tiering. The filesystem can span multiple devices with configurable replication, providing RAID-like redundancy without a separate volume manager. Different storage tiers (e.g. fast NVMe SSD and slow HDD) can be combined in a single filesystem using the target options (--foreground_target, --promote_target, --background_target). All persistent filesystem-wide options can be set at format time and many can also be changed later with bcachefs set-fs-option.
How do I run a basic mkfs.bcachefs example?
Run `sudo mkfs.bcachefs [/dev/sdXY]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -L, --fs_label=_label_ do in mkfs.bcachefs?
Set the filesystem volume label