mkfs.btrfs Command Examples in Linux

mkfs.btrfs is a utility used to create a Btrfs (short for “B-tree file system”) file system on a storage device. By default, mkfs.btrfs creates a RAID1 file system, meaning that data is stored in two identical copies, each located on a separate storage device. This provides data redundancy, allowing the file system to continue functioning even if one of the storage devices fails. The RAID1 layout is specified with the -d raid1 option, and it can be changed to other Btrfs RAID levels (e.g. RAID0, RAID10) if desired. Note that creating a Btrfs file system requires unmounting the target device, and all existing data on the device will be destroyed.

mkfs.btrfs Command Examples

1. Create a btrfs filesystem on a single device:

# sudo mkfs.btrfs --metadata single --data single /dev/sda

2. Create a btrfs filesystem on multiple devices with raid1:

# sudo mkfs.btrfs --metadata raid1 --data raid1 /dev/sda /dev/sdb /dev/sdN

3. Set a label for the filesystem:

# sudo mkfs.btrfs --label "label" /dev/sda [/dev/sdN]
Related Post