{
    "mode": "man",
    "parameter": "btrfs-check",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/btrfs-check/8/json",
    "generated": "2026-06-03T01:44:58Z",
    "synopsis": "btrfs check [options] <device>",
    "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 filesystem and attempt to\nrepair it if requested. It is recommended to unmount the filesystem prior to running the\ncheck, but it is possible to start checking a mounted filesystem (see --force).\n\nBy default, btrfs check will not modify the device but you can reaffirm that by the option\n--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 or an experienced\nuser, and then only after having accepted that no fsck successfully repair all types of\nfilesystem corruption. Eg. some other software or hardware bugs can fatally damage a\nvolume.\n\nThe structural integrity check verifies if internal filesystem objects or data structures\nsatisfy the constraints, point to the right objects or are correctly connected together.\n\nThere are several cross checks that can detect wrong reference counts of shared extents,\nbackreferences, missing extents of inodes, directory and inode connectivity etc.\n\nThe amount of memory required can be high, depending on the size of the filesystem, similarly\nthe run time. Check the modes that can also affect 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 damaged.\n",
            "subsections": [
                {
                    "name": "--check-data-csum",
                    "content": "verify checksums of data blocks\n\nThis expects that the filesystem is otherwise OK, and is basically an offline scrub that\ndoes not repair data from spare copies.\n\n--chunk-root <bytenr>\nuse 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": "--check-data-csum"
                },
                {
                    "name": "--readonly",
                    "content": "(default) run in read-only mode, this option exists to calm potential panic when users\nare going to run the checker\n\n-s|--super <superblock>\nuse 'superblock’th superblock copy, valid values are 0, 1 or 2 if the respective\nsuperblock offset is within the device size\n\nThis can be used to use a different starting point if some of the primary superblock is\ndamaged.\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 rebuilds the free space\ncache for block groups that are modified while the filesystem is mounted with that\noption. Thus, using this option with v1 makes it possible to actually clear the entire\nfree space cache.\n\nFor free space cache v2, the clearcache kernel mount option destroys the entire free\nspace cache. This option, with v2 provides an alternative method of clearing the free\nspace cache that doesn’t require mounting the filesystem.\n",
                    "long": "--readonly"
                },
                {
                    "name": "--clear-ino-cache",
                    "content": "remove leftover items pertaining to the deprecated inode map feature\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 without --force to give\nusers a chance to think twice before running repair, the warnings in documentation\nhave shown to be insufficient\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 problems.\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\n--mode <MODE>\nselect 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 requirements are high on\nlarge filesystems and can even lead to out-of-memory conditions. The possible\nworkaround is to export the block device over network to a machine with enough\nmemory.\n\nlowmem\nThis mode is supposed to address the high memory consumption at the cost of increased\nIO when it needs to re-read blocks. This may increase run time.\n\nNote\nlowmem mode does not work with --repair yet, and is still considered\nexperimental.\n",
                    "long": "--init-extent-tree"
                },
                {
                    "name": "--force",
                    "content": "allow work on a mounted filesystem. Note that this should work fine on a quiescent or\nread-only mounted filesystem but may crash if the device is changed externally, eg. by\nthe kernel module. Repair without mount checks is not supported right now.\n\nThis option also skips the delay and warning in the repair mode (see --repair).\n",
                    "long": "--force"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "btrfs check returns a zero exit status if it succeeds. Non zero is returned in case of\nfailure.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "btrfs is part of btrfs-progs. Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for\nfurther details.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "mkfs.btrfs(8), btrfs-scrub(8), btrfs-rescue(8)\n\n\n\nBtrfs v5.16.2                                02/16/2022                               BTRFS-CHECK(8)",
            "subsections": []
        }
    },
    "summary": "btrfs-check - check or repair a btrfs filesystem",
    "flags": [],
    "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"
        },
        {
            "name": "BTRFS-CHECK",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/BTRFS-CHECK/8/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Check or repair a btrfs filesystem.",
        "examples": [
            {
                "description": "Check a btrfs filesystem",
                "command": "sudo btrfs {{c|check}} {{path/to/partition}}"
            },
            {
                "description": "Check and repair a btrfs filesystem (dangerous)",
                "command": "sudo btrfs {{c|check}} --repair {{path/to/partition}}"
            },
            {
                "description": "Show the progress of the check",
                "command": "sudo btrfs {{c|check}} {{-p|--progress}} {{path/to/partition}}"
            },
            {
                "description": "Verify the checksum of each data block (if the filesystem is good)",
                "command": "sudo btrfs {{c|check}} --check-data-csum {{path/to/partition}}"
            },
            {
                "description": "Use the `n`-th superblock (`n` can be 0, 1, or 2)",
                "command": "sudo btrfs {{c|check}} {{-s|--super}} {{n}} {{path/to/partition}}"
            },
            {
                "description": "Rebuild the checksum tree",
                "command": "sudo btrfs {{c|check}} --repair --init-csum-tree {{path/to/partition}}"
            },
            {
                "description": "Rebuild the extent tree",
                "command": "sudo btrfs {{c|check}} --repair --init-extent-tree {{path/to/partition}}"
            }
        ]
    }
}