Difference between revisions of "Btrfs"
(Created page with "== Btrfs == '''Btrfs''' (''B-tree File System'', often pronounced as "butter FS", "better FS", or "B-tree FS") is a modern copy-on-write (COW) file system for Linux. It is des...") |
|||
Line 18: | Line 18: | ||
To create a Btrfs filesystem: | To create a Btrfs filesystem: | ||
− | + | ||
− | mkfs.btrfs /dev/sdX1 | + | mkfs.btrfs /dev/sdX1 |
− | + | ||
To mount a Btrfs partition: | To mount a Btrfs partition: | ||
− | + | ||
− | mount -t btrfs /dev/sdX1 /mnt | + | mount -t btrfs /dev/sdX1 /mnt |
− | + | ||
To create a snapshot: | To create a snapshot: | ||
− | + | ||
− | btrfs subvolume snapshot /mnt /mnt/snapshot1 | + | btrfs subvolume snapshot /mnt /mnt/snapshot1 |
− | + | ||
To check the filesystem: | To check the filesystem: | ||
− | + | ||
− | btrfs check /dev/sdX1 | + | btrfs check /dev/sdX1 |
− | + | ||
=== Subvolumes and Snapshots === | === Subvolumes and Snapshots === | ||
Line 51: | Line 51: | ||
Btrfs can manage multiple devices without LVM or mdadm: | Btrfs can manage multiple devices without LVM or mdadm: | ||
− | + | ||
− | mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc | + | mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc |
− | + | ||
> Note: As of 2024, RAID 5 and 6 are still considered **unstable** in production environments. | > Note: As of 2024, RAID 5 and 6 are still considered **unstable** in production environments. | ||
Line 97: | Line 97: | ||
* [[ext4]] | * [[ext4]] | ||
− | |||
− | |||
* [[Filesystem]] | * [[Filesystem]] | ||
* [[RAID]] | * [[RAID]] | ||
− |
Latest revision as of 14:08, 19 May 2025
Contents
Btrfs
Btrfs (B-tree File System, often pronounced as "butter FS", "better FS", or "B-tree FS") is a modern copy-on-write (COW) file system for Linux. It is designed to address the shortcomings of traditional Linux filesystems like ext4 and XFS, offering advanced features such as snapshots, built-in RAID, checksumming, and transparent compression.
Originally developed by Oracle Corporation in 2007, Btrfs is now maintained by multiple contributors, including SUSE and Facebook, and is integrated into the Linux kernel.
Key Features
- Copy-on-Write (COW) – All data and metadata modifications are written to new locations, enabling safe snapshots and data integrity.
- Snapshots and Subvolumes – Lightweight snapshots allow instant backups and rollbacks. Subvolumes can function like independent mountable directories.
- Built-in RAID Support – Supports RAID 0, 1, 10, and experimental RAID 5/6 modes without external tools.
- Checksumming – Data and metadata are checksummed independently to detect and correct silent corruption.
- Transparent Compression – Supports zlib, LZO, and zstd compression algorithms.
- Online Resizing – Allows volumes to be grown or shrunk while mounted.
- Cloning – Efficiently creates duplicates of files and directories using block-level reference.
Usage
To create a Btrfs filesystem:
mkfs.btrfs /dev/sdX1
To mount a Btrfs partition:
mount -t btrfs /dev/sdX1 /mnt
To create a snapshot:
btrfs subvolume snapshot /mnt /mnt/snapshot1
To check the filesystem:
btrfs check /dev/sdX1
Subvolumes and Snapshots
Btrfs supports subvolumes and snapshots natively:
- Subvolumes are logical divisions of the filesystem that can be managed independently.
- Snapshots are read-only or read-write clones of a subvolume at a given point in time, useful for backups and system rollback.
RAID Support
Btrfs can manage multiple devices without LVM or mdadm:
mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc
> Note: As of 2024, RAID 5 and 6 are still considered **unstable** in production environments.
Limitations
- RAID 5/6 is experimental and not recommended for production.
- Lower performance under heavy fragmentation compared to ext4/XFS.
- Recovery from serious corruption can be complex.
- Less mature compared to ZFS for enterprise data storage use cases.
Comparison with Other Filesystems
Feature | Btrfs | ext4 | XFS | ZFS | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Copy-on-write | Yes | No | No | Yes | Snapshots | Yes | No | No | Yes | Compression | Yes | No | No | Yes | Checksumming | Yes | Metadata only | Metadata only | Yes | Built-in RAID | Yes | No | No | Yes | Max file size | 16 EiB | 16 TiB | 8 EiB | 16 EiB | Online resize | Yes (grow/shrink) | Yes (grow/shrink) | Yes (grow only) | Yes (grow only) | Platform | Linux only | Linux | Linux | Linux, FreeBSD | Development maturity | Active | Stable | Mature | Mature |
Common Use Cases
- Linux desktops and laptops (especially with snapshots for rollback)
- NAS devices and home servers
- Container storage (e.g., Docker, LXC)
- Backup systems
Distributions Supporting Btrfs
- Fedora (default for Workstation)
- openSUSE and SUSE Linux Enterprise
- Ubuntu (optional during installation)
- Debian (optional filesystem choice)