summaryrefslogtreecommitdiff
path: root/Documentation/btrfs-check.8
blob: da562a572e7a25eccf55e7960bff306522b434b8 (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
220
221
222
223
224
225
226
227
228
229
230
'\" t
.\"     Title: btrfs-check
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 12/05/2018
.\"    Manual: Btrfs Manual
.\"    Source: Btrfs v4.19.1
.\"  Language: English
.\"
.TH "BTRFS\-CHECK" "8" "12/05/2018" "Btrfs v4\&.19\&.1" "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 a btrfs filesystem
.SH "SYNOPSIS"
.sp
\fBbtrfs check\fR [options] \fI<device>\fR
.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\fR)\&.
.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 advised to do so by a developer or an experienced user, and then only after having accepted that no \fIfsck\fR successfully repair all types of filesystem corruption\&. Eg\&. some other software or hardware bugs can fatally damage a volume\&.
.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, 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\&.
.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, and is basically and offline
\fIscrub\fR
but does not repair data from spare copies\&.
.RE
.PP
\-\-chunk\-root \fI<bytenr>\fR
.RS 4
use the given offset
\fIbytenr\fR
for the chunk tree root
.RE
.PP
\-E|\-\-subvol\-extents \fI<subvolid>\fR
.RS 4
show extent state for the given subvolume
.RE
.PP
\-p|\-\-progress
.RS 4
indicate progress at various checking phases
.RE
.PP
\-Q|\-\-qgroup\-report
.RS 4
verify qgroup accounting and compare against filesystem accounting
.RE
.PP
\-r|\-\-tree\-root \fI<bytenr>\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<superblock>\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
.PP
\-\-clear\-space\-cache v1|v2
.RS 4
completely wipe all free space cache of given type
.sp
For free space cache
\fIv1\fR, the
\fIclear_cache\fR
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\fR
makes it possible to actually clear the entire free space cache\&.
.sp
For free space cache
\fIv2\fR, the
\fIclear_cache\fR
kernel mount option destroys the entire free space cache\&. This option, with
\fIv2\fR
provides an alternative method of clearing the free space cache that doesn\(cqt require mounting the filesystem\&.
.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 consumption 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
.PP
\-\-force
.RS 4
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\&.
.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)