ZFS Scrub
What Is a ZFS Scrub?
A ZFS scrub reads data in a storage pool and verifies each block against its stored checksum to identify corruption. When valid redundant data is available from a mirror, RAIDZ, dRAID, or another supported redundant copy, ZFS can use that redundancy to repair damaged data discovered during the scrub.
Scrubs are particularly valuable for finding latent errors in blocks that may not have been read during normal system activity for an extended period.
How Does a ZFS Scrub Work?
ZFS protects blocks with checksums. During a scrub, the pool is systematically examined so stored blocks can be verified instead of waiting for normal applications to eventually read them.
Scan the Pool
ZFS identifies the allocated data that needs to be examined during the scrub operation.
Read the Blocks
Stored data is read from the pool so ZFS can validate its integrity.
Verify Checksums
ZFS compares the data that was read with the checksum associated with the block.
Repair When Possible
If corruption is detected and a valid redundant copy can be reconstructed, ZFS can repair the damaged data.
ZFS Scrubbing Relies on End-to-End Checksums
ZFS calculates checksums when blocks are written and stores checksum information so data can later be verified. When data is read during a scrub, ZFS can determine whether the returned data matches what was originally expected.
Finding Latent Data Corruption
Some stored blocks may go months or years without being accessed. Without periodically reading those blocks, latent media problems may remain undiscovered.
Can a ZFS Scrub Repair Corrupted Data?
Yes — when ZFS has sufficient valid redundancy. If a block fails checksum verification and another valid copy or parity reconstruction is available, ZFS can use the correct data and repair the damaged copy.
This is one of the major advantages of combining ZFS checksums with redundant storage. ZFS does not merely know that a block is wrong; in a properly redundant pool, it can often determine which version is valid and repair the damaged data.
ZFS Scrub vs Resilver
Scrubbing and resilvering both read storage and perform integrity-related work, but they serve different purposes.
| Characteristic | ZFS Scrub | ZFS Resilver |
|---|---|---|
| Primary Purpose | Verify pool data integrity | Restore data known to be missing or out of date |
| Typical Trigger | Scheduled or manually initiated maintenance | Device replacement, attachment or return to service |
| Scope | Examines pool data for integrity errors | Examines data ZFS knows requires reconstruction |
| Checksum Verification | Core purpose of a normal scrub | Depends on reconstruction method |
| I/O Intensive | Yes | Yes |
| Run Simultaneously? | No — scrub and resilver do not run concurrently | No — resilver takes precedence |
Common ZFS Scrub Commands
OpenZFS provides commands for starting, monitoring, pausing and stopping a pool scrub.
zpool scrub poolnamezpool status poolnamezpool scrub -p poolnamezpool scrub -s poolnameHow to Check ZFS Scrub Status
The zpool status command reports scrub progress while the operation is running and summarizes the results after it completes.
READ, WRITE & CKSUM Errors
ZFS reports several types of device errors through zpool status. These counters provide useful clues when investigating storage hardware and data-integrity problems.
How Often Should You Scrub a ZFS Pool?
There is no single scrub interval that is ideal for every ZFS system. The appropriate schedule depends on storage media, workload, pool size, hardware reliability, operational load and how quickly administrators want latent errors to be discovered.
Regular periodic scrubbing is generally preferable to leaving rarely accessed data unchecked indefinitely. Administrators should choose a schedule that provides useful integrity verification without creating unnecessary workload during important production periods.
Does a ZFS Scrub Affect Performance?
A scrub generates substantial storage I/O because ZFS must read allocated data throughout the pool. Depending on the storage hardware and workload, this additional activity can compete with normal application I/O.
Administrators of performance-sensitive systems may therefore schedule scrubs during periods of lower activity and monitor application latency while the scrub is running.
Scrubbing Works With Your ZFS Redundancy
Scrubbing can detect corruption regardless of whether the pool is redundant. Automatic repair, however, depends on ZFS having valid redundant information available.
A ZFS Scrub Is Not a Backup
Scrubbing verifies the integrity of data already stored in the pool. It does not create an independent historical copy of that data and therefore does not replace a backup strategy.
A scrub cannot independently recover a file that was legitimately deleted, overwritten or changed before the scrub began. Important data should still be protected with backups appropriate for the required recovery objectives.
ZFS Scrub FAQ
What does a ZFS scrub do?
A scrub examines data in the ZFS pool and verifies block checksums to detect corruption.
Does a ZFS scrub repair errors?
ZFS can automatically repair damaged data discovered during a scrub when sufficient valid redundancy is available.
What command starts a ZFS scrub?
Use zpool scrub poolname, replacing poolname with the name of the storage pool.
How do I check scrub progress?
Use zpool status. The scan section reports scrub progress and results.
Can I pause a ZFS scrub?
Yes. OpenZFS supports pausing a scrub with zpool scrub -p poolname.
Can a scrub and resilver run at the same time?
No. Both operations are I/O intensive and OpenZFS allows only one scrub or resilver operation at a time.
Does scrubbing slow down a ZFS pool?
It can. A scrub generates substantial read activity and may compete with normal workloads for storage resources.
Can ZFS detect corruption without redundancy?
Yes. Checksums can identify corrupted data, but without another valid copy or suitable redundancy ZFS may not be able to repair it.
Is a ZFS scrub the same as a backup?
No. Scrubbing validates stored data integrity. It does not create an independent recoverable copy of the data.
