{
    "content": [
        {
            "type": "text",
            "text": "# BTRFS-CHECK (info)\n\n## NAME\n\nbtrfs-check - check or repair a btrfs filesystem\n\n## SYNOPSIS\n\nbtrfs check [options] <device>\n\n## DESCRIPTION\n\nThe filesystem checker is used to verify structural integrity of a\nfilesystem and attempt to repair it if requested. It is recommended to\nunmount the filesystem prior to running the check, but it is possible\nto start checking a mounted filesystem (see --force).\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SAFE OR ADVISORY OPTIONS** (4 subsections)\n- **DANGEROUS OPTIONS** (5 subsections)\n- **EXIT STATUS**\n- **AVAILABILITY**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "BTRFS-CHECK",
        "section": "",
        "mode": "info",
        "summary": "btrfs-check - check or repair a btrfs filesystem",
        "synopsis": "btrfs check [options] <device>",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "",
                "long": "--check-data-csum",
                "arg": null,
                "description": "verify checksums of data blocks This expects that the filesystem is otherwise OK, and is basically an offline scrub that does not repair data from spare copies."
            },
            {
                "flag": "",
                "long": "--chunk-root",
                "arg": "<bytenr>",
                "description": "use the given offset bytenr for the chunk tree root -E|--subvol-extents <subvolid> show extent state for the given subvolume -p|--progress indicate progress at various checking phases -Q|--qgroup-report verify qgroup accounting and compare against filesystem accounting -r|--tree-root <bytenr> use the given offset bytenr for the tree root"
            },
            {
                "flag": "",
                "long": "--readonly",
                "arg": null,
                "description": "(default) run in read-only mode, this option exists to calm potential panic when users are going to run the checker -s|--super <superblock> use 'superblock'th superblock copy, valid values are 0, 1 or 2 if the respective superblock offset is within the device size This can be used to use a different starting point if some of the primary superblock is damaged. --clear-space-cache v1|v2 completely wipe all free space cache of given type For free space cache v1, the clearcache kernel mount option only rebuilds the free space cache for block groups that are modified while the filesystem is mounted with that option. Thus, using this option with v1 makes it possible to actually clear the entire free space cache. For free space cache v2, the clearcache kernel mount option destroys the entire free space cache. This option, with v2 provides an alternative method of clearing the free space cache that doesn't require mounting the filesystem."
            },
            {
                "flag": "",
                "long": "--clear-ino-cache",
                "arg": null,
                "description": "remove leftover items pertaining to the deprecated inode map feature"
            },
            {
                "flag": "",
                "long": "--repair",
                "arg": null,
                "description": "enable the repair mode and attempt to fix problems where possible Note there's a warning and 10 second delay when this option is run without --force to give users a chance to think twice before running repair, the warnings in documentation have shown to be insufficient"
            },
            {
                "flag": "",
                "long": "--init-csum-tree",
                "arg": null,
                "description": "create a new checksum tree and recalculate checksums in all files Note Do not blindly use this option to fix checksum mismatch problems."
            },
            {
                "flag": "",
                "long": "--init-extent-tree",
                "arg": null,
                "description": "build the extent tree from scratch Note Do not use unless you know what you're doing."
            },
            {
                "flag": "",
                "long": "--mode",
                "arg": "<MODE>",
                "description": "select mode of operation regarding memory and IO The MODE can be one of: original The metadata are read into memory and verified, thus the requirements are high on large filesystems and can even lead to out-of-memory conditions. The possible workaround is to export the block device over network to a machine with enough memory. lowmem This mode is supposed to address the high memory consumption at the cost of increased IO when it needs to re-read blocks. This may increase run time. Note lowmem mode does not work with --repair yet, and is still considered experimental."
            },
            {
                "flag": "",
                "long": "--force",
                "arg": null,
                "description": "allow work on a mounted filesystem. Note that this should work fine on a quiescent or read-only mounted filesystem but may crash if the device is changed externally, eg. by the kernel module. Repair without mount checks is not supported right now. This option also skips the delay and warning in the repair mode (see --repair)."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "mkfs.btrfs",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/mkfs.btrfs/8/json"
            },
            {
                "name": "btrfs-scrub",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/btrfs-scrub/8/json"
            },
            {
                "name": "btrfs-rescue",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/btrfs-rescue/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "SAFE OR ADVISORY OPTIONS",
                "lines": 6,
                "subsections": [
                    {
                        "name": "--check-data-csum",
                        "lines": 5,
                        "long": "--check-data-csum"
                    },
                    {
                        "name": "--chunk-root <bytenr>",
                        "lines": 14,
                        "long": "--chunk-root",
                        "arg": "<bytenr>"
                    },
                    {
                        "name": "--readonly",
                        "lines": 24,
                        "long": "--readonly"
                    },
                    {
                        "name": "--clear-ino-cache",
                        "lines": 3,
                        "long": "--clear-ino-cache"
                    }
                ]
            },
            {
                "name": "DANGEROUS OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "--repair",
                        "lines": 8,
                        "long": "--repair"
                    },
                    {
                        "name": "--init-csum-tree",
                        "lines": 6,
                        "long": "--init-csum-tree"
                    },
                    {
                        "name": "--init-extent-tree",
                        "lines": 5,
                        "long": "--init-extent-tree"
                    },
                    {
                        "name": "--mode <MODE>",
                        "lines": 19,
                        "long": "--mode",
                        "arg": "<MODE>"
                    },
                    {
                        "name": "--force",
                        "lines": 8,
                        "long": "--force"
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "btrfs-check - check or repair a btrfs filesystem\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "btrfs check [options] <device>\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The filesystem checker is used to verify structural integrity of a\nfilesystem and attempt to repair it if requested. It is recommended to\nunmount the filesystem prior to running the check, but it is possible\nto start checking a mounted filesystem (see --force).\n\nBy default, btrfs check will not modify the device but you can reaffirm\nthat by the option --readonly.\n\nbtrfsck is an alias of btrfs check command and is now deprecated.\n\nWarning\nDo not use --repair unless you are advised to do so by a developer\nor an experienced user, and then only after having accepted that no\nfsck successfully repair all types of filesystem corruption. Eg.\nsome other software or hardware bugs can fatally damage a volume.\n\nThe structural integrity check verifies if internal filesystem objects\nor data structures satisfy the constraints, point to the right objects\nor are correctly connected together.\n\nThere are several cross checks that can detect wrong reference counts\nof shared extents, backreferences, missing extents of inodes, directory\nand inode connectivity etc.\n\nThe amount of memory required can be high, depending on the size of the\nfilesystem, similarly the run time. Check the modes that can also\naffect that.\n",
                "subsections": []
            },
            "SAFE OR ADVISORY OPTIONS": {
                "content": "-b|--backup\nuse the first valid set of backup roots stored in the superblock\n\nThis can be combined with --super if some of the superblocks are\ndamaged.\n",
                "subsections": [
                    {
                        "name": "--check-data-csum",
                        "content": "verify checksums of data blocks\n\nThis expects that the filesystem is otherwise OK, and is basically\nan offline scrub that does not repair data from spare copies.\n",
                        "long": "--check-data-csum"
                    },
                    {
                        "name": "--chunk-root <bytenr>",
                        "content": "use the given offset bytenr for the chunk tree root\n\n-E|--subvol-extents <subvolid>\nshow extent state for the given subvolume\n\n-p|--progress\nindicate progress at various checking phases\n\n-Q|--qgroup-report\nverify qgroup accounting and compare against filesystem accounting\n\n-r|--tree-root <bytenr>\nuse the given offset bytenr for the tree root\n",
                        "long": "--chunk-root",
                        "arg": "<bytenr>"
                    },
                    {
                        "name": "--readonly",
                        "content": "(default) run in read-only mode, this option exists to calm\npotential panic when users are going to run the checker\n\n-s|--super <superblock>\nuse 'superblock'th superblock copy, valid values are 0, 1 or 2 if\nthe respective superblock offset is within the device size\n\nThis can be used to use a different starting point if some of the\nprimary superblock is damaged.\n\n--clear-space-cache v1|v2\ncompletely wipe all free space cache of given type\n\nFor free space cache v1, the clearcache kernel mount option only\nrebuilds the free space cache for block groups that are modified\nwhile the filesystem is mounted with that option. Thus, using this\noption with v1 makes it possible to actually clear the entire free\nspace cache.\n\nFor free space cache v2, the clearcache kernel mount option\ndestroys the entire free space cache. This option, with v2 provides\nan alternative method of clearing the free space cache that doesn't\nrequire mounting the filesystem.\n",
                        "long": "--readonly"
                    },
                    {
                        "name": "--clear-ino-cache",
                        "content": "remove leftover items pertaining to the deprecated inode map\nfeature\n",
                        "long": "--clear-ino-cache"
                    }
                ]
            },
            "DANGEROUS OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "--repair",
                        "content": "enable the repair mode and attempt to fix problems where possible\n\nNote\nthere's a warning and 10 second delay when this option is run\nwithout --force to give users a chance to think twice before\nrunning repair, the warnings in documentation have shown to be\ninsufficient\n",
                        "long": "--repair"
                    },
                    {
                        "name": "--init-csum-tree",
                        "content": "create a new checksum tree and recalculate checksums in all files\n\nNote\nDo not blindly use this option to fix checksum mismatch\nproblems.\n",
                        "long": "--init-csum-tree"
                    },
                    {
                        "name": "--init-extent-tree",
                        "content": "build the extent tree from scratch\n\nNote\nDo not use unless you know what you're doing.\n",
                        "long": "--init-extent-tree"
                    },
                    {
                        "name": "--mode <MODE>",
                        "content": "select mode of operation regarding memory and IO\n\nThe MODE can be one of:\n\noriginal\nThe metadata are read into memory and verified, thus the\nrequirements are high on large filesystems and can even lead to\nout-of-memory conditions. The possible workaround is to export\nthe block device over network to a machine with enough memory.\n\nlowmem\nThis mode is supposed to address the high memory consumption at\nthe cost of increased IO when it needs to re-read blocks. This\nmay increase run time.\n\nNote\nlowmem mode does not work with --repair yet, and is still\nconsidered experimental.\n",
                        "long": "--mode",
                        "arg": "<MODE>"
                    },
                    {
                        "name": "--force",
                        "content": "allow work on a mounted filesystem. Note that this should work fine\non a quiescent or read-only mounted filesystem but may crash if the\ndevice is changed externally, eg. by the kernel module. Repair\nwithout mount checks is not supported right now.\n\nThis option also skips the delay and warning in the repair mode\n(see --repair).\n",
                        "long": "--force"
                    }
                ]
            },
            "EXIT STATUS": {
                "content": "btrfs check returns a zero exit status if it succeeds. Non zero is\nreturned in case of failure.\n",
                "subsections": []
            },
            "AVAILABILITY": {
                "content": "btrfs is part of btrfs-progs. Please refer to the btrfs wiki\nhttp://btrfs.wiki.kernel.org for further details.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "mkfs.btrfs(8), btrfs-scrub(8), btrfs-rescue(8)\n\nBtrfs v5.16.2                     02/16/2022                    BTRFS-CHECK(8)",
                "subsections": []
            }
        }
    }
}