xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-scrub.8 (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or https://opensource.org/licenses/CDDL-1.0.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
23.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
25.\" Copyright (c) 2017 Datto Inc.
26.\" Copyright (c) 2018, 2021 George Melikov. All Rights Reserved.
27.\" Copyright 2017 Nexenta Systems, Inc.
28.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29.\"
30.Dd November 18, 2024
31.Dt ZPOOL-SCRUB 8
32.Os
33.
34.Sh NAME
35.Nm zpool-scrub
36.Nd begin or resume scrub of ZFS storage pools
37.Sh SYNOPSIS
38.Nm zpool
39.Cm scrub
40.Op Ns Fl e | Ns Fl p | Fl s Ns | Fl C Ns
41.Op Fl w
42.Ar pool Ns …
43.
44.Sh DESCRIPTION
45Begins a scrub or resumes a paused scrub.
46The scrub examines all data in the specified pools to verify that it checksums
47correctly.
48For replicated
49.Pq mirror, raidz, or draid
50devices, ZFS automatically repairs any damage discovered during the scrub.
51The
52.Nm zpool Cm status
53command reports the progress of the scrub and summarizes the results of the
54scrub upon completion.
55.Pp
56Scrubbing and resilvering are very similar operations.
57The difference is that resilvering only examines data that ZFS knows to be out
58of date
59.Po
60for example, when attaching a new device to a mirror or replacing an existing
61device
62.Pc ,
63whereas scrubbing examines all data to discover silent errors due to hardware
64faults or disk failure.
65.Pp
66When scrubbing a pool with encrypted filesystems the keys do not need to be
67loaded.
68However, if the keys are not loaded and an unrepairable checksum error is
69detected the file name cannot be included in the
70.Nm zpool Cm status Fl v
71verbose error report.
72.Pp
73Because scrubbing and resilvering are I/O-intensive operations, ZFS only allows
74one at a time.
75.Pp
76A scrub is split into two parts: metadata scanning and block scrubbing.
77The metadata scanning sorts blocks into large sequential ranges which can then
78be read much more efficiently from disk when issuing the scrub I/O.
79.Pp
80If a scrub is paused, the
81.Nm zpool Cm scrub
82resumes it.
83If a resilver is in progress, ZFS does not allow a scrub to be started until the
84resilver completes.
85.Pp
86Note that, due to changes in pool data on a live system, it is possible for
87scrubs to progress slightly beyond 100% completion.
88During this period, no completion time estimate will be provided.
89.
90.Sh OPTIONS
91.Bl -tag -width "-s"
92.It Fl s
93Stop scrubbing.
94.It Fl p
95Pause scrubbing.
96Scrub pause state and progress are periodically synced to disk.
97If the system is restarted or pool is exported during a paused scrub,
98even after import, scrub will remain paused until it is resumed.
99Once resumed the scrub will pick up from the place where it was last
100checkpointed to disk.
101To resume a paused scrub issue
102.Nm zpool Cm scrub
103or
104.Nm zpool Cm scrub
105.Fl e
106again.
107.It Fl w
108Wait until scrub has completed before returning.
109.It Fl e
110Only scrub files with known data errors as reported by
111.Nm zpool Cm status Fl v .
112The pool must have been scrubbed at least once with the
113.Sy head_errlog
114feature enabled to use this option.
115Error scrubbing cannot be run simultaneously with regular scrubbing or
116resilvering, nor can it be run when a regular scrub is paused.
117.It Fl C
118Continue scrub from last saved txg (see zpool
119.Sy last_scrubbed_txg
120property).
121.El
122.Sh EXAMPLES
123.Ss Example 1
124Status of pool with ongoing scrub:
125.sp
126.Bd -literal -compact
127.No # Nm zpool Cm status
128  ...
129  scan: scrub in progress since Sun Jul 25 16:07:49 2021
130        403M / 405M scanned at 100M/s, 68.4M / 405M issued at 10.0M/s
131        0B repaired, 16.91% done, 00:00:04 to go
132  ...
133.Ed
134.Pp
135Where metadata which references 403M of file data has been
136scanned at 100M/s, and 68.4M of that file data has been
137scrubbed sequentially at 10.0M/s.
138.Sh PERIODIC SCRUB
139On machines using systemd, scrub timers can be enabled on per-pool basis.
140.Nm weekly
141and
142.Nm monthly
143timer units are provided.
144.Bl -tag -width Ds
145.It Xo
146.Xc
147.Nm systemctl
148.Cm enable
149.Cm zfs-scrub-\fIweekly\fB@\fIrpool\fB.timer
150.Cm --now
151.It Xo
152.Xc
153.Nm systemctl
154.Cm enable
155.Cm zfs-scrub-\fImonthly\fB@\fIotherpool\fB.timer
156.Cm --now
157.El
158.
159.Sh SEE ALSO
160.Xr systemd.timer 5 ,
161.Xr zpool-iostat 8 ,
162.Xr zpool-resilver 8 ,
163.Xr zpool-status 8
164