'\" t
.\" Title: btrfs-check
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1
.\" Date: 09/22/2016
.\" Manual: Btrfs Manual
.\" Source: Btrfs v4.7.3
.\" Language: English
.\"
.TH "BTRFS\-CHECK" "8" "09/22/2016" "Btrfs v4\&.7\&.3" "Btrfs Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
btrfs-check \- check or repair an unmounted btrfs filesystem
.SH "SYNOPSIS"
.sp
\fBbtrfs check\fR [options] \fI\fR
.SH "DESCRIPTION"
.sp
The filesystem checker is used to verify structural integrity of a filesystem and attempt to repair it if requested\&. The filesystem must be unmounted\&.
.sp
By default, \fBbtrfs check\fR will not modify the device but you can reaffirm that by the option \fI\-\-readonly\fR\&.
.sp
\fBbtrfsck\fR is an alias of \fBbtrfs check\fR command and is now deprecated\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBWarning\fR
.ps -1
.br
.sp
Do not use \fI\-\-repair\fR unless you are adviced to by a developer, an experienced user or accept the fact that \fIfsck\fR cannot possibly fix all sorts of damage that could happen to a filesystem because of software and hardware bugs\&.
.sp .5v
.RE
.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, backrefrences, 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, smililarly the run time\&.
.SH "SAFE OR ADVISORY OPTIONS"
.PP
\-b|\-\-backup
.RS 4
use the first valid set of backup roots stored in the superblock
.sp
This can be combined with
\fI\-\-super\fR
if some of the superblocks are damaged\&.
.RE
.PP
\-\-check\-data\-csum
.RS 4
verify checksums of data blocks
.sp
This expects that the filesystem is otherwise OK, so this is basically and offline
\fIscrub\fR
but does not repair data from spare coipes\&.
.RE
.PP
\-\-chunk\-root \fI\fR
.RS 4
use the given offset
\fIbytenr\fR
for the chunk tree root
.RE
.PP
\-E|\-\-subvol\-extents \fI\fR
.RS 4
show extent state for the given subvolume
.RE
.PP
\-p|\-\-progress
.RS 4
indicate progress at various checking phases
.RE
.PP
\-\-qgroup\-report
.RS 4
verify qgroup accounting and compare against filesystem accounting
.RE
.PP
\-r|\-\-tree\-root \fI\fR
.RS 4
use the given offset
\fIbytenr\fR
for the tree root
.RE
.PP
\-\-readonly
.RS 4
(default) run in read\-only mode, this option exists to calm potential panic when users are going to run the checker
.RE
.PP
\-s|\-\-super \fI\fR
.RS 4
use \*(Aqsuperblock\(cqth 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\&.
.RE
.SH "DANGEROUS OPTIONS"
.PP
\-\-repair
.RS 4
enable the repair mode and attempt to fix problems where possible
.RE
.PP
\-\-init\-csum\-tree
.RS 4
create a new checksum tree and recalculate checksums in all files
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
Do not blindly use this option to fix checksum mismatch problems\&.
.sp .5v
.RE
.RE
.PP
\-\-init\-extent\-tree
.RS 4
build the extent tree from scratch
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
Do not use unless you know what you\(cqre doing\&.
.sp .5v
.RE
.RE
.PP
\-\-mode=MODE
.RS 4
select mode of operation regarding memory and IO
.sp
The
\fIMODE\fR
can be one of
\fIoriginal\fR
and
\fIlowmem\fR\&. The original mode is mostly unoptimized regarding memory consumpption and can lead to out\-of\-memory conditions on large filesystems\&. The possible workaround is to export the block device over network to a machine with enough memory\&. The low memory mode is supposed to address the memory consumption, at the cost of increased IO when it needs to re\-read blocks when needed\&. This may increase run time\&.
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.sp
\fIlowmem\fR mode does not work with \fI\-\-repair\fR yet, and is still considered experimental\&.
.sp .5v
.RE
.SH "EXIT STATUS"
.sp
\fBbtrfs check\fR returns a zero exit status if it succeeds\&. Non zero is returned in case of failure\&.
.SH "AVAILABILITY"
.sp
\fBbtrfs\fR is part of btrfs\-progs\&. Please refer to the btrfs wiki \m[blue]\fBhttp://btrfs\&.wiki\&.kernel\&.org\fR\m[] for further details\&.
.SH "SEE ALSO"
.sp
\fBmkfs\&.btrfs\fR(8), \fBbtrfs\-scrub\fR(8), \fBbtrfs\-rescue\fR(8)