fsck.btrfs - Linux


fsck.btrfs is a command-line tool for checking and repairing the integrity of Btrfs file systems. It’s used to detect and fix errors that may occur due to power outages, hardware failures, or software bugs.


fsck.btrfs [options] <device>


  • -a: Automatic repair mode. Attempts to repair all errors without prompting for confirmation.
  • -C: Check only the superblock and its immediate vicinity, reducing runtime.
  • -f: Force check even if the file system is not marked dirty.
  • -p: Print btree statistics for each root.
  • -s: Show the current state of the file system.


Check and repair a Btrfs file system:

fsck.btrfs -a /dev/sda1

Check the file system state without repairing:

fsck.btrfs -s /dev/sda1

Check only the superblock:

fsck.btrfs -C /dev/sda1

Common Issues

  • File system is dirty: If the file system is marked dirty, fsck.btrfs will refuse to check it automatically. Use the -f flag to force a check in this case.
  • Data loss: Repairing file systems can sometimes result in data loss. Always back up important data before using fsck.btrfs.
  • Unrecoverable errors: In severe cases, fsck.btrfs may report unrecoverable errors. It’s important to note that data recovery may not be possible at this point.


Mount a file system after fsck.btrfs:

fsck.btrfs -a /dev/sda1 && mount /dev/sda1 /mnt

Use fsck.btrfs in a recovery script:


if [ -f /dev/sda1 ]; then
  fsck.btrfs -C /dev/sda1 && mount /dev/sda1 /mnt
  echo "Error: File system not found"

Related Commands

  • btrfsck: A utility for performing advanced file system checks and repairs on Btrfs file systems.
  • debugfs: A tool for debugging Btrfs file systems.
  • fdisk: A tool for partitioning hard disks.