LinuxCommandLibrary

btrfs-check

Check and repair btrfs filesystem integrity

TLDR

Check a btrfs filesystem

$ sudo btrfs check [path/to/partition]
copy
Check and repair a btrfs filesystem (dangerous)
$ sudo btrfs check --repair [path/to/partition]
copy
Show the progress of the check
$ sudo btrfs check -p [path/to/partition]
copy
Verify the checksum of each data block
$ sudo btrfs check --check-data-csum [path/to/partition]
copy
Use a specific superblock (0, 1, or 2)
$ sudo btrfs check -s [n] [path/to/partition]
copy
Rebuild the checksum tree
$ sudo btrfs check --repair --init-csum-tree [path/to/partition]
copy
Rebuild the extent tree
$ sudo btrfs check --repair --init-extent-tree [path/to/partition]
copy

SYNOPSIS

btrfs check [options] device

DESCRIPTION

btrfs check examines btrfs filesystem structures for consistency errors and can optionally repair certain types of damage. It operates on unmounted filesystems only.
The check mode is non-destructive and reports issues. The repair mode attempts fixes but carries risk of data loss if used incorrectly.

PARAMETERS

--repair

Attempt to fix detected errors (dangerous, backup first)
-p, --progress
Show progress during the check
--check-data-csum
Verify data block checksums
-s, --super num
Use the specified superblock copy (0, 1, or 2)
--init-csum-tree
Rebuild the checksum tree from scratch
--init-extent-tree
Rebuild the extent tree from scratch
--readonly
Run in read-only mode (default)

CAVEATS

The filesystem must be unmounted. Repair operations are dangerous and can cause data loss; always backup first. Running check on a mounted filesystem may report false errors. Tree rebuild operations are last-resort options.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community