btrfs scrub Command Examples in Linux

The btrfs scrub command is a command-line utility in Linux that is used to scan and verify the integrity of a btrfs file system. Btrfs is a copy-on-write (CoW) file system that is included in the Linux kernel and is known for its advanced features and capabilities, such as snapshotting, incremental backups, and more.

btrfs scrub is a utility that is included in the btrfs-progs package, which is a collection of tools and libraries for managing btrfs file systems. To use btrfs scrub, you will need to have the btrfs-progs package installed on your Linux system. btrfs-progs is usually available as a package in the repositories of popular Linux distributions, and you can install it using the package manager for your specific distribution.

btrfs scrub is used to scan and verify the integrity of a btrfs file system by comparing the checksums of data blocks and metadata blocks on disk with their expected values. If btrfs scrub finds any discrepancies between the actual and expected values, it will report them and attempt to repair the errors if possible.

btrfs scrub Command Examples

1. Start a scrub:

# btrfs scrub start /path/to/btrfs_mount

2. Show the status of an ongoing or last completed scrub:

# btrfs scrub status /path/to/btrfs_mount

3. Cancel an ongoing scrub:

# btrfs scrub cancel /path/to/btrfs_mount

4. Resume a previously cancelled scrub:

# btrfs scrub resume /path/to/btrfs_mount

5. Start a scrub, but wait until the scrub finishes before exiting:

# btrfs scrub start -B /path/to/btrfs_mount

6. Start a scrub in quiet mode (does not print errors or statistics):

# btrfs scrub start -q /path/to/btrfs_mount
Related Post