Skip to content

Instantly share code, notes, and snippets.

@killerbees19
Last active April 15, 2022 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerbees19/58fb9352f23f2bf0f60c017229c4b432 to your computer and use it in GitHub Desktop.
Save killerbees19/58fb9352f23f2bf0f60c017229c4b432 to your computer and use it in GitHub Desktop.
Improved scrubbing for TrueNAS

Improved SCRUB handling at TrueNAS.

Tested at TrueNAS CORE 12.0-U7, but it should be compatible with TrueNAS SCALE too.

Tunables

Not required, but recommended: vfs.zfs.scan_legacy=1

Init/Shutdown Scripts

  • Type: Script
  • Script: .../zpool-scrub-resume
  • When: Post Init

  • Type: Script
  • Script: .../zpool-scrub-pause
  • When: Shutdown

#!/bin/sh
zpool list -H -o health,name 2>&1 \
| awk -F'\t' '$1 == "ONLINE" {print $2}' \
| while read -r pool
do
zpool status "$pool" \
| grep -Fq "scrub in progress" \
&& zpool scrub -p "$pool"
done
#!/bin/sh
zpool list -H -o health,name 2>&1 \
| awk -F'\t' '$1 == "ONLINE" {print $2}' \
| while read -r pool
do
zpool status "$pool" \
| grep -Fq "scrub paused" \
&& zpool scrub "$pool"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment