Btrfs

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/OptionExampleDescription
mkfs.btrfsmkfs.btrfs /dev/sdX1Create a Btrfs file system on a partition
mkfs.btrfs -L label /dev/sdX1mkfs.btrfs -L mylabel /dev/sdX1Create a Btrfs file system with a volume label

File System Checking and Repair #

Command/OptionExampleDescription
btrfs checkbtrfs check /dev/sdX1Check a Btrfs file system for errors
btrfs check --repair /dev/sdX1btrfs check --repair /dev/sdX1Check and repair a Btrfs file system

Mounting and Unmounting #

Command/OptionExampleDescription
mountmount -t btrfs /dev/sdX1 /mntMount a Btrfs file system to a directory
umountumount /mntUnmount the file system

File System Information #

Command/OptionExampleDescription
btrfs filesystem dfbtrfs filesystem df /mntShow space usage for a Btrfs file system
btrfs filesystem showbtrfs filesystem show /mntDisplay detailed information about Btrfs file systems

File System Management #

Command/OptionExampleDescription
btrfs device addbtrfs device add /dev/sdX2 /mntAdd a new device to a Btrfs file system
btrfs device deletebtrfs device delete /dev/sdX2 /mntRemove a device from a Btrfs file system
btrfs balance startbtrfs balance start /mntStart a balance operation to redistribute data across devices

Snapshots and Subvolumes #

Command/OptionExampleDescription
btrfs subvolume createbtrfs subvolume create /mnt/subvolCreate a new Btrfs subvolume
btrfs subvolume deletebtrfs subvolume delete /mnt/subvolDelete a Btrfs subvolume
btrfs snapshotbtrfs snapshot /mnt/subvol /mnt/snapshotCreate a snapshot of a Btrfs subvolume

Compression and Deduplication #

Command/OptionExampleDescription
btrfs property setbtrfs property set /mnt compression lzoSet compression algorithm for a Btrfs file system
btrfs balance start -dbtrfs balance start -d /mntStart deduplication of data blocks

File System Integrity #

Command/OptionExampleDescription
btrfs scrub startbtrfs scrub start /mntStart a scrub operation to check and repair data integrity
btrfs scrub statusbtrfs scrub status /mntCheck the status of a scrub operation

Quotas and Limits #

Command/OptionExampleDescription
btrfs quota enablebtrfs quota enable /mntEnable quotas on a Btrfs file system
btrfs qgroup limitbtrfs qgroup limit 10G /mntSet 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.

Cheatsheet Website

Discover our extensive collection of cheatsheets covering various tools and technologies to streamline your workflow.