{
    "content": [
        {
            "type": "text",
            "text": "# btrfs-scrub(8) (man)\n\n## TLDR\n\n> Scrub btrfs filesystems to verify data integrity.\n\n- Start a scrub:\n  `sudo btrfs {{sc|scrub}} start {{path/to/btrfs_mount}}`\n- Show the status of an ongoing or last completed scrub:\n  `sudo btrfs {{sc|scrub}} status {{path/to/btrfs_mount}}`\n- Cancel an ongoing scrub:\n  `sudo btrfs {{sc|scrub}} {{c|cancel}} {{path/to/btrfs_mount}}`\n- Resume a previously cancelled scrub:\n  `sudo btrfs {{sc|scrub}} {{r|resume}} {{path/to/btrfs_mount}}`\n- Start a scrub, but do not put the program in the [B]ackground:\n  `sudo btrfs {{sc|scrub}} start -B {{path/to/btrfs_mount}}`\n- Start a scrub in quiet mode (does not print errors or statistics):\n  `sudo btrfs {{sc|scrub}} start {{-q|--quiet}} {{path/to/btrfs_mount}}`\n\n*Source: tldr-pages*\n\n---\n\n**Summary:** btrfs-scrub - scrub btrfs filesystem, verify block checksums\n\n**Synopsis:** btrfs scrub <subcommand> <args>\n\n## See Also\n\n- mkfs.btrfs(8)\n- ionice(1)\n- BTRFS-SCRUB(8)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (25 lines)\n- **SUBCOMMAND** (97 lines)\n- **EXIT STATUS** (12 lines)\n- **AVAILABILITY** (3 lines)\n- **SEE ALSO** (5 lines)\n\n## Full Content\n\n### NAME\n\nbtrfs-scrub - scrub btrfs filesystem, verify block checksums\n\n### SYNOPSIS\n\nbtrfs scrub <subcommand> <args>\n\n### DESCRIPTION\n\nbtrfs scrub is used to scrub a mounted btrfs filesystem, which will read all data and\nmetadata blocks from all devices and verify checksums. Automatically repair corrupted blocks\nif there’s a correct copy available.\n\nNote\nScrub is not a filesystem checker (fsck) and does not verify nor repair structural damage\nin the filesystem. It really only checks checksums of data and tree blocks, it doesn’t\nensure the content of tree blocks is valid and consistent. There’s some validation\nperformed when metadata blocks are read from disk but it’s not extensive and cannot\nsubstitute full btrfs check run.\n\nThe user is supposed to run it manually or via a periodic system service. The recommended\nperiod is a month but could be less. The estimated device bandwidth utilization is about 80%\non an idle filesystem. The IO priority class is by default idle so background scrub should\nnot significantly interfere with normal filesystem operation. The IO scheduler set for the\ndevice(s) might not support the priority classes though.\n\nThe scrubbing status is recorded in /var/lib/btrfs/ in textual files named scrub.status.UUID\nfor a filesystem identified by the given UUID. (Progress state is communicated through a\nnamed pipe in file scrub.progress.UUID in the same directory.) The status file is updated\nevery 5 seconds. A resumed scrub will continue from the last saved position.\n\nScrub can be started only on a mounted filesystem, though it’s possible to scrub only a\nselected device. See scrub start for more.\n\n### SUBCOMMAND\n\ncancel <path>|<device>\nIf a scrub is running on the filesystem identified by path or device, cancel it.\n\nIf a device is specified, the corresponding filesystem is found and btrfs scrub cancel\nbehaves as if it was called on that filesystem. The progress is saved in the status file\nso btrfs scrub resume can continue from the last position.\n\nresume [-BdqrR] [-c <ioprioclass> -n <ioprioclassdata>] <path>|<device>\nResume a cancelled or interrupted scrub on the filesystem identified by path or on a\ngiven device. The starting point is read from the status file if it exists.\n\nThis does not start a new scrub if the last scrub finished successfully.\n\nOptions\n\nsee scrub start.\n\nstart [-BdqrRf] [-c <ioprioclass> -n <ioprioclassdata>] <path>|<device>\nStart a scrub on all devices of the mounted filesystem identified by path or on a single\ndevice. If a scrub is already running, the new one will not start. A device of an\nunmounted filesystem cannot be scrubbed this way.\n\nWithout options, scrub is started as a background process. The automatic repairs of\ndamaged copies is performed by default for block group profiles with redundancy.\n\nThe default IO priority of scrub is the idle class. The priority can be configured\nsimilar to the ionice(1) syntax using -c and -n options. Note that not all IO schedulers\nhonor the ionice settings.\n\nOptions\n\n-B\ndo not background and print scrub statistics when finished\n\n-d\nprint separate statistics for each device of the filesystem (-B only) at the end\n\n-r\nrun in read-only mode, do not attempt to correct anything, can be run on a read-only\nfilesystem\n\n-R\nraw print mode, print full data instead of summary\n\n-c <ioprioclass>\nset IO priority class (see ionice(1) manpage)\n\n-n <ioprioclassdata>\nset IO priority classdata (see ionice(1) manpage)\n\n-f\nforce starting new scrub even if a scrub is already running, this can useful when\nscrub status file is damaged and reports a running scrub although it is not, but\nshould not normally be necessary\n\n-q\n(deprecated) alias for global -q option\n\nstatus [options] <path>|<device>\nShow status of a running scrub for the filesystem identified by path or for the specified\ndevice.\n\nIf no scrub is running, show statistics of the last finished or cancelled scrub for that\nfilesystem or device.\n\nOptions\n\n-d\nprint separate statistics for each device of the filesystem\n\n-R\nprint all raw statistics without postprocessing as returned by the status ioctl\n\n--raw\nprint all numbers raw values in bytes without the B suffix\n\n--human-readable\nprint human friendly numbers, base 1024, this is the default\n\n--iec\nselect the 1024 base for the following options, according to the IEC standard\n\n--si\nselect the 1000 base for the following options, according to the SI standard\n\n--kbytes\nshow sizes in KiB, or kB with --si\n\n--mbytes\nshow sizes in MiB, or MB with --si\n\n--gbytes\nshow sizes in GiB, or GB with --si\n\n--tbytes\nshow sizes in TiB, or TB with --si\n\n### EXIT STATUS\n\nbtrfs scrub returns a zero exit status if it succeeds. Non zero is returned in case of\nfailure:\n\n1\nscrub couldn’t be performed\n\n2\nthere is nothing to resume\n\n3\nscrub found uncorrectable errors\n\n### AVAILABILITY\n\nbtrfs is part of btrfs-progs. Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for\nfurther details.\n\n### SEE ALSO\n\nmkfs.btrfs(8), ionice(1)\n\n\n\nBtrfs v5.16.2                                02/16/2022                               BTRFS-SCRUB(8)\n\n"
        }
    ],
    "structuredContent": {
        "command": "btrfs-scrub",
        "section": "8",
        "mode": "man",
        "summary": "btrfs-scrub - scrub btrfs filesystem, verify block checksums",
        "synopsis": "btrfs scrub <subcommand> <args>",
        "tldr_summary": "Scrub btrfs filesystems to verify data integrity.",
        "tldr_examples": [
            {
                "description": "Start a scrub",
                "command": "sudo btrfs {{sc|scrub}} start {{path/to/btrfs_mount}}"
            },
            {
                "description": "Show the status of an ongoing or last completed scrub",
                "command": "sudo btrfs {{sc|scrub}} status {{path/to/btrfs_mount}}"
            },
            {
                "description": "Cancel an ongoing scrub",
                "command": "sudo btrfs {{sc|scrub}} {{c|cancel}} {{path/to/btrfs_mount}}"
            },
            {
                "description": "Resume a previously cancelled scrub",
                "command": "sudo btrfs {{sc|scrub}} {{r|resume}} {{path/to/btrfs_mount}}"
            },
            {
                "description": "Start a scrub, but do not put the program in the [B]ackground",
                "command": "sudo btrfs {{sc|scrub}} start -B {{path/to/btrfs_mount}}"
            },
            {
                "description": "Start a scrub in quiet mode (does not print errors or statistics)",
                "command": "sudo btrfs {{sc|scrub}} start {{-q|--quiet}} {{path/to/btrfs_mount}}"
            }
        ],
        "tldr_source": "official",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "mkfs.btrfs",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/mkfs.btrfs/8/json"
            },
            {
                "name": "ionice",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ionice/1/json"
            },
            {
                "name": "BTRFS-SCRUB",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/BTRFS-SCRUB/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "SUBCOMMAND",
                "lines": 97,
                "subsections": []
            },
            {
                "name": "EXIT STATUS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}