2c1b57
#!/bin/bash
2c1b57
#
2c1b57
# Configuration file for /etc/cron.weekly/raid-check
2c1b57
#
2c1b57
# options:
2c1b57
#	ENABLED - must be yes in order for the raid check to proceed
2c1b57
#	CHECK - can be either check or repair depending on the type of
2c1b57
#		operation the user desires.  A check operation will scan
2c1b57
#		the drives looking for bad sectors and automatically
2c1b57
#		repairing only bad sectors.  If it finds good sectors that
2c1b57
#		contain bad data (meaning that the data in a sector does
2c1b57
#		not agree with what the data from another disk indicates
2c1b57
#		the data should be, for example the parity block + the other
2c1b57
#		data blocks would cause us to think that this data block
2c1b57
#		is incorrect), then it does nothing but increments the
2c1b57
#		counter in the file /sys/block/$dev/md/mismatch_count.
2c1b57
#		This allows the sysadmin to inspect the data in the sector
2c1b57
#		and the data that would be produced by rebuilding the
2c1b57
#		sector from redundant information and pick the correct
2c1b57
#		data to keep.  The repair option does the same thing, but
2c1b57
#		when it encounters a mismatch in the data, it automatically
2c1b57
#		updates the data to be consistent.  However, since we really
2c1b57
#		don't know whether it's the parity or the data block that's
2c1b57
#		correct (or which data block in the case of raid1), it's
2c1b57
#		luck of the draw whether or not the user gets the right
2c1b57
#		data instead of the bad data.  This option is the default
2c1b57
#		option for devices not listed in either CHECK_DEVS or
2c1b57
#		REPAIR_DEVS.
2c1b57
#	CHECK_DEVS - a space delimited list of devs that the user specifically
2c1b57
#		wants to run a check operation on.
2c1b57
#	REPAIR_DEVS - a space delimited list of devs that the user
2c1b57
#		specifically wants to run a repair on.
2c1b57
#	SKIP_DEVS - a space delimited list of devs that should be skipped
2c1b57
#	NICE - Change the raid check CPU and IO priority in order to make
2c1b57
#		the system more responsive during lengthy checks.  Valid
2c1b57
#		values are high, normal, low, idle.
2c1b57
#	MAXCONCURENT - Limit the number of devices to be checked at a time.
2c1b57
#		By default all devices will be checked at the same time.
2c1b57
#
2c1b57
# Note: the raid-check script intentionaly runs last in the cron.weekly
2c1b57
# sequence.  This is so we can wait for all the resync operations to complete
2c1b57
# and then check the mismatch_count on each array without unduly delaying
2c1b57
# other weekly cron jobs.  If any arrays have a non-0 mismatch_count after
2c1b57
# the check completes, we echo a warning to stdout which will then me emailed
2c1b57
# to the admin as long as mails from cron jobs have not been redirected to
2c1b57
# /dev/null.  We do not wait for repair operations to complete as the
2c1b57
# md stack will correct any mismatch_cnts automatically.
2c1b57
#
2c1b57
# Note2: you can not use symbolic names for the raid devices, such as you
2c1b57
# /dev/md/root.  The names used in this file must match the names seen in
2c1b57
# /proc/mdstat and in /sys/block.
2c1b57
2c1b57
ENABLED=yes
2c1b57
CHECK=check
2c1b57
NICE=low
2c1b57
# To check devs /dev/md0 and /dev/md3, use "md0 md3"
2c1b57
CHECK_DEVS=""
2c1b57
REPAIR_DEVS=""
2c1b57
SKIP_DEVS=""
2c1b57
MAXCONCURRENT=