Forrest logo
back to the btrfs tool

btrfs-check:tldr:f0a88

btrfs-check: Rebuild the extent tree.
$ sudo btrfs check --repair --init-extent-tree ${path-to-partition}
try on your machine

This command is used to check and repair a Btrfs filesystem on a specified partition.

Here's the breakdown of the command:

  • sudo: It is a command that allows the user to run programs with the security privileges of another user, typically the superuser.
  • btrfs: It is the command-line tool for managing Btrfs filesystems.
  • check: It is a subcommand of btrfs used to check the filesystem for inconsistencies and errors.
  • --repair: This flag tells btrfs check to automatically repair any errors it finds during the check process.
  • --init-extent-tree: This flag initializes the extent tree if it is found to be corrupted or uninitialized.
  • ${path-to-partition}: It should be replaced with the actual path to the partition where the Btrfs filesystem resides. For example, it could be /dev/sdb1 for a partition on the second storage device.

When you run this command with appropriate privileges, it will check the specified Btrfs filesystem for errors and inconsistencies. If any issues are found, it will repair them automatically. Additionally, if the extent tree is found to be corrupted or uninitialized, it will initialize it.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the btrfs tool