btrfs

file managementLinux
The btrfs command is one of the most frequently used commands in Linux/Unix-like operating systems. btrfs Control and manage the Btrfs filesystem in Linux

Quick Reference

Command Name:

btrfs

Category:

file management

Platform:

Linux

Basic Usage:

btrfs [options] [arguments]

Common Use Cases

    Syntax

    btrfs [COMMAND] [OPTIONS] <args>

    Options

    Command Group Description
    balance Balance data across devices
    device Manage devices in the filesystem
    filesystem Manage filesystem parameters
    subvolume Create and manage subvolumes
    scrub Verify data and metadata integrity
    quota Manage filesystem quotas
    snapshot Create read-only or writable point-in-time copies
    send/receive Serialize and transfer subvolumes between filesystems
    restore Restore files from Btrfs snapshots
    inspect-internal Debug tools for Btrfs developers

    Common Options:

    Option Description
    --help Display help for the command
    -v, --verbose Increase verbosity of output
    -q, --quiet Suppress unimportant output messages

    Examples

    How to Use These Examples

    The examples below show common ways to use the btrfs command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    btrfs filesystem show
    Display all btrfs filesystems.
    btrfs subvolume list /mnt/btrfs
    List all subvolumes in the specified path.
    btrfs subvolume create /mnt/btrfs/newsub
    Create a new subvolume. # Advanced Examples Advanced btrfs balance start /mnt/btrfs Start balancing data across devices in the filesystem. btrfs subvolume snapshot /mnt/btrfs/source /mnt/btrfs/snapshot Create a snapshot of a subvolume. btrfs send /mnt/btrfs/snapshot | btrfs receive /mnt/backup Send a snapshot to another location or filesystem. btrfs scrub start /mnt/btrfs Start a scrub operation to check for data integrity.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    Btrfs (B-tree File System) is a modern copy-on-write (CoW) filesystem for Linux with advanced features including: - Snapshots and clones - Multiple device support (RAID) - Data integrity verification - Transparent compression - Online filesystem defragmentation - Online filesystem expansion and shrinking - Subvolumes (filesystems within a filesystem) The btrfs command provides tools to manage these features. Most operations require root privileges. **Key Concepts:** 1. **Subvolumes**: Independently mountable filesystems within the Btrfs filesystem. They can have their own fstab entries. 2. **Snapshots**: Point-in-time copies of subvolumes that share common data. Changes to either the original or the snapshot are not reflected in the other. 3. **Send/Receive**: Tools to serialize and restore subvolumes, enabling efficient backups and transfers. 4. **Scrub**: Background process that reads all data and metadata to verify checksums and repair corruptions when redundant copies exist. 5. **Balance**: Redistributes data across devices to optimize space usage and performance. When using Btrfs for critical data, regular backups are still recommended despite its data integrity features.

    Related Commands

    These commands are frequently used alongside btrfs or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the btrfs command works in different scenarios.

    $ btrfs
    View All Commands