Btrfs Cheatsheet
#
Btrfs is a modern copy-on-write file system for Linux that provides advanced features like snapshots, checksums, and volume management.
File System Creation
#
Command/Option | Example | Description |
---|
mkfs.btrfs | mkfs.btrfs /dev/sdX1 | Create a Btrfs file system on a partition |
mkfs.btrfs -L label /dev/sdX1 | mkfs.btrfs -L mylabel /dev/sdX1 | Create a Btrfs file system with a volume label |
File System Checking and Repair
#
Command/Option | Example | Description |
---|
btrfs check | btrfs check /dev/sdX1 | Check a Btrfs file system for errors |
btrfs check --repair /dev/sdX1 | btrfs check --repair /dev/sdX1 | Check and repair a Btrfs file system |
Mounting and Unmounting
#
Command/Option | Example | Description |
---|
mount | mount -t btrfs /dev/sdX1 /mnt | Mount a Btrfs file system to a directory |
umount | umount /mnt | Unmount the file system |
Command/Option | Example | Description |
---|
btrfs filesystem df | btrfs filesystem df /mnt | Show space usage for a Btrfs file system |
btrfs filesystem show | btrfs filesystem show /mnt | Display detailed information about Btrfs file systems |
File System Management
#
Command/Option | Example | Description |
---|
btrfs device add | btrfs device add /dev/sdX2 /mnt | Add a new device to a Btrfs file system |
btrfs device delete | btrfs device delete /dev/sdX2 /mnt | Remove a device from a Btrfs file system |
btrfs balance start | btrfs balance start /mnt | Start a balance operation to redistribute data across devices |
Snapshots and Subvolumes
#
Command/Option | Example | Description |
---|
btrfs subvolume create | btrfs subvolume create /mnt/subvol | Create a new Btrfs subvolume |
btrfs subvolume delete | btrfs subvolume delete /mnt/subvol | Delete a Btrfs subvolume |
btrfs snapshot | btrfs snapshot /mnt/subvol /mnt/snapshot | Create a snapshot of a Btrfs subvolume |
Compression and Deduplication
#
Command/Option | Example | Description |
---|
btrfs property set | btrfs property set /mnt compression lzo | Set compression algorithm for a Btrfs file system |
btrfs balance start -d | btrfs balance start -d /mnt | Start deduplication of data blocks |
File System Integrity
#
Command/Option | Example | Description |
---|
btrfs scrub start | btrfs scrub start /mnt | Start a scrub operation to check and repair data integrity |
btrfs scrub status | btrfs scrub status /mnt | Check the status of a scrub operation |
Quotas and Limits
#
Command/Option | Example | Description |
---|
btrfs quota enable | btrfs quota enable /mnt | Enable quotas on a Btrfs file system |
btrfs qgroup limit | btrfs qgroup limit 10G /mnt | Set a quota limit on a Btrfs file system |
This cheatsheet covers essential Btrfs commands and options to help you manage and maintain Btrfs file systems effectively.