xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-scrub.8 (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1*61145dc2SMartin Matuska.\" SPDX-License-Identifier: CDDL-1.0
2eda14cbcSMatt Macy.\"
3eda14cbcSMatt Macy.\" CDDL HEADER START
4eda14cbcSMatt Macy.\"
5eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the
6eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License").
7eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License.
8eda14cbcSMatt Macy.\"
9eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0.
11eda14cbcSMatt Macy.\" See the License for the specific language governing permissions
12eda14cbcSMatt Macy.\" and limitations under the License.
13eda14cbcSMatt Macy.\"
14eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each
15eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the
17eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying
18eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner]
19eda14cbcSMatt Macy.\"
20eda14cbcSMatt Macy.\" CDDL HEADER END
21eda14cbcSMatt Macy.\"
22eda14cbcSMatt Macy.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
23eda14cbcSMatt Macy.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24eda14cbcSMatt Macy.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
25eda14cbcSMatt Macy.\" Copyright (c) 2017 Datto Inc.
261f88aa09SMartin Matuska.\" Copyright (c) 2018, 2021 George Melikov. All Rights Reserved.
27eda14cbcSMatt Macy.\" Copyright 2017 Nexenta Systems, Inc.
28eda14cbcSMatt Macy.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29eda14cbcSMatt Macy.\"
3017aab35aSMartin Matuska.Dd November 18, 2024
31eda14cbcSMatt Macy.Dt ZPOOL-SCRUB 8
32eda14cbcSMatt Macy.Os
3316038816SMartin Matuska.
34eda14cbcSMatt Macy.Sh NAME
357877fdebSMatt Macy.Nm zpool-scrub
3616038816SMartin Matuska.Nd begin or resume scrub of ZFS storage pools
37eda14cbcSMatt Macy.Sh SYNOPSIS
387877fdebSMatt Macy.Nm zpool
39eda14cbcSMatt Macy.Cm scrub
4017aab35aSMartin Matuska.Op Ns Fl e | Ns Fl p | Fl s Ns | Fl C Ns
41eda14cbcSMatt Macy.Op Fl w
4216038816SMartin Matuska.Ar pool Ns …
4316038816SMartin Matuska.
44eda14cbcSMatt Macy.Sh DESCRIPTION
45eda14cbcSMatt MacyBegins a scrub or resumes a paused scrub.
46eda14cbcSMatt MacyThe scrub examines all data in the specified pools to verify that it checksums
47eda14cbcSMatt Macycorrectly.
48eda14cbcSMatt MacyFor replicated
497877fdebSMatt Macy.Pq mirror, raidz, or draid
50eda14cbcSMatt Macydevices, ZFS automatically repairs any damage discovered during the scrub.
51eda14cbcSMatt MacyThe
52eda14cbcSMatt Macy.Nm zpool Cm status
53eda14cbcSMatt Macycommand reports the progress of the scrub and summarizes the results of the
54eda14cbcSMatt Macyscrub upon completion.
55eda14cbcSMatt Macy.Pp
56eda14cbcSMatt MacyScrubbing and resilvering are very similar operations.
57eda14cbcSMatt MacyThe difference is that resilvering only examines data that ZFS knows to be out
58eda14cbcSMatt Macyof date
59eda14cbcSMatt Macy.Po
60eda14cbcSMatt Macyfor example, when attaching a new device to a mirror or replacing an existing
61eda14cbcSMatt Macydevice
62eda14cbcSMatt Macy.Pc ,
63eda14cbcSMatt Macywhereas scrubbing examines all data to discover silent errors due to hardware
64eda14cbcSMatt Macyfaults or disk failure.
65eda14cbcSMatt Macy.Pp
66c0a83fe0SMartin MatuskaWhen scrubbing a pool with encrypted filesystems the keys do not need to be
67c0a83fe0SMartin Matuskaloaded.
68c0a83fe0SMartin MatuskaHowever, if the keys are not loaded and an unrepairable checksum error is
69c0a83fe0SMartin Matuskadetected the file name cannot be included in the
70c0a83fe0SMartin Matuska.Nm zpool Cm status Fl v
71c0a83fe0SMartin Matuskaverbose error report.
72c0a83fe0SMartin Matuska.Pp
73eda14cbcSMatt MacyBecause scrubbing and resilvering are I/O-intensive operations, ZFS only allows
74eda14cbcSMatt Macyone at a time.
751f88aa09SMartin Matuska.Pp
761f88aa09SMartin MatuskaA scrub is split into two parts: metadata scanning and block scrubbing.
771f88aa09SMartin MatuskaThe metadata scanning sorts blocks into large sequential ranges which can then
781f88aa09SMartin Matuskabe read much more efficiently from disk when issuing the scrub I/O.
791f88aa09SMartin Matuska.Pp
80eda14cbcSMatt MacyIf a scrub is paused, the
81eda14cbcSMatt Macy.Nm zpool Cm scrub
82eda14cbcSMatt Macyresumes it.
83eda14cbcSMatt MacyIf a resilver is in progress, ZFS does not allow a scrub to be started until the
84eda14cbcSMatt Macyresilver completes.
85eda14cbcSMatt Macy.Pp
86eda14cbcSMatt MacyNote that, due to changes in pool data on a live system, it is possible for
8716038816SMartin Matuskascrubs to progress slightly beyond 100% completion.
8816038816SMartin MatuskaDuring this period, no completion time estimate will be provided.
8916038816SMartin Matuska.
9016038816SMartin Matuska.Sh OPTIONS
9116038816SMartin Matuska.Bl -tag -width "-s"
92eda14cbcSMatt Macy.It Fl s
93eda14cbcSMatt MacyStop scrubbing.
94eda14cbcSMatt Macy.It Fl p
95eda14cbcSMatt MacyPause scrubbing.
96eda14cbcSMatt MacyScrub pause state and progress are periodically synced to disk.
97eda14cbcSMatt MacyIf the system is restarted or pool is exported during a paused scrub,
98eda14cbcSMatt Macyeven after import, scrub will remain paused until it is resumed.
99eda14cbcSMatt MacyOnce resumed the scrub will pick up from the place where it was last
100eda14cbcSMatt Macycheckpointed to disk.
101eda14cbcSMatt MacyTo resume a paused scrub issue
102eda14cbcSMatt Macy.Nm zpool Cm scrub
103c0a83fe0SMartin Matuskaor
104c0a83fe0SMartin Matuska.Nm zpool Cm scrub
105c0a83fe0SMartin Matuska.Fl e
106eda14cbcSMatt Macyagain.
107eda14cbcSMatt Macy.It Fl w
108eda14cbcSMatt MacyWait until scrub has completed before returning.
109c0a83fe0SMartin Matuska.It Fl e
110c0a83fe0SMartin MatuskaOnly scrub files with known data errors as reported by
111c0a83fe0SMartin Matuska.Nm zpool Cm status Fl v .
112c0a83fe0SMartin MatuskaThe pool must have been scrubbed at least once with the
113c0a83fe0SMartin Matuska.Sy head_errlog
114c0a83fe0SMartin Matuskafeature enabled to use this option.
115c0a83fe0SMartin MatuskaError scrubbing cannot be run simultaneously with regular scrubbing or
116c0a83fe0SMartin Matuskaresilvering, nor can it be run when a regular scrub is paused.
11717aab35aSMartin Matuska.It Fl C
11817aab35aSMartin MatuskaContinue scrub from last saved txg (see zpool
11917aab35aSMartin Matuska.Sy last_scrubbed_txg
12017aab35aSMartin Matuskaproperty).
121eda14cbcSMatt Macy.El
1221f88aa09SMartin Matuska.Sh EXAMPLES
123bb2d13b6SMartin Matuska.Ss Example 1
124bb2d13b6SMartin MatuskaStatus of pool with ongoing scrub:
125bb2d13b6SMartin Matuska.sp
126da5137abSMartin Matuska.Bd -literal -compact
1271f88aa09SMartin Matuska.No # Nm zpool Cm status
1281f88aa09SMartin Matuska  ...
1291f88aa09SMartin Matuska  scan: scrub in progress since Sun Jul 25 16:07:49 2021
1300a97523dSMartin Matuska        403M / 405M scanned at 100M/s, 68.4M / 405M issued at 10.0M/s
1311f88aa09SMartin Matuska        0B repaired, 16.91% done, 00:00:04 to go
1321f88aa09SMartin Matuska  ...
1331f88aa09SMartin Matuska.Ed
134da5137abSMartin Matuska.Pp
135da5137abSMartin MatuskaWhere metadata which references 403M of file data has been
1361f88aa09SMartin Matuskascanned at 100M/s, and 68.4M of that file data has been
1371f88aa09SMartin Matuskascrubbed sequentially at 10.0M/s.
138e92ffd9bSMartin Matuska.Sh PERIODIC SCRUB
139e92ffd9bSMartin MatuskaOn machines using systemd, scrub timers can be enabled on per-pool basis.
140e92ffd9bSMartin Matuska.Nm weekly
141e92ffd9bSMartin Matuskaand
142e92ffd9bSMartin Matuska.Nm monthly
143e92ffd9bSMartin Matuskatimer units are provided.
144e92ffd9bSMartin Matuska.Bl -tag -width Ds
145e92ffd9bSMartin Matuska.It Xo
146e92ffd9bSMartin Matuska.Xc
147e92ffd9bSMartin Matuska.Nm systemctl
148e92ffd9bSMartin Matuska.Cm enable
149e92ffd9bSMartin Matuska.Cm zfs-scrub-\fIweekly\fB@\fIrpool\fB.timer
150e92ffd9bSMartin Matuska.Cm --now
151e92ffd9bSMartin Matuska.It Xo
152e92ffd9bSMartin Matuska.Xc
153e92ffd9bSMartin Matuska.Nm systemctl
154e92ffd9bSMartin Matuska.Cm enable
155e92ffd9bSMartin Matuska.Cm zfs-scrub-\fImonthly\fB@\fIotherpool\fB.timer
156e92ffd9bSMartin Matuska.Cm --now
157e92ffd9bSMartin Matuska.El
15816038816SMartin Matuska.
159eda14cbcSMatt Macy.Sh SEE ALSO
160e92ffd9bSMartin Matuska.Xr systemd.timer 5 ,
161eda14cbcSMatt Macy.Xr zpool-iostat 8 ,
162eda14cbcSMatt Macy.Xr zpool-resilver 8 ,
163eda14cbcSMatt Macy.Xr zpool-status 8
164