btrfsck - Linux


Overview

btrfsck is a command-line tool for checking and repairing Btrfs file systems. It scans the file system for errors, including checksum and data corruption, and attempts to fix them automatically if possible.

Syntax

btrfsck [options] <device>

Options/Flags

  • -a, –auto-repair: Automatically fix detected errors.
  • -c, –check: Only check for errors, do not repair them.
  • -d, –debug: Enable debug mode for enhanced logging.
  • -f, –force: Force the check even if the file system is not unmounted.
  • -p, –progress: Display progress information.
  • -R, –repair: Repair detected errors, prompting for confirmation.
  • -v, –verbose: Enable verbose output.

Examples

Check a Btrfs file system without repairing errors:

btrfsck -c /dev/sda1

Fix errors on a Btrfs file system automatically:

btrfsck -a /dev/sdb1

Repair errors after being prompted for confirmation:

btrfsck -R /dev/sdc1

Common Issues

  • Unable to mount file system: Ensure that the file system is unmounted before running btrfsck.
  • Errors not resolved after repair: Some errors may require manual intervention. Check the log file for more details.
  • Timeout during repair: Increase the repair timeout using the –timeout option.

Integration

  • dumpe2fs: Dump the file system metadata for further analysis.
  • e2fsck: Repair ext2/ext3/ext4 file systems.
  • fsck: Generic file system checker for various file systems.

Related Commands

  • btrfs: Manage Btrfs file systems.
  • fsstat: Display file system statistics.
  • lsblk: List block devices.