diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4f3a25 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/disk-burnin.sh b/disk-burnin.sh index 768056f..7792f11 100644 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -18,10 +18,10 @@ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # 2> Run times for large disks can take several days to complete, so it -# is a good idea to use tmux sessions to prevent mishaps. +# is a good idea to use tmux sessions to prevent mishaps. # # 3> Must be run as 'root'. -# +# # 4> Tests of large drives can take days to complete: use tmux! # # Performs these steps: @@ -30,7 +30,7 @@ # 2> Run badblocks # 3> Run SMART extended test # -# The script sleeps after starting each SMART test, using a duration +# The script sleeps after starting each SMART test, using a duration # based on the polling interval reported by the disk, after which the # script will poll the disk to verify the self-test has completed. # @@ -40,10 +40,10 @@ # You should monitor the burn-in progress and watch for errors, particularly # any errors reported by badblocks, or these SMART errors: # -# 5 Reallocated_Sector_Ct -# 196 Reallocated_Event_Count -# 197 Current_Pending_Sector -# 198 Offline_Uncorrectable +# 5 Reallocated_Sector_Ct +# 196 Reallocated_Event_Count +# 197 Current_Pending_Sector +# 198 Offline_Uncorrectable # # These indicate possible problems with the drive. You therefore may # wish to abort the remaining tests and proceed with an RMA exchange @@ -55,28 +55,28 @@ # # badblocks is invoked with a block size of 4096, the -wsv options, and # the -o option to instruct it to write the list of bad blocks found (if -# any) to a file named 'burnin-[model]_[serial number].bb'. -# +# any) to a file named 'burnin-[model]_[serial number].bb'. +# # The only required command-line argument is the device specifier, e.g.: # -# ./disk-burnin.sh sda +# ./disk-burnin.sh sda # # ...will run the burn-in test on device /dev/sda # # You can run the script in 'dry run mode' (see below) to check the sleep # duration calculations and to insure that the sequence of commands suits -# your needs. In 'dry runs' the script does not actually perform any +# your needs. In 'dry runs' the script does not actually perform any # SMART tests or invoke the sleep or badblocks programs. The script is # distributed with 'dry runs' enabled, so you will need to edit the # Dry_Run variable below, setting it to 0, in order to actually perform # tests on drives. -# +# # Before using the script on FreeBSD systems (including FreeNAS) you must # first execute this sysctl command to alter the kernel's geometry debug # flags. This allows badblocks to write to the entire disk: # # sysctl kern.geom.debugflags=0x10 -# +# # Tested under: # FreeNAS 9.10.2 (FreeBSD 10.3-STABLE) # Ubuntu Server 16.04.2 LTS @@ -94,7 +94,7 @@ # Uses: grep, pcregrep, awk, sed, tr, sleep, badblocks # # Written by Keith Nash, March 2017 -# +# # KN, 8 Apr 2017: # Added minimum test durations because some devices don't return accurate values. # Added code to clean up the log file, removing copyright notices, etc. @@ -102,16 +102,16 @@ # Emit test results after tests instead of full 'smartctl -a' output. # Emit full 'smartctl -x' output at the end of all testing. # Minor changes to log output and formatting. -# +# # KN, 12 May 2017: # Added code to poll the disk and check for completed self-tests. -# +# # As noted above, some disks don't report accurate values for the short and extended -# self-test intervals, sometimes by a significant amount. The original approach using +# self-test intervals, sometimes by a significant amount. The original approach using # 'fudge' factors wasn't reliable and the script would finish even though the SMART # self-tests had not completed. The new polling code helps insure that this doesn't # happen. -# +# # Fixed code to work around annoying differences between sed's behavior on Linux and # FreeBSD. # @@ -128,7 +128,7 @@ # 1> Short SMART test # 2> badblocks # 3> Extended SMART test -# +# ######################################################################## if [ $# -ne 1 ]; then @@ -144,7 +144,7 @@ Drive=$1 Dry_Run=0 -# Directory specifiers for log and badblocks data files. Leave off the +# Directory specifiers for log and badblocks data files. Leave off the # trailing slash if you specify a value. Default is the current working # directory. @@ -227,7 +227,7 @@ poll_selftest_complete() # Return 0 if the test has completed, 1 if we exceed our polling timeout interval while [ $l_done -eq 0 ]; - do + do smartctl -a /dev/"$Drive" | grep -i "The previous self-test routine completed" > /dev/null 2<&1 l_status=$? if [ $l_status -eq 0 ]; then @@ -235,7 +235,7 @@ poll_selftest_complete() l_rv=0 l_done=1 else - # Check for failure + # Check for failure smartctl -a /dev/"$Drive" | grep -i "of the test failed." > /dev/null 2<&1 l_status=$? if [ $l_status -eq 0 ]; then @@ -255,7 +255,7 @@ poll_selftest_complete() done return $l_rv -} +} run_short_test() { @@ -367,4 +367,3 @@ if [ "${osflavor}" = "FreeBSD" ]; then sed -i '' -e '/Vendor Specific SMART/d' "${Log_File}" sed -i '' -e '/SMART Error Log Version/d' "${Log_File}" fi - diff --git a/license.txt b/license.txt index 791fc35..dfd4a46 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,7 @@ MIT License -Copyright (c) 2017 by Keith Nash +Original work Copyright (c) 2017 by Keith Nash +Modified work Copyright (c) 2020 by Michael Schnerring Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal