LinuxCommandLibrary

bcachefs

Manage and create Bcachefs filesystems

TLDR

Format a partition with bcachefs

$ sudo bcachefs format [path/to/partition]
copy

Mount a bcachefs filesystem
$ sudo bcachefs mount [path/to/partition] [path/to/mountpoint]
copy

Create a RAID 0 filesystem where an SSD acts as a cache and an HDD acts as a long-term storage
$ sudo bcachefs format [[-l|--label]] [ssd.ssd1] [path/to/ssd_partition] [[-l|--label]] [hdd.hdd1] [path/to/hdd_partition] --replicas 1 --foreground_target [ssd] --promote_target [ssd] --background_target [hdd]
copy

Mount a multidevice filesystem
$ sudo bcachefs mount [path/to/partition1]:[path/to/partition2] [path/to/mountpoint]
copy

Display disk usage
$ bcachefs fs usage [[-h|--human-readable]] [path/to/mountpoint]
copy

Set replicas after formatting and mounting
$ sudo bcachefs set-fs-option --metadata_replicas [2] --data_replicas [2] [path/to/partition]
copy

Force bcachefs to ensure all files are replicated
$ sudo bcachefs data rereplicate [path/to/mountpoint]
copy

Create a snapshot of a particular directory
$ bcachefs subvolume snapshot [path/to/directory] [path/to/snapshot]
copy

SYNOPSIS

bcachefs [global-options] <subcommand> [subcommand-options] [arguments]

PARAMETERS

-C, --config=<FILE>
    Read configuration from FILE instead of default

-d[<LEVEL>], --debug[=<LEVEL>]
    Enable debug logging at specified level (0-31)

--version
    Print bcachefs version and exit

--help
    Show usage help

daemon
    Start, stop, or query kernel daemon threads for devices

format [<options>] <device>...
    Format devices into new bcachefs filesystem (mkfs.bcachefs symlink)

fsck [<options>] <device>
    Check filesystem integrity and repair issues (fsck.bcachefs symlink)

rescue <subcmd>
    Recovery tools: superblock, key, uuid, devices, etc.

version
    Print detailed version information

kernel-config
    Dump/print kernel config options used by bcachefs

DESCRIPTION

bcachefs is a next-generation Linux filesystem designed for high performance, reliability, and advanced features like copy-on-write (COW), snapshots, built-in RAID (including erasure coding), compression, deduplication, and encryption. It combines the best of Btrfs, ZFS, and ext4 while addressing their shortcomings through a novel b-tree based design for both metadata and data.

The bcachefs command-line tool manages bcachefs volumes, devices, and filesystems. Key operations include formatting devices (bcachefs format), filesystem checks and repairs (bcachefs fsck), data recovery (bcachefs rescue), and querying status. It supports multi-device setups for redundancy and performance, with automatic balancing and scrubbing.

Developed by Kent Overstreet, bcachefs emphasizes simplicity in code and configuration. The userspace tools integrate with kernel module (CONFIG_BCACHEFS_FS) for mounting via mount.bcachefs. Ideal for servers needing robust storage without complex management.

CAVEATS

Relatively new filesystem (kernel 6.7+); test thoroughly, backup data before format/fsck/rescue. Some features experimental; distro support varies. Multi-device requires careful planning to avoid data loss.

KEY FEATURES

Snapshots, subvolume-aware, RAID 0/1/5/6/10, zstd/lzo compression, chunk dedup, LSKC encryption, fast balancing/scrubbing.

MOUNTING

Use mount -t bcachefs or mount.bcachefs; options like compression=zstd, replicas=2.

HISTORY

Created by Kent Overstreet ~2015 as bcache evolution. Years of development with public git tree. Merged to Linux 6.7 (Dec 2023) after rigorous review. Userspace tools track kernel closely.

SEE ALSO

mount.bcachefs(8), mkfs.bcachefs(8), fsck.bcachefs(8), btrfs(8), zfs(8)

Copied to clipboard