Allow -c arg override in badblocks run

This commit is contained in:
kyounger
2022-05-30 09:12:40 -05:00
parent 66c5bb6d52
commit 52a934b5f8
2 changed files with 19 additions and 7 deletions
+4 -2
View File
@@ -25,7 +25,7 @@ The script calls `sleep` after starting each SMART test, using a duration based
Full SMART information is pulled after each SMART test. All output except for the `sleep` command is echoed to both the screen and log file. Full SMART information is pulled after each SMART test. All output except for the `sleep` command is echoed to both the screen and log file.
You should periodically monitor the burn-in progress and check for errors, particularly any errors reported by `badblocks`, or these SMART errors: You should periodically monitor the burn-in progress and check for errors, particularly any errors reported by `badblocks`, or these SMART errors:
|ID|Attribute Name| |ID|Attribute Name|
|---:|---| |---:|---|
| 5|Reallocated_Sector_Ct| | 5|Reallocated_Sector_Ct|
@@ -43,6 +43,7 @@ The script extracts the drive model and serial number and creates a log filename
* `-b 8192` : Use a block size of 8192 * `-b 8192` : Use a block size of 8192
* `-e 1` : Abort the `badblocks` test immediately if an error is found (override this setting with the `-x` option below) * `-e 1` : Abort the `badblocks` test immediately if an error is found (override this setting with the `-x` option below)
* `-c 64` : Number of concurrent blocks to check. (override this setting with the `-c` option below, but beware of memory use with high values)
* `-v` : Verbose mode * `-v` : Verbose mode
* `-o` : Write list of bad blocks found (if any) to a file named `burnin-[model]_[serial number].bb` * `-o` : Write list of bad blocks found (if any) to a file named `burnin-[model]_[serial number].bb`
* `-s` : Show progress * `-s` : Show progress
@@ -50,12 +51,13 @@ The script extracts the drive model and serial number and creates a log filename
## Usage ## Usage
`./disk-burnin.sh [-h] [-e] [-f] [-o <directory>] [-x] <disk>` `./disk-burnin.sh [-h] [-e] [-c <num_blocks>] [-f] [-o <directory>] [-x] <disk>`
### Options ### Options
* `-h`: show help text * `-h`: show help text
* `-e`: show extended help text * `-e`: show extended help text
* `-c`: number of concurrent blocks to check (default: 64). Higher values will use more memory.
* `-f`: run a full, destructive test. Disables the default 'dry-run mode'. **ALL DATA ON THE DISK WILL BE LOST!** * `-f`: run a full, destructive test. Disables the default 'dry-run mode'. **ALL DATA ON THE DISK WILL BE LOST!**
* `-o <directory>`: write log files to `<directory>` (default: working directory `$(pwd)`) * `-o <directory>`: write log files to `<directory>` (default: working directory `$(pwd)`)
* `-x`: perform a full pass of `badblocks`, using the `-e 0` option. * `-x`: perform a full pass of `badblocks`, using the `-e 0` option.
+15 -5
View File
@@ -29,7 +29,7 @@ readonly USAGE=\
$(basename "$0") -- disk burn-in program $(basename "$0") -- disk burn-in program
SYNOPSIS SYNOPSIS
$(basename "$0") [-h] [-e] [-f] [-o <directory>] [-x] <disk> $(basename "$0") [-h] [-c <num_blocks>] [-e] [-f] [-o <directory>] [-x] <disk>
DESCRIPTION DESCRIPTION
A script to simplify the process of burning-in disks. Only intended for use A script to simplify the process of burning-in disks. Only intended for use
@@ -46,6 +46,7 @@ DESCRIPTION
OPTIONS OPTIONS
-h Show help text -h Show help text
-e Show extended help text -e Show extended help text
-c <num_blocks> Override concurrent number of blocks tested
-f Force script to run in destructive mode -f Force script to run in destructive mode
ALL DATA ON THE DISK WILL BE LOST! ALL DATA ON THE DISK WILL BE LOST!
-o <directory> Write log files to <directory> (default: $(pwd)) -o <directory> Write log files to <directory> (default: $(pwd))
@@ -218,13 +219,19 @@ VERSIONS
Changed disk type detection so that we assume all drives are mechanical drives Changed disk type detection so that we assume all drives are mechanical drives
unless they explicitly return 'Solid State Drive' for Rotational Rate. unless they explicitly return 'Solid State Drive' for Rotational Rate.
Removed datestamp from every line of log output, only emitting it in log headers. Removed datestamp from every line of log output, only emitting it in log headers.
Minor reformatting." Minor reformatting.
KY, 30 May 2022
Added -c option to control the badblocks -c option."
# badblocks default -e option is 1, stop testing if a single error occurs # badblocks default -e option is 1, stop testing if a single error occurs
BB_E_ARG=1 BB_E_ARG=1
# badblocks default -c option is 64, and this allows overriding
BB_C_ARG=64
# parse options # parse options
while getopts ':hefo:x' option; do while getopts ':hefo:c:x' option; do
case "${option}" in case "${option}" in
h) echo "${USAGE}" h) echo "${USAGE}"
exit exit
@@ -237,7 +244,9 @@ while getopts ':hefo:x' option; do
;; ;;
o) LOG_DIR="${OPTARG}" o) LOG_DIR="${OPTARG}"
;; ;;
x) BB_E_ARG=0 c) BB_C_ARG="${OPTARG}"
;;
x) BB_E_ARG=0
;; ;;
:) printf 'Missing argument for -%s\n' "${OPTARG}" >&2 :) printf 'Missing argument for -%s\n' "${OPTARG}" >&2
echo "${USAGE}" >&2 echo "${USAGE}" >&2
@@ -262,6 +271,7 @@ fi
################################################################################ ################################################################################
readonly BB_E_ARG readonly BB_E_ARG
readonly BB_C_ARG
# Drive to burn-in # Drive to burn-in
DRIVE="$1" DRIVE="$1"
@@ -559,7 +569,7 @@ run_smart_test() {
run_badblocks_test() { run_badblocks_test() {
log_header "Running badblocks test" log_header "Running badblocks test"
if [ "${DISK_TYPE}" != "SSD" ]; then if [ "${DISK_TYPE}" != "SSD" ]; then
dry_run_wrapper "badblocks -b 8192 -wsv -e ${BB_E_ARG} -o \"${BB_File}\" \"${DRIVE}\"" dry_run_wrapper "badblocks -b 8192 -wsv -c ${BB_C_ARG} -e ${BB_E_ARG} -o \"${BB_File}\" \"${DRIVE}\""
else else
log_info "SKIPPED: badblocks for ${DISK_TYPE} device" log_info "SKIPPED: badblocks for ${DISK_TYPE} device"
fi fi