Forrest logo
tool overview
On this page you find all important commands for the CLI tool btrfs. If the command you are looking for is missing please ask our AI.

btrfs

Btrfs, which stands for "B-tree file system," is a modern copy-on-write (CoW) filesystem developed for Linux operating systems. It was initially designed by Oracle Corporation and later open-sourced.

Btrfs offers several advanced features, including snapshots, subvolumes, RAID support, checksumming, and transparent compression. Snapshots allow users to create read-only copies of the filesystem at a specific point in time, which aids in system backup and recovery.

Subvolumes in Btrfs allow users to create separate logical partitions within the filesystem, similar to directories, but with their own properties and access controls. This feature enhances flexibility and ease of data management.

Btrfs also supports different RAID levels for data redundancy and performance improvement, including RAID0, RAID1, RAID10, and RAID5/6. These RAID configurations provide various levels of data protection and performance options.

Checksumming is a fundamental feature in Btrfs that validates the integrity of data by verifying the checksum of each block. It helps detect and repair corrupted data automatically.

Transparent compression allows Btrfs to compress files and directories on the fly, saving storage space without impacting user experience or requiring manual intervention.

Btrfs includes a command line tool known as "btrfs" that allows users to manage and administer Btrfs filesystems. With this tool, users can create and delete subvolumes, manage snapshots, set RAID configurations, check filesystem health, balance data across devices, and repair any inconsistencies.

The btrfs command line tool provides a comprehensive set of options and commands, making it easy to perform complex filesystem operations. It also supports advanced functionalities like converting an existing ext4 filesystem to Btrfs.

Btrfs is known for its scalability and can handle vast amounts of storage. It supports filesystems up to 16 exabytes in size, making it suitable for both personal and enterprise environments.

Btrfs has gained popularity due to its robustness, flexibility, and its ability to self-heal. It continues to be actively developed and improves with each new Linux kernel release, ensuring continuous enhancements and feature additions.

List of commands for btrfs:

  • btrfs-balance:tldr:2da87 btrfs-balance: Balance all block groups (slow; rewrites all blocks in filesystem).
    $ sudo btrfs balance start ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:466a3 btrfs-balance: Convert data blocks to the raid6 and metadata to raid1c3 (see mkfs.btrfs(8) for profiles).
    $ sudo btrfs balance start -dconvert=${raid6} -mconvert=${raid1c3} ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:6c98d btrfs-balance: Balance a max of 10 metadata chunks with less than 20% utilization and at least 1 chunk on a given device `devid` (see `btrfs filesystem show`).
    $ sudo btrfs balance start -musage=${20},limit=${10},devid=${devid} ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:9b5aa btrfs-balance: Cancel, pause, or resume a running or paused balance operation.
    $ sudo btrfs balance ${select} ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:9c8dc btrfs-balance: Convert data blocks to raid1, skipping already converted chunks (e.g. after a previous cancelled conversion operation).
    $ sudo btrfs balance start -dconvert=${raid1},soft ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:cd02e btrfs-balance: Show the status of a running or paused balance operation.
    $ sudo btrfs balance status ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-balance:tldr:d2677 btrfs-balance: Balance data block groups which are less than 15% utilized, running the operation in the background.
    $ sudo btrfs balance start --bg -dusage=${15} ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-check:tldr:74c69 btrfs-check: Use the `n`-th superblock (`n` can be 0, 1 or 2).
    $ sudo btrfs check --super ${n} ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:a48f4 btrfs-check: Rebuild the checksum tree.
    $ sudo btrfs check --repair --init-csum-tree ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:a682e btrfs-check: Check and repair a btrfs filesystem (dangerous).
    $ sudo btrfs check --repair ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:ac7d9 btrfs-check: Show the progress of the check.
    $ sudo btrfs check --progress ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:b73e3 btrfs-check: Check a btrfs filesystem.
    $ sudo btrfs check ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:f0a88 btrfs-check: Rebuild the extent tree.
    $ sudo btrfs check --repair --init-extent-tree ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-check:tldr:f85ca btrfs-check: Verify the checksum of each data block (if the filesystem is good).
    $ sudo btrfs check --check-data-csum ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-device:tldr:514c8 btrfs-device: Scan all disks and inform the kernel of all detected btrfs filesystems.
    $ sudo btrfs device scan --all-devices
    try on your machine
    explain this command
  • btrfs-device:tldr:68da9 btrfs-device: Display detailed per-disk allocation statistics.
    $ sudo btrfs device usage ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-device:tldr:7d0f3 btrfs-device: Display error statistics.
    $ sudo btrfs device stats ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-device:tldr:8a3e7 btrfs-device: Remove a device from a btrfs filesystem.
    $ sudo btrfs device remove ${select} [${---}]
    try on your machine
    explain this command
  • btrfs-device:tldr:8b29c btrfs-device: Add one or more devices to a btrfs filesystem.
    $ sudo btrfs device add ${path-to-block_device1} [${path-to-block_device2}] ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:11717 btrfs-filesystem: Force syncing unwritten data blocks to disk(s).
    $ sudo btrfs filesystem sync ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:3f2d2 btrfs-filesystem: Defragment a directory recursively (does not cross subvolume boundaries).
    $ sudo btrfs filesystem defragment -v -r ${path-to-directory}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:47653 btrfs-filesystem: Show usage by individual devices.
    $ sudo btrfs filesystem show ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:4ec59 btrfs-filesystem: Defragment a single file on a btrfs filesystem (avoid while a deduplication agent is running).
    $ sudo btrfs filesystem defragment -v ${filename}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:73997 btrfs-filesystem: Summarize disk usage for the files in a directory recursively.
    $ sudo btrfs filesystem du --summarize ${path-to-directory}
    try on your machine
    explain this command
  • btrfs-filesystem:tldr:b0898 btrfs-filesystem: Show filesystem usage (optionally run as root to show detailed information).
    $ btrfs filesystem usage ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:10962 btrfs-inspect-internal: Print filesystem's metadata information.
    $ sudo btrfs inspect-internal dump-tree ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:3ad75 btrfs-inspect-internal: Print list of files in inode `n`-th.
    $ sudo btrfs inspect-internal inode-resolve ${n} ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:5e408 btrfs-inspect-internal: Print stats of root, extent, csum and fs trees.
    $ sudo btrfs inspect-internal tree-stats ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:c3e6a btrfs-inspect-internal: Print superblock's and all of its copies' information.
    $ sudo btrfs inspect-internal dump-super --all ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:c4c0b btrfs-inspect-internal: Print superblock's information.
    $ sudo btrfs inspect-internal dump-super ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-inspect-internal:tldr:fc672 btrfs-inspect-internal: Print list of files at a given logical address.
    $ sudo btrfs inspect-internal logical-resolve ${logical_address} ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-property:tldr:219d6 btrfs-property: Get all object type-specific properties for the given btrfs filesystem or device.
    $ sudo btrfs property get -t ${select} ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-property:tldr:32cc5 btrfs-property: Get the `label` property for the given btrfs filesystem or device.
    $ sudo btrfs property get ${path-to-btrfs_filesystem} label
    try on your machine
    explain this command
  • btrfs-property:tldr:3c5f6 btrfs-property: Set the `compression` property for a given btrfs inode (either a file or directory).
    $ sudo btrfs property set ${path-to-btrfs_inode} compression ${select}
    try on your machine
    explain this command
  • btrfs-property:tldr:b2f80 btrfs-property: Get all properties for the given btrfs object.
    $ sudo btrfs property get ${path-to-btrfs_object}
    try on your machine
    explain this command
  • btrfs-property:tldr:f75e7 btrfs-property: List available properties (and descriptions) for the given btrfs object.
    $ sudo btrfs property list ${path-to-btrfs_object}
    try on your machine
    explain this command
  • btrfs-rescue:tldr:06b31 btrfs-rescue: Create a `/dev/btrfs-control` control device when `mknod` is not installed.
    $ sudo btrfs rescue create-control-device
    try on your machine
    explain this command
  • btrfs-rescue:tldr:7f54d btrfs-rescue: Rebuild the filesystem metadata tree (very slow).
    $ sudo btrfs rescue chunk-recover ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-rescue:tldr:81f45 btrfs-rescue: Recover from an interrupted transactions (fixes log replay problems).
    $ sudo btrfs rescue zero-log ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-rescue:tldr:a4e26 btrfs-rescue: Fix device size alignment related problems (e.g. unable to mount the filesystem with super total bytes mismatch).
    $ sudo btrfs rescue fix-device-size ${path-to-partition}
    try on your machine
    explain this command
  • btrfs-restore:tldr:37794 btrfs-restore: Restore files from a btrfs filesystem using a specific root tree `bytenr` (see `btrfs-find-root`).
    $ sudo btrfs restore -t ${bytenr} ${path-to-btrfs_device} ${path-to-target_directory}
    try on your machine
    explain this command
  • btrfs-restore:tldr:55b79 btrfs-restore: Restore all files from a btrfs filesystem to a given directory.
    $ sudo btrfs restore ${path-to-btrfs_device} ${path-to-target_directory}
    try on your machine
    explain this command
  • btrfs-restore:tldr:d863c btrfs-restore: Restore files matching a given regex ([c]ase-insensitive) files to be restored from a btrfs filesystem (all parent directories of target file(s) must match as well).
    $ sudo btrfs restore --path-regex ${regex} -c ${path-to-btrfs_device} ${path-to-target_directory}
    try on your machine
    explain this command
  • btrfs-restore:tldr:f5170 btrfs-restore: List (don't write) files to be restored from a btrfs filesystem.
    $ sudo btrfs restore --dry-run ${path-to-btrfs_device} ${path-to-target_directory}
    try on your machine
    explain this command
  • btrfs-restore:tldr:fb98b btrfs-restore: Restore files from a btrfs filesystem (along with metadata, extended attributes, and Symlinks), overwriting files in the target.
    $ sudo btrfs restore --metadata --xattr --symlinks --overwrite ${path-to-btrfs_device} ${path-to-target_directory}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:2071b btrfs-scrub: Start a scrub, but wait until the scrub finishes before exiting.
    $ sudo btrfs scrub start -B ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:3cd67 btrfs-scrub: Cancel an ongoing scrub.
    $ sudo btrfs scrub cancel ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:94c9a btrfs-scrub: Start a scrub.
    $ sudo btrfs scrub start ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:a26c9 btrfs-scrub: Resume a previously cancelled scrub.
    $ sudo btrfs scrub resume ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:d8f3b btrfs-scrub: Show the status of an ongoing or last completed scrub.
    $ sudo btrfs scrub status ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-scrub:tldr:f8e70 btrfs-scrub: Start a scrub in quiet mode (does not print errors or statistics).
    $ sudo btrfs scrub start -q ${path-to-btrfs_mount}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:688e9 btrfs-subvolume: Create a read-write snapshot of an existing subvolume.
    $ sudo btrfs subvolume snapshot ${path-to-source_subvolume} ${path-to-target}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:6f6de btrfs-subvolume: List all subvolumes and snapshots in the specified filesystem.
    $ sudo btrfs subvolume list ${path-to-btrfs_filesystem}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:9f578 btrfs-subvolume: Delete a subvolume.
    $ sudo btrfs subvolume delete ${path-to-subvolume}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:bfe4b btrfs-subvolume: Create a new empty subvolume.
    $ sudo btrfs subvolume create ${path-to-new_subvolume}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:d38c8 btrfs-subvolume: Show detailed information about a subvolume.
    $ sudo btrfs subvolume show ${path-to-subvolume}
    try on your machine
    explain this command
  • btrfs-subvolume:tldr:f68c6 btrfs-subvolume: Create a read-only snapshot of an existing subvolume.
    $ sudo btrfs subvolume snapshot -r ${path-to-source_subvolume} ${path-to-target}
    try on your machine
    explain this command
  • btrfs-version:tldr:34814 btrfs-version: Display help.
    $ btrfs version --help
    try on your machine
    explain this command
  • btrfs-version:tldr:e3cc7 btrfs-version: Display btrfs-progs version.
    $ btrfs version
    try on your machine
    explain this command
  • btrfs:tldr:3a364 btrfs: Show space usage information.
    $ sudo btrfs filesystem df ${path-to-mount_point}
    try on your machine
    explain this command
  • btrfs:tldr:4bb21 btrfs: Enable quota.
    $ sudo btrfs quota enable ${path-to-subvolume}
    try on your machine
    explain this command
  • btrfs:tldr:c2469 btrfs: Show quota.
    $ sudo btrfs qgroup show ${path-to-subvolume}
    try on your machine
    explain this command
tool overview