1BTRFS-SCRUB(8) BTRFS BTRFS-SCRUB(8)
2
3
4
6 btrfs-scrub - scrub btrfs filesystem, verify block checksums
7
9 btrfs scrub <subcommand> <args>
10
12 Scrub is a pass over all filesystem data and metadata and verifying the
13 checksums. If a valid copy is available (replicated block group pro‐
14 files) then the damaged one is repaired. All copies of the replicated
15 profiles are validated.
16
17 NOTE:
18 Scrub is not a filesystem checker (fsck) and does not verify nor re‐
19 pair structural damage in the filesystem. It really only checks
20 checksums of data and tree blocks, it doesn't ensure the content of
21 tree blocks is valid and consistent. There's some validation per‐
22 formed when metadata blocks are read from disk but it's not exten‐
23 sive and cannot substitute full btrfs check run.
24
25 The user is supposed to run it manually or via a periodic system ser‐
26 vice. The recommended period is a month but could be less. The esti‐
27 mated device bandwidth utilization is about 80% on an idle filesystem.
28 The IO priority class is by default idle so background scrub should not
29 significantly interfere with normal filesystem operation. The IO sched‐
30 uler set for the device(s) might not support the priority classes
31 though.
32
33 The scrubbing status is recorded in /var/lib/btrfs/ in textual files
34 named scrub.status.UUID for a filesystem identified by the given UUID.
35 (Progress state is communicated through a named pipe in file
36 scrub.progress.UUID in the same directory.) The status file is updated
37 every 5 seconds. A resumed scrub will continue from the last saved po‐
38 sition.
39
40 Scrub can be started only on a mounted filesystem, though it's possible
41 to scrub only a selected device. See btrfs scrub start for more.
42
44 cancel <path>|<device>
45 If a scrub is running on the filesystem identified by path or
46 device, cancel it.
47
48 If a device is specified, the corresponding filesystem is found
49 and btrfs scrub cancel behaves as if it was called on that
50 filesystem. The progress is saved in the status file so btrfs
51 scrub resume can continue from the last position.
52
53 resume [-BdqrR] <path>|<device>
54 Resume a cancelled or interrupted scrub on the filesystem iden‐
55 tified by path or on a given device. The starting point is read
56 from the status file if it exists.
57
58 This does not start a new scrub if the last scrub finished suc‐
59 cessfully.
60
61 Options
62
63 see scrub start.
64
65 start [-BdrRf] <path>|<device>
66 Start a scrub on all devices of the mounted filesystem identi‐
67 fied by path or on a single device. If a scrub is already run‐
68 ning, the new one will not start. A device of an unmounted
69 filesystem cannot be scrubbed this way.
70
71 Without options, scrub is started as a background process. The
72 automatic repairs of damaged copies are performed by default for
73 block group profiles with redundancy. No-repair can be enabled
74 by option -r.
75
76 Options
77
78 -B do not background and print scrub statistics when fin‐
79 ished
80
81 -d print separate statistics for each device of the filesys‐
82 tem (-B only) at the end
83
84 -r run in read-only mode, do not attempt to correct any‐
85 thing, can be run on a read-only filesystem
86
87 -R raw print mode, print full data instead of summary
88
89 -f force starting new scrub even if a scrub is already run‐
90 ning, this can useful when scrub status file is damaged
91 and reports a running scrub although it is not, but
92 should not normally be necessary
93
94 Deprecated options
95
96 -c <ioprio_class>
97 set IO priority class (see ionice(1) manpage) if the IO
98 scheduler configured for the device supports ionice. This
99 is not supported byg BFQ or Kyber but is not supported by
100 mq-deadline.
101
102 -n <ioprio_classdata>
103 set IO priority classdata (see ionice(1) manpage)
104
105 -q (deprecated) alias for global -q option
106
107 status [options] <path>|<device>
108 Show status of a running scrub for the filesystem identified
109 by path or for the specified device.
110
111 If no scrub is running, show statistics of the last finished
112 or cancelled scrub for that filesystem or device.
113
114 Options
115
116 -d print separate statistics for each device of the
117 filesystem
118
119 -R print all raw statistics without postprocessing as re‐
120 turned by the status ioctl
121
122 --raw print all numbers raw values in bytes without the B
123 suffix
124
125 --human-readable
126 print human friendly numbers, base 1024, this is the
127 default
128
129 --iec select the 1024 base for the following options, ac‐
130 cording to the IEC standard
131
132 --si select the 1000 base for the following options, ac‐
133 cording to the SI standard
134
135 --kbytes
136 show sizes in KiB, or kB with --si
137
138 --mbytes
139 show sizes in MiB, or MB with --si
140
141 --gbytes
142 show sizes in GiB, or GB with --si
143
144 --tbytes
145 show sizes in TiB, or TB with --si
146
147 A status on a filesystem without any error looks like the
148 following:
149
150 # btrfs scrub start /
151 # btrfs scrub status /
152 UUID: 76fac721-2294-4f89-a1af-620cde7a1980
153 Scrub started: Wed Apr 10 12:34:56 2023
154 Status: running
155 Duration: 0:00:05
156 Time left: 0:00:05
157 ETA: Wed Apr 10 12:35:01 2023
158 Total to scrub: 28.32GiB
159 Bytes scrubbed: 13.76GiB (48.59%)
160 Rate: 2.75GiB/s
161 Error summary: no errors found
162
163 With some errors found:
164
165 Error summary: csum=72
166 Corrected: 2
167 Uncorrectable: 72
168 Unverified: 0
169
170 • Corrected -- number of bad blocks that were repaired from an‐
171 other copy
172
173 • Uncorrectable -- errors detected at read time but not possible
174 to repair from other copy
175
176 • Unverified -- transient errors, first read failed but a retry
177 succeeded, may be affected by lower layers that group or split
178 IO requests
179
180 • Error summary -- followed by a more detailed list of errors
181 found
182
183 • csum -- checksum mismatch
184
185 • super -- super block errors, unless the error is fixed imme‐
186 diately, the next commit will overwrite superblock
187
188 • verify -- metadata block header errors
189
190 • read -- blocks can't be read due to IO errors
191
193 btrfs scrub returns a zero exit status if it succeeds. Non zero is re‐
194 turned in case of failure:
195
196 1 scrub couldn't be performed
197
198 2 there is nothing to resume
199
200 3 scrub found uncorrectable errors
201
203 btrfs is part of btrfs-progs. Please refer to the documentation at
204 https://btrfs.readthedocs.io.
205
207 mkfs.btrfs(8)
208
209
210
211
2126.6.2 Nov 24, 2023 BTRFS-SCRUB(8)