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

  • 1

    Filesystem management

    Create and manage Btrfs filesystems

  • 2

    Data snapshots

    Create and manage filesystem snapshots

  • 3

    Storage optimization

    Optimize storage usage with advanced features

  • 4

    Data integrity

    Ensure data integrity with checksums and error correction

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:

Display all btrfs filesystems
btrfs filesystem show
List all subvolumes in the specified path
btrfs subvolume list /mnt/btrfs
Create a new subvolume
btrfs subvolume create /mnt/btrfs/newsub

Advanced Examples:

Start balancing data across devices in the filesystem
btrfs balance start /mnt/btrfs
Create a snapshot of a subvolume
btrfs subvolume snapshot /mnt/btrfs/source /mnt/btrfs/snapshot
Send a snapshot to another location or filesystem
btrfs send /mnt/btrfs/snapshot | btrfs receive /mnt/backup
Start a scrub operation to check for data integrity
btrfs scrub start /mnt/btrfs

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.

Common Use Cases

Filesystem management

Create and manage Btrfs filesystems

Data snapshots

Create and manage filesystem snapshots

Storage optimization

Optimize storage usage with advanced features

Data integrity

Ensure data integrity with checksums and error correction

Storage administration

Manage advanced storage features and configurations

Related Commands

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

Use Cases

1

Filesystem management

Create and manage Btrfs filesystems

2

Data snapshots

Create and manage filesystem snapshots

3

Storage optimization

Optimize storage usage with advanced features

4

Data integrity

Ensure data integrity with checksums and error correction

5

Storage administration

Manage advanced storage features and configurations

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
btrfs - Linux B-tree Filesystem Command