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.\" Copyright (c) 2025 Hewlett Packard Enterprise Development LP. 30.\" 31.Dd December 11, 2024 32.Dt ZPOOL-SCRUB 8 33.Os 34. 35.Sh NAME 36.Nm zpool-scrub 37.Nd begin or resume scrub of ZFS storage pools 38.Sh SYNOPSIS 39.Nm zpool 40.Cm scrub 41.Op Ns Fl e | Ns Fl p | Fl s Ns | Fl C Ns 42.Op Fl w 43.Op Fl S Ar date 44.Op Fl E Ar date 45.Fl a Ns | Ns Ar pool Ns … 46. 47.Sh DESCRIPTION 48Begins a scrub or resumes a paused scrub. 49The scrub examines all data in the specified pools to verify that it checksums 50correctly. 51For replicated 52.Pq mirror, raidz, or draid 53devices, ZFS automatically repairs any damage discovered during the scrub. 54The 55.Nm zpool Cm status 56command reports the progress of the scrub and summarizes the results of the 57scrub upon completion. 58.Pp 59Scrubbing and resilvering are very similar operations. 60The difference is that resilvering only examines data that ZFS knows to be out 61of date 62.Po 63for example, when attaching a new device to a mirror or replacing an existing 64device 65.Pc , 66whereas scrubbing examines all data to discover silent errors due to hardware 67faults or disk failure. 68.Pp 69When scrubbing a pool with encrypted filesystems the keys do not need to be 70loaded. 71However, if the keys are not loaded and an unrepairable checksum error is 72detected the file name cannot be included in the 73.Nm zpool Cm status Fl v 74verbose error report. 75.Pp 76Because scrubbing and resilvering are I/O-intensive operations, ZFS only allows 77one at a time. 78.Pp 79A scrub is split into two parts: metadata scanning and block scrubbing. 80The metadata scanning sorts blocks into large sequential ranges which can then 81be read much more efficiently from disk when issuing the scrub I/O. 82.Pp 83If a scrub is paused, the 84.Nm zpool Cm scrub 85resumes it. 86If a resilver is in progress, ZFS does not allow a scrub to be started until the 87resilver completes. 88.Pp 89Note that, due to changes in pool data on a live system, it is possible for 90scrubs to progress slightly beyond 100% completion. 91During this period, no completion time estimate will be provided. 92. 93.Sh OPTIONS 94.Bl -tag -width "-s" 95.It Fl a , -all 96Begin, pause, stop scrub on 97all 98pools. 99Initiating scrubs on multiple pools can put considerable load and memory 100pressure on the system, so this operation should be performed with caution. 101.It Fl s 102Stop scrubbing. 103.It Fl p 104Pause scrubbing. 105Scrub pause state and progress are periodically synced to disk. 106If the system is restarted or pool is exported during a paused scrub, 107even after import, scrub will remain paused until it is resumed. 108Once resumed the scrub will pick up from the place where it was last 109checkpointed to disk. 110To resume a paused scrub issue 111.Nm zpool Cm scrub 112or 113.Nm zpool Cm scrub 114.Fl e 115again. 116.It Fl w 117Wait until scrub has completed before returning. 118.It Fl e 119Only scrub files with known data errors as reported by 120.Nm zpool Cm status Fl v . 121The pool must have been scrubbed at least once with the 122.Sy head_errlog 123feature enabled to use this option. 124Error scrubbing cannot be run simultaneously with regular scrubbing or 125resilvering, nor can it be run when a regular scrub is paused. 126.It Fl C 127Continue scrub from last saved txg (see zpool 128.Sy last_scrubbed_txg 129property). 130.It Fl S Ar date , Fl E Ar date 131Allows specifying the date range for blocks created between these dates. 132.Bl -bullet -compact -offset indent 133.It 134.Fl S 135Defines a start date. 136If not specified, scrubbing begins from the start of the pool's 137existence. 138.It 139.Fl E 140Defines an end date. 141If not specified, scrubbing continues up to the most recent data. 142.El 143The provided date should be in the format: 144.Dq YYYY-MM-DD HH:MM . 145Where: 146.Bl -bullet -compact -offset indent 147.It 148.Dq YYYY 149is the year. 150.It 151.Dq MM 152is the numeric representation of the month. 153.It 154.Dq DD 155is the day of the month. 156.It 157.Dq HH 158is the hour. 159.It 160.Dq MM 161is the minutes. 162.El 163The hour and minutes parameters can be omitted. 164The time should be provided in machine local time zone. 165Specifying dates prior to enabling this feature will result in scrubbing 166starting from the date the pool was created. 167If the time was moved backward manually the data range may become inaccurate. 168.El 169.Sh EXAMPLES 170.Ss Example 1 171Status of pool with ongoing scrub: 172.sp 173.Bd -literal -compact 174.No # Nm zpool Cm status 175 ... 176 scan: scrub in progress since Sun Jul 25 16:07:49 2021 177 403M / 405M scanned at 100M/s, 68.4M / 405M issued at 10.0M/s 178 0B repaired, 16.91% done, 00:00:04 to go 179 ... 180.Ed 181.Pp 182Where metadata which references 403M of file data has been 183scanned at 100M/s, and 68.4M of that file data has been 184scrubbed sequentially at 10.0M/s. 185.Sh PERIODIC SCRUB 186On machines using systemd, scrub timers can be enabled on per-pool basis. 187.Nm weekly 188and 189.Nm monthly 190timer units are provided. 191.Bl -tag -width Ds 192.It Xo 193.Xc 194.Nm systemctl 195.Cm enable 196.Cm zfs-scrub-\fIweekly\fB@\fIrpool\fB.timer 197.Cm --now 198.It Xo 199.Xc 200.Nm systemctl 201.Cm enable 202.Cm zfs-scrub-\fImonthly\fB@\fIotherpool\fB.timer 203.Cm --now 204.El 205. 206.Sh SEE ALSO 207.Xr systemd.timer 5 , 208.Xr zpool-iostat 8 , 209.Xr zpool-resilver 8 , 210.Xr zpool-status 8 211