summaryrefslogtreecommitdiffstats
path: root/upstream/debian-bookworm/man8/btrfs-check.8
blob: f375376bde77648f185c1da53d47148b6365f218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
.\" Man page generated from reStructuredText.
.
.
.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
..
.TH "BTRFS-CHECK" "8" "Feb 28, 2023" "6.2" "BTRFS"
.SH NAME
btrfs-check \- check or repair a btrfs filesystem
.SH SYNOPSIS
.sp
\fBbtrfs check\fP [options] <device>
.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 \ <bytenr>
use the given offset \fIbytenr\fP for the chunk tree root
.UNINDENT
.INDENT 0.0
.TP
.B \-E|\-\-subvol\-extents <subvolid>
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 <bytenr>
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 <N>
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 \ <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
\fI\%mkfs.btrfs(8)\fP,
\fI\%btrfs\-scrub(8)\fP,
\fI\%btrfs\-rescue(8)\fP
.\" Generated by docutils manpage writer.
.