LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

btrfs-check

Check and repair btrfs filesystem integrity

TLDR

Check a filesystem read-only, which is the default and is safe
$ sudo btrfs check [/dev/sda1]
copy
Show progress while it runs
$ sudo btrfs check --progress [/dev/sda1]
copy
Verify the data checksums as well as the metadata
$ sudo btrfs check --check-data-csum [/dev/sda1]
copy
Read a backup superblock when the first one is damaged
$ sudo btrfs check --super [1] [/dev/sda1]
copy
Fall back to the backup roots
$ sudo btrfs check --backup [/dev/sda1]
copy
Trade speed for lower memory use on a large filesystem
$ sudo btrfs check --mode lowmem [/dev/sda1]
copy
Report quota group inconsistencies
$ sudo btrfs check --qgroup-report [/dev/sda1]
copy
Attempt repairs, which can destroy the filesystem
$ sudo btrfs check --repair [/dev/sda1]
copy
Discard and regenerate the tree of data checksums
$ sudo btrfs check --repair --init-csum-tree [/dev/sda1]
copy
Discard and regenerate the tree that tracks allocated extents
$ sudo btrfs check --repair --init-extent-tree [/dev/sda1]
copy
Drop the free space cache so it is rebuilt at the next mount
$ sudo btrfs check --clear-space-cache v2 [/dev/sda1]
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)

INSTALL

sudo apt install btrfs-progs
copy
sudo dnf install btrfs-progs
copy
sudo pacman -S btrfs-progs
copy
sudo apk add btrfs-progs
copy
brew install btrfs-progs
copy
nix profile install nixpkgs#btrfs-progs
copy

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

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid