Debian Codegraph @

upstream/opensuse-leap-16-1/man8/btrfs-scrub.8

raw
1 .\" Man page generated from reStructuredText.
2 .
3 .
4 .nr rst2man-indent-level 0
5 .
6 .de1 rstReportMargin
7 \\$1 \\n[an-margin]
8 level \\n[rst2man-indent-level]
9 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
10 -
11 \\n[rst2man-indent0]
12 \\n[rst2man-indent1]
13 \\n[rst2man-indent2]
14 ..
15 .de1 INDENT
16 .\" .rstReportMargin pre:
17 . RS \\$1
18 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
19 . nr rst2man-indent-level +1
20 .\" .rstReportMargin post:
21 ..
22 .de UNINDENT
23 . RE
24 .\" indent \\n[an-margin]
25 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
26 .nr rst2man-indent-level -1
27 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
28 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
29 ..
30 .TH "BTRFS-SCRUB" "8" "Mar 26, 2025" "6.14" "BTRFS"
31 .SH NAME
32 btrfs-scrub \- scrub btrfs filesystem, verify block checksums
33 .SH SYNOPSIS
34 .sp
35 \fBbtrfs scrub\fP <subcommand> <args>
36 .SH DESCRIPTION
37 .sp
38 Scrub is a validation pass over all filesystem data and metadata that detects
39 data checksum errors, basic super block errors, basic metadata block header errors,
40 and disk read errors.
41 .sp
42 Scrub is done on a per\-device base, if a device is specified to \fBbtrfs scrub start\fP,
43 then only that device will be scrubbed. Although btrfs will also try to read
44 other device to find a good copy, if the mirror on that specified device failed
45 to be read or pass verification.
46 .sp
47 If a path of btrfs is specified to \fBbtrfs scrub start\fP, btrfs will scrub
48 all devices in parallel.
49 .sp
50 On filesystems that use replicated block group profiles (e.g. RAID1), read\-write
51 scrub will also automatically repair any damage by copying verified good data
52 from one of the other replicas.
53 .sp
54 Such automatic repair is also carried out when reading metadata or data from a
55 read\-write mounted filesystem.
56 .sp
57 \fBWARNING:\fP
58 .INDENT 0.0
59 .INDENT 3.5
60 As currently implemented, setting the \fBNOCOW\fP file attribute (by
61 \fBchattr +C\fP) on a file implicitly enables
62 \fBNODATASUM\fP\&. This means that while metadata for these files continues to
63 be validated and corrected by scrub, the actual file data is not.
64 .sp
65 Furthermore, btrfs does not currently mark missing or failed disks as
66 unreliable, so will continue to load\-balance reads to potentially damaged
67 replicas. This is not a problem normally because damage is detected by
68 checksum validation, but because \fBNOCOW\fP files are
69 not protected by checksums, btrfs has no idea which mirror is good thus it can
70 return the bad contents to the user space tool.
71 .sp
72 Detecting and recovering from such failure requires manual intervention.
73 .sp
74 Notably, \X'tty: link https://github.com/systemd/systemd/commit/11689d2a021d95a8447d938180e0962cd9439763'\fI\%systemd sets +C on journals by default\fP\X'tty: link',
75 and \X'tty: link https://www.libvirt.org/news.html#v6-6-0-2020-08-02'\fI\%libvirt ≥ 6.6 sets +C on storage pool directories by default\fP\X'tty: link'\&.
76 Other applications or distributions may also set \fB+C\fP to try to improve
77 performance.
78 .UNINDENT
79 .UNINDENT
80 .sp
81 \fBNOTE:\fP
82 .INDENT 0.0
83 .INDENT 3.5
84 Scrub is not a filesystem checker (fsck, \fI\%btrfs\-check(8)\fP). It can only detect
85 filesystem damage using the checksum validation, and it can only repair
86 filesystem damage by copying from other known good replicas.
87 .sp
88 \fI\%btrfs\-check(8)\fP performs more exhaustive checking and can sometimes be
89 used, with expert guidance, to rebuild certain corrupted filesystem structures
90 in the absence of any good replica.
91 .UNINDENT
92 .UNINDENT
93 .sp
94 \fBNOTE:\fP
95 .INDENT 0.0
96 .INDENT 3.5
97 Read\-only scrub on a read\-write filesystem will cause some writes into the
98 filesystem.
99 .sp
100 This is due to the design limitation to prevent race between marking block
101 group read\-only and writing back block group items.
102 .sp
103 To avoid any writes from scrub, one has to run read\-only scrub on read\-only
104 filesystem.
105 .UNINDENT
106 .UNINDENT
107 .sp
108 The user is supposed to run it manually or via a periodic system service. The
109 recommended period is a month but it could be less. The estimated device bandwidth
110 utilization is about 80% on an idle filesystem.
111 .sp
112 The scrubbing status is recorded in \fB/var/lib/btrfs/\fP in textual files named
113 \fIscrub.status.UUID\fP for a filesystem identified by the given UUID. (Progress
114 state is communicated through a named pipe in file \fIscrub.progress.UUID\fP in the
115 same directory.) The status file is updated every 5 seconds. A resumed scrub
116 will continue from the last saved position.
117 .sp
118 Scrub can be started only on a mounted filesystem, though it\(aqs possible to
119 scrub only a selected device. See \fI\%btrfs scrub start\fP for more.
120 .SS Bandwidth and IO limiting
121 .sp
122 \fBNOTE:\fP
123 .INDENT 0.0
124 .INDENT 3.5
125 The \X'tty: link https://man7.org/linux/man-pages/man1/ionice.1.html'\fI\%ionice(1)\fP\X'tty: link' may not be generally supported by all IO schedulers and
126 the options to \fBbtrfs scrub start\fP may not work as expected.
127 .UNINDENT
128 .UNINDENT
129 .sp
130 In the past when the \X'tty: link https://en.wikipedia.org/wiki/Completely_fair_queueing'\fI\%CFQ IO scheduler\fP\X'tty: link' was generally used
131 the \X'tty: link https://man7.org/linux/man-pages/man1/ionice.1.html'\fI\%ionice(1)\fP\X'tty: link' syscalls set the priority to \fIidle\fP so the IO would not
132 interfere with regular IO. Since the kernel 5.0 the CFQ is not available.
133 .sp
134 The IO scheduler known to support that is \X'tty: link https://docs.kernel.org/block/bfq-iosched.html'\fI\%BFQ\fP\X'tty: link', but first read the
135 documentation before using it!
136 .sp
137 For other commonly used schedulers like \X'tty: link https://docs.kernel.org/block/blk-mq.html'\fI\%mq\-deadline\fP\X'tty: link' it\(aqs recommended to use
138 \fIcgroup2 IO controller\fP which could be managed by e.g. \fIsystemd\fP
139 (documented in \fBsystemd.resource\-control\fP). However, starting scrub like that
140 is not yet completely straightforward. The IO controller must know the physical
141 device of the filesystem and create a slice so all processes started from that
142 belong to the same accounting group.
143 .INDENT 0.0
144 .INDENT 3.5
145 .sp
146 .EX
147 $ systemd\-run \-p \(dqIOReadBandwidthMax=/dev/sdx 10M\(dq btrfs scrub start \-B /
148 .EE
149 .UNINDENT
150 .UNINDENT
151 .sp
152 Since linux 5.14 it\(aqs possible to set the per\-device bandwidth limits in a
153 BTRFS\-specific way using files \fB/sys/fs/btrfs/FSID/devinfo/DEVID/scrub_speed_max\fP\&.
154 This setting is not persistent, lasts until the filesystem is unmounted.
155 Currently set limits can be displayed by command \fI\%btrfs scrub
156 limit\fP\&.
157 .INDENT 0.0
158 .INDENT 3.5
159 .sp
160 .EX
161 $ echo 100m > /sys/fs/btrfs/9b5fd16e\-1b64\-4f9b\-904a\-74e74c0bbadc/devinfo/1/scrub_speed_max
162 $ btrfs scrub limit /
163 UUID: 9b5fd16e\-1b64\-4f9b\-904a\-74e74c0bbadc
164 Id Limit Path
165 \-\- \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-
166 1 100.00MiB /dev/sdx
167 .EE
168 .UNINDENT
169 .UNINDENT
170 .SH SUBCOMMAND
171 .INDENT 0.0
172 .TP
173 .B cancel <path>|<device>
174 If a scrub is running on the filesystem identified by \fIpath\fP or
175 \fIdevice\fP, cancel it.
176 .sp
177 If a \fIdevice\fP is specified, the corresponding filesystem is found and
178 \fBbtrfs scrub cancel\fP behaves as if it was called on that filesystem.
179 The progress is saved in the status file so \fBbtrfs scrub resume\fP can
180 continue from the last position.
181 .UNINDENT
182 .INDENT 0.0
183 .TP
184 .B limit [options] <path>
185 Show or set scrub limits on devices of the given filesystem.
186 .sp
187 \fBOptions\fP
188 .INDENT 7.0
189 .TP
190 .B \-d|\-\-devid DEVID
191 select the device by DEVID to apply the limit
192 .TP
193 .B \-l|\-\-limit SIZE
194 set the limit of the device to SIZE (size units with suffix),
195 or 0 to reset to \fIunlimited\fP
196 .TP
197 .B \-a|\-\-all
198 apply the limit to all devices
199 .UNINDENT
200 .INDENT 7.0
201 .TP
202 .B \-\-raw
203 print all numbers raw values in bytes without the \fIB\fP suffix
204 .TP
205 .B \-\-human\-readable
206 print human friendly numbers, base 1024, this is the default
207 .TP
208 .B \-\-iec
209 select the 1024 base for the following options, according to
210 the IEC standard
211 .TP
212 .B \-\-si
213 select the 1000 base for the following options, according to the SI standard
214 .TP
215 .B \-\-kbytes
216 show sizes in KiB, or kB with \-\-si
217 .TP
218 .B \-\-mbytes
219 show sizes in MiB, or MB with \-\-si
220 .TP
221 .B \-\-gbytes
222 show sizes in GiB, or GB with \-\-si
223 .TP
224 .B \-\-tbytes
225 show sizes in TiB, or TB with \-\-si
226 .UNINDENT
227 .TP
228 .B resume [\-BdqrR] <path>|<device>
229 Resume a cancelled or interrupted scrub on the filesystem identified by
230 \fIpath\fP or on a given \fIdevice\fP\&. The starting point is read from the
231 status file if it exists.
232 .sp
233 This does not start a new scrub if the last scrub finished successfully.
234 .sp
235 \fBOptions\fP
236 .sp
237 see \fBscrub start\fP\&.
238 .UNINDENT
239 .INDENT 0.0
240 .TP
241 .B start [options] <path>|<device>
242 Start a scrub on all devices of the mounted filesystem identified by
243 \fIpath\fP or on a single \fIdevice\fP\&. If a scrub is already running, the new
244 one will not start. A device of an unmounted filesystem cannot be
245 scrubbed this way.
246 .sp
247 Without options, scrub is started as a background process. The
248 automatic repairs of damaged copies are performed by default for block
249 group profiles with redundancy. No\-repair can be enabled by option \fI\-r\fP\&.
250 .sp
251 \fBOptions\fP
252 .INDENT 7.0
253 .TP
254 .B \-B
255 do not background and print scrub statistics when finished
256 .TP
257 .B \-d
258 print separate statistics for each device of the filesystem
259 (\fI\-B\fP only) at the end
260 .TP
261 .B \-r
262 run in read\-only mode, do not attempt to correct anything, can
263 be run on a read\-only filesystem
264 .sp
265 Note that a read\-only scrub on a read\-write filesystem can
266 still cause writes into the filesystem due to some internal
267 limitations. Only a read\-only scrub on a read\-only filesystem
268 can avoid writes from scrub.
269 .TP
270 .B \-R
271 raw print mode, print full data instead of summary
272 .TP
273 .BI \-\-limit \ <limit>
274 set the scrub throughput limit for each device.
275 .sp
276 If the scrub is for the whole fs, it\(aqs the same as
277 \fBbtrfs scrub limit \-a \-l <value>\fP\&.
278 If the scrub is for a single device, it\(aqs the same as
279 \fBbtrfs scrub limit \-d <devid> \-l <value>\fP\&.
280 .sp
281 The value is bytes per second, and accepts the usual KMGT prefixes.
282 After the scrub is finished, the throughput limit will be reset to
283 the old value of each device.
284 .TP
285 .B \-f
286 force starting new scrub even if a scrub is already running,
287 this can useful when scrub status file is damaged and reports a
288 running scrub although it is not, but should not normally be
289 necessary
290 .UNINDENT
291 .sp
292 \fBDeprecated options\fP
293 .INDENT 7.0
294 .TP
295 .BI \-c \ <ioprio_class>
296 set IO priority class (see \X'tty: link https://man7.org/linux/man-pages/man1/ionice.1.html'\fI\%ionice(1)\fP\X'tty: link' manual page) if the IO
297 scheduler configured for the device supports ionice. This is
298 only supported by BFQ or Kyber but is \fInot\fP supported by
299 mq\-deadline. Please read the section about
300 \fI\%IO limiting\fP\&.
301 .TP
302 .BI \-n \ <ioprio_classdata>
303 set IO priority classdata (see \X'tty: link https://man7.org/linux/man-pages/man1/ionice.1.html'\fI\%ionice(1)\fP\X'tty: link' manpage)
304 .TP
305 .B \-q
306 (deprecated) alias for global \fI\-q\fP option
307 .UNINDENT
308 .TP
309 .B status [options] <path>|<device>
310 Show status of a running scrub for the filesystem identified by \fIpath\fP
311 or for the specified \fIdevice\fP\&.
312 .sp
313 If no scrub is running, show statistics of the last finished or
314 cancelled scrub for that filesystem or device.
315 .sp
316 \fBOptions\fP
317 .INDENT 7.0
318 .TP
319 .B \-d
320 print separate statistics for each device of the filesystem
321 .TP
322 .B \-R
323 print all raw statistics without postprocessing as returned by
324 the status ioctl
325 .TP
326 .B \-\-raw
327 print all numbers raw values in bytes without the \fIB\fP suffix
328 .TP
329 .B \-\-human\-readable
330 print human friendly numbers, base 1024, this is the default
331 .TP
332 .B \-\-iec
333 select the 1024 base for the following options, according to
334 the IEC standard
335 .TP
336 .B \-\-si
337 select the 1000 base for the following options, according to the SI standard
338 .TP
339 .B \-\-kbytes
340 show sizes in KiB, or kB with \-\-si
341 .TP
342 .B \-\-mbytes
343 show sizes in MiB, or MB with \-\-si
344 .TP
345 .B \-\-gbytes
346 show sizes in GiB, or GB with \-\-si
347 .TP
348 .B \-\-tbytes
349 show sizes in TiB, or TB with \-\-si
350 .UNINDENT
351 .sp
352 A status on a filesystem without any error looks like the following:
353 .INDENT 7.0
354 .INDENT 3.5
355 .sp
356 .EX
357 # btrfs scrub start /
358 # btrfs scrub status /
359 UUID: 76fac721\-2294\-4f89\-a1af\-620cde7a1980
360 Scrub started: Wed Apr 10 12:34:56 2023
361 Status: running
362 Duration: 0:00:05
363 Time left: 0:00:05
364 ETA: Wed Apr 10 12:35:01 2023
365 Total to scrub: 28.32GiB
366 Bytes scrubbed: 13.76GiB (48.59%)
367 Rate: 2.75GiB/s
368 Error summary: no errors found
369 .EE
370 .UNINDENT
371 .UNINDENT
372 .sp
373 With some errors found:
374 .INDENT 7.0
375 .INDENT 3.5
376 .sp
377 .EX
378 Error summary: csum=72
379 Corrected: 2
380 Uncorrectable: 72
381 Unverified: 0
382 .EE
383 .UNINDENT
384 .UNINDENT
385 .INDENT 7.0
386 .IP \(bu 2
387 \fICorrected\fP \-\- number of bad blocks that were repaired from another copy
388 .IP \(bu 2
389 \fIUncorrectable\fP \-\- errors detected at read time but not possible to repair from other copy
390 .IP \(bu 2
391 \fIUnverified\fP \-\- transient errors, first read failed but a retry
392 succeeded, may be affected by lower layers that group or split IO requests
393 .IP \(bu 2
394 \fIError summary\fP \-\- followed by a more detailed list of errors found
395 .INDENT 2.0
396 .IP \(bu 2
397 \fIcsum\fP \-\- checksum mismatch
398 .IP \(bu 2
399 \fIsuper\fP \-\- super block errors, unless the error is fixed
400 immediately, the next commit will overwrite superblock
401 .IP \(bu 2
402 \fIverify\fP \-\- metadata block header errors
403 .IP \(bu 2
404 \fIread\fP \-\- blocks can\(aqt be read due to IO errors
405 .UNINDENT
406 .UNINDENT
407 .sp
408 It\(aqs possible to set a per\-device limit via file
409 \fBsysfs/fs/btrfs/FSID/devinfo/scrub_speed_max\fP\&. In that case
410 the limit is printed on the \fIRate:\fP line if option \fI\-d\fP is specified,
411 or without it on a single\-device filesystem. Read more about tat in
412 section about \fI\%scrub IO limiting\fP\&.
413 .INDENT 7.0
414 .INDENT 3.5
415 .sp
416 .EX
417 Rate: 989.0MiB/s (limit 1.0G/s)
418 .EE
419 .UNINDENT
420 .UNINDENT
421 .sp
422 On a multi\-device filesystem with at least one device limit the
423 overall stats cannot print the limit without \fI\-d\fP so there\(aqs a not that
424 some limits are set:
425 .INDENT 7.0
426 .INDENT 3.5
427 .sp
428 .EX
429 Rate: 36.37MiB/s (some device limits set)
430 .EE
431 .UNINDENT
432 .UNINDENT
433 .UNINDENT
434 .SH EXIT STATUS
435 .sp
436 \fBbtrfs scrub\fP returns a zero exit status if it succeeds. Non zero is
437 returned in case of failure:
438 .INDENT 0.0
439 .TP
440 .B 1
441 scrub couldn\(aqt be performed
442 .TP
443 .B 2
444 there is nothing to resume
445 .TP
446 .B 3
447 scrub found uncorrectable errors
448 .UNINDENT
449 .SH AVAILABILITY
450 .sp
451 \fBbtrfs\fP is part of btrfs\-progs. Please refer to the documentation at
452 \X'tty: link https://btrfs.readthedocs.io'\fI\%https://btrfs.readthedocs.io\fP\X'tty: link'\&.
453 .SH SEE ALSO
454 .sp
455 \fI\%mkfs.btrfs(8)\fP
456 .\" Generated by docutils manpage writer.
457 .