ZFS Scrubbing

Posted on Mon 01 May 2017 in zfs

A simple way to check the data integrity of a ZFS pool is by scrubbing the data. This process goes through all of the data and ensures it can be read.

To start a scrub you can run the command:

$ zpool scrub <pool>

If you would like to stop a scrub that is currently in progress (if you are doing some other heavy i/o work for instance) run the following command:

$ zpool scrub -s <pool>

Schedule scrub once per week

Scrubbing should happen at least once a week. Here are a couple ways to easily schedule a scrub.

Set up a cronjob to run a scrub once a week:

$ crontab -e
------------
...
30 19 * * 5 zpool scrub <pool>
...

Alternativly use systemd-zpool-scrub from the AUR if you are on Arch Linux Once installed it will create a service file that will run a scrub weekly, all you need to do is enable the service.

$ systemctl enable zpool-scrub@<pool>.timer  
$ systemctl start zpool-scrub@<pool>.timer 

zfs