.\" Man page generated from reStructuredText. . .TH "BTRFS-CHECK" "8" "Apr 30, 2023" "6.2" "BTRFS" .SH NAME btrfs-check \- check or repair a btrfs filesystem . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp \fBbtrfs check\fP [options] .SH DESCRIPTION .sp The filesystem checker is used to verify structural integrity of a filesystem and attempt to repair it if requested. It is recommended to unmount the filesystem prior to running the check, but it is possible to start checking a mounted filesystem (see \fI\-\-force\fP). .sp By default, \fBbtrfs check\fP will not modify the device but you can reaffirm that by the option \fI\-\-readonly\fP\&. .sp \fBbtrfsck\fP is an alias of \fBbtrfs check\fP command and is now deprecated. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not use \fI\-\-repair\fP unless you are advised to do so by a developer or an experienced user, and then only after having accepted that no \fIfsck\fP successfully repair all types of filesystem corruption. E.g. some other software or hardware bugs can fatally damage a volume. .UNINDENT .UNINDENT .sp The structural integrity check verifies if internal filesystem objects or data structures satisfy the constraints, point to the right objects or are correctly connected together. .sp There are several cross checks that can detect wrong reference counts of shared extents, backreferences, missing extents of inodes, directory and inode connectivity etc. .sp The amount of memory required can be high, depending on the size of the filesystem, similarly the run time. Check the modes that can also affect that. .SH SAFE OR ADVISORY OPTIONS .INDENT 0.0 .TP .B \-b|\-\-backup use the first valid set of backup roots stored in the superblock .sp This can be combined with \fI\-\-super\fP if some of the superblocks are damaged. .UNINDENT .INDENT 0.0 .TP .B \-\-check\-data\-csum verify checksums of data blocks .sp This expects that the filesystem is otherwise OK, and is basically an offline \fIscrub\fP that does not repair data from spare copies. .TP .BI \-\-chunk\-root \ use the given offset \fIbytenr\fP for the chunk tree root .UNINDENT .INDENT 0.0 .TP .B \-E|\-\-subvol\-extents show extent state for the given subvolume .TP .B \-p|\-\-progress indicate progress at various checking phases .TP .B \-Q|\-\-qgroup\-report verify qgroup accounting and compare against filesystem accounting .TP .B \-r|\-\-tree\-root use the given offset \(aqbytenr\(aq for the tree root .UNINDENT .INDENT 0.0 .TP .B \-\-readonly (default) run in read\-only mode, this option exists to calm potential panic when users are going to run the checker .UNINDENT .INDENT 0.0 .TP .B \-s|\-\-super use Nth superblock copy, valid values are 0, 1 or 2 if the respective superblock offset is within the device size .sp This can be used to use a different starting point if some of the primary superblock is damaged. .TP .B \-\-clear\-space\-cache v1|v2 completely wipe all free space cache of given type .sp For free space cache \fIv1\fP, the \fIclear_cache\fP 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 \fIv1\fP makes it possible to actually clear the entire free space cache. .sp For free space cache \fIv2\fP, the \fIclear_cache\fP kernel mount option destroys the entire free space cache. This option, with \fIv2\fP provides an alternative method of clearing the free space cache that doesn\(aqt require mounting the filesystem. .UNINDENT .INDENT 0.0 .TP .B \-\-clear\-ino\-cache remove leftover items pertaining to the deprecated inode map feature .UNINDENT .SH DANGEROUS OPTIONS .INDENT 0.0 .TP .B \-\-repair enable the repair mode and attempt to fix problems where possible .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 There\(aqs a warning and 10 second delay when this option is run without \fI\-\-force\fP to give users a chance to think twice before running repair, the warnings in documentation have shown to be insufficient .UNINDENT .UNINDENT .TP .B \-\-init\-csum\-tree create a new checksum tree and recalculate checksums in all files .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Do not blindly use this option to fix checksum mismatch problems. .UNINDENT .UNINDENT .TP .B \-\-init\-extent\-tree build the extent tree from scratch .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Do not use unless you know what you\(aqre doing. .UNINDENT .UNINDENT .TP .BI \-\-mode \ select mode of operation regarding memory and IO .sp The \fIMODE\fP can be one of: .INDENT 7.0 .TP .B 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. .TP .B 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. .UNINDENT .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIlowmem\fP mode does not work with \fI\-\-repair\fP yet, and is still considered experimental. .UNINDENT .UNINDENT .TP .B \-\-force 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, e.g. by the kernel module. Repair without mount checks is not supported right now. .sp This option also skips the delay and warning in the repair mode (see \fI\-\-repair\fP). .UNINDENT .SH EXIT STATUS .sp \fBbtrfs check\fP returns a zero exit status if it succeeds. Non zero is returned in case of failure. .SH AVAILABILITY .sp \fBbtrfs\fP is part of btrfs\-progs. Please refer to the documentation at \fI\%https://btrfs.readthedocs.io\fP or wiki \fI\%http://btrfs.wiki.kernel.org\fP for further information. .SH SEE ALSO .sp mkfs.btrfs(8), btrfs\-scrub(8), btrfs\-rescue(8) .\" Generated by docutils manpage writer. .