mirror of
https://github.com/Spearfoot/disk-burnin-and-testing.git
synced 2025-12-10 21:33:34 +00:00
Merge pull request #8 from schnerring/master
Add dry_run_wrapper(), update docs, improve option parsing, add detection for mechanical drives
This commit is contained in:
57
README.md
57
README.md
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
Be warned that:
|
Be warned that:
|
||||||
|
|
||||||
* This script runs the `badblocks` program in destructive mode, which erases any data on the disk. Therefore, please be careful! __Do not run this script on disks containing data you value!__
|
* This script runs `badblocks` in destructive mode, which erases any data on the disk. Therefore, please be careful! __Do not run this script on disks containing valuable data!__
|
||||||
* Run times for large disks can take several days to a week or more to complete, so it is a good idea to use `tmux` sessions to prevent mishaps.
|
* Run times for large disks can be several days. Use tmux or screen to test multiple disks in parallel.
|
||||||
* Must be run as 'root', so either log on using the root account or use the `sudo` command, for example: `sudo ./disk_burnin.sh sda`
|
* Must be run as 'root'.
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
@@ -48,29 +48,41 @@ The script extracts the drive model and serial number and creates a log filename
|
|||||||
* `-s` : Show progress
|
* `-s` : Show progress
|
||||||
* `-w` : Write-mode test, writes four patterns (0xaa, 0x55, 0x44, 0x00) on every disk block
|
* `-w` : Write-mode test, writes four patterns (0xaa, 0x55, 0x44, 0x00) on every disk block
|
||||||
|
|
||||||
The only required command-line argument is the device specifier, e.g.:
|
## Usage
|
||||||
|
|
||||||
`./disk-burnin.sh sda`
|
`./disk-burnin.sh [-h] [-f] [-o <directory>] <disk>`
|
||||||
|
|
||||||
...will run the burn-in test on device /dev/sda
|
### Options
|
||||||
|
|
||||||
## Dry Run Mode
|
* `-h`: show help text
|
||||||
|
* `-e`: show extended help text
|
||||||
|
* `-f`: run in destructive, non-dry mode. **ALL DATA ON THE DISK WILL BE LOST!**
|
||||||
|
* `-o <directory>`: write log files to `<directory>` (default: working directory `$(pwd)`)
|
||||||
|
* `<disk>`: disk to burn-in (`/dev/` may be omitted)
|
||||||
|
|
||||||
The script supports a 'dry run mode' which lets you check the sleep duration calculations and insure that the sequence of commands suits your needs without actually performing any operations on disks. In 'dry runs' the script does not perform any SMART tests or invoke the `sleep` or `badblocks` programs.
|
### Examples
|
||||||
|
|
||||||
The script was formerly distributed with 'dry run mode' enabled by default, but this is no longer the case. You will have to edit the script and set the `Dry_Run` variable to a non-zero value to enable 'dry runs'.
|
* `./disk-burnin.sh sda`: run in dry-run mode on disk `/dev/sda`
|
||||||
|
* `./disk-burnin.sh -f /dev/sdb`: run in destructive, non-dry mode on disk `/dev/sdb`
|
||||||
|
* `./disk-burnin.sh -f -o ~/burn-in-logs sdc`: run in destructive, non-dry mode on disk `/dev/sdc` and write the log files to `~/burn-in-logs` directory
|
||||||
|
|
||||||
|
## Dry-Run Mode
|
||||||
|
|
||||||
|
The script runs in dry-run mode by default, so you can check the sleep durations and to insure that the sequence of commands suits your needs. In dry-run mode the script does not actually perform any SMART tests or invoke the `sleep` or `badblocks` programs.
|
||||||
|
|
||||||
|
In order to perform tests on drives, you will need to provide the `-f` option.
|
||||||
|
|
||||||
## `smartctl` Device Type
|
## `smartctl` Device Type
|
||||||
|
|
||||||
Some users with atypical hardware environments may need to modify the script and specify the `smartctl` command device type explictly with the `-d` option. User __bcmryan__ reports success using `-d sat` with a Western Digital MyBook 8TB external drive enclosure.
|
Some users with atypical hardware environments may need to modify the script and specify the `smartctl` command device type explictly with the `-d` option. User __bcmryan__ reports success using `-d sat` with a Western Digital MyBook 8TB external drive enclosure.
|
||||||
|
|
||||||
## FreeBSD/FreeNAS Notes
|
## FreeBSD / FreeNAS Notes
|
||||||
|
|
||||||
Before using the script on FreeBSD systems (including FreeNAS) you should first execute the `sysctl` command below to alter the kernel's geometry debug flags. This allows `badblocks` to write to the entire disk:
|
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`
|
`sysctl kern.geom.debugflags=0x10`
|
||||||
|
|
||||||
Also note that `badblocks` may issue the following warning under FreeBSD/FreeNAS, which can safely be ignored as it has no effect on testing:
|
Also note that `badblocks` may issue the following warning under FreeBSD / FreeNAS, which can safely be ignored as it has no effect on testing:
|
||||||
|
|
||||||
`set_o_direct: Inappropiate ioctl for device`
|
`set_o_direct: Inappropiate ioctl for device`
|
||||||
|
|
||||||
@@ -83,17 +95,30 @@ Tested under:
|
|||||||
* FreeNAS 11.2-U8 (FreeBSD 11.2-STABLE)
|
* FreeNAS 11.2-U8 (FreeBSD 11.2-STABLE)
|
||||||
* Ubuntu Server 16.04.2 LTS
|
* Ubuntu Server 16.04.2 LTS
|
||||||
* CentOS 7.0
|
* CentOS 7.0
|
||||||
|
* Tiny Core Linux 11.1
|
||||||
|
|
||||||
## Drive Models Tested
|
## Drive Models Tested
|
||||||
|
|
||||||
The script should run successfully on any SATA disk with SMART capabilities, which includes just about all modern drives. It has been tested on these particular devices:
|
The script should run successfully on any SATA disk with SMART capabilities, which includes just about all modern drives. It has been tested on these particular devices:
|
||||||
|
|
||||||
* HGST Deskstar NAS, UltraStar, UltraStar He10, and UltraStar He12 models
|
* Intel
|
||||||
* Western Digital Gold, Black, and Re models
|
* DC S3700 SSD
|
||||||
|
* Model 320 Series SSD
|
||||||
|
* HGST
|
||||||
|
* Deskstar NAS (HDN724040ALE640)
|
||||||
|
* Ultrastar 7K4000 (HUS724020ALE640)
|
||||||
|
* Ultrastar He10
|
||||||
|
* Ultrastar He12
|
||||||
|
* Western Digital
|
||||||
|
* Black (WD6001FZWX)
|
||||||
|
* Gold
|
||||||
|
* Re (WD4000FYYZ)
|
||||||
|
* Seagate
|
||||||
|
* IronWolf NAS HDD 12TB (ST12000VN0008)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
Requires the smartmontools, available at [www.smartmontools.org](https://www.smartmontools.org)
|
smartmontools, available at [www.smartmontools.org](https://www.smartmontools.org)
|
||||||
|
|
||||||
Uses: `grep`, `awk`, `sed`, `sleep`, `badblocks`
|
Uses: `grep`, `awk`, `sed`, `sleep`, `badblocks`
|
||||||
|
|
||||||
@@ -102,4 +127,4 @@ Tested with the static analysis tool at [www.shellcheck.net](https://www.shellch
|
|||||||
## Author
|
## Author
|
||||||
|
|
||||||
Written by Keith Nash, March 2017.
|
Written by Keith Nash, March 2017.
|
||||||
Modified on 19 August 2020.
|
Modified on 9 September 2020.
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Started burn-in of /dev/da8 on boomer : Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Drive Model: HGST_HUS724020ALE640
|
|
||||||
Serial Number: PKXXXXXXXXXXXX
|
|
||||||
Short test duration: 1 minutes
|
|
||||||
Short test sleep duration: 90 seconds (includes extra delay of 30 seconds)
|
|
||||||
Extended test duration: 332 minutes
|
|
||||||
Extended test sleep duration: 20220 seconds (includes extra delay of 300 seconds)
|
|
||||||
Log file: ./burnin-HGST_HUS724020ALE640_PKXXXXXXXXXXXX.log
|
|
||||||
Bad blocks file: ./burnin-HGST_HUS724020ALE640_PKXXXXXXXXXXXX.bb
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Run SMART short test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Dry run: would start the SMART short test and sleep 90 seconds until the test finishes
|
|
||||||
Finished SMART short test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Run SMART extended test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Dry run: would start the SMART extended test and sleep 20220 seconds until the test finishes
|
|
||||||
Finished SMART extended test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Run badblocks test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Dry run: would run badblocks -b 4096 -wsv -o ./burnin-HGST_HUS724020ALE640_PKXXXXXXXXXXXX.bb /dev/da8
|
|
||||||
Finished badblocks test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Run SMART short test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Dry run: would start the SMART short test and sleep 90 seconds until the test finishes
|
|
||||||
Finished SMART short test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Run SMART extended test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
Dry run: would start the SMART extended test and sleep 20220 seconds until the test finishes
|
|
||||||
Finished SMART extended test on drive /dev/da8: Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
+ Finished burn-in of /dev/da8 on boomer : Tue Mar 14 02:24:16 CDT 2017
|
|
||||||
+-----------------------------------------------------------------------------
|
|
||||||
45
burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log
Normal file
45
burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + Started burn-in
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] Host: arch-desktop
|
||||||
|
[2020-09-09 21:58:23 CEST] OS Flavor: Linux
|
||||||
|
[2020-09-09 21:58:23 CEST] Drive: /dev/sdb
|
||||||
|
[2020-09-09 21:58:23 CEST] Disk Type: mechanical
|
||||||
|
[2020-09-09 21:58:23 CEST] Drive Model: SAMSUNG_HD204UI
|
||||||
|
[2020-09-09 21:58:23 CEST] Serial Number: XXXXXXXXXXXXXX
|
||||||
|
[2020-09-09 21:58:23 CEST] Short test duration: 2 minutes
|
||||||
|
[2020-09-09 21:58:23 CEST] 120 seconds
|
||||||
|
[2020-09-09 21:58:23 CEST] Extended test duration: 341 minutes
|
||||||
|
[2020-09-09 21:58:23 CEST] 20460 seconds
|
||||||
|
[2020-09-09 21:58:23 CEST] Log file: ./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log
|
||||||
|
[2020-09-09 21:58:23 CEST] Bad blocks file: ./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.bb
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + Running SMART short test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: smartctl --test="short" "/dev/sdb"
|
||||||
|
[2020-09-09 21:58:23 CEST] SMART short test started, awaiting completion for 120 seconds ...
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: sleep "120"
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: poll_selftest_complete
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: smartctl --log=selftest "/dev/sdb" | tee -a "./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log"
|
||||||
|
[2020-09-09 21:58:23 CEST] Finished SMART short test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + Running badblocks test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: badblocks -b 4096 -wsv -e 1 -o "./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.bb" "/dev/sdb"
|
||||||
|
[2020-09-09 21:58:23 CEST] Finished badblocks test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + Running SMART long test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: smartctl --test="long" "/dev/sdb"
|
||||||
|
[2020-09-09 21:58:23 CEST] SMART long test started, awaiting completion for 20460 seconds ...
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: sleep "20460"
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: poll_selftest_complete
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: smartctl --log=selftest "/dev/sdb" | tee -a "./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log"
|
||||||
|
[2020-09-09 21:58:23 CEST] Finished SMART long test
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + SMART and non-SMART information
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] DRY RUN: smartctl --xall --vendorattribute=7,hex48 "/dev/sdb" | tee -a "./burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log"
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
|
[2020-09-09 21:58:23 CEST] + Finished burn-in
|
||||||
|
[2020-09-09 21:58:23 CEST] +-----------------------------------------------------------------------------
|
||||||
599
disk-burnin.sh
599
disk-burnin.sh
@@ -1,178 +1,206 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
########################################################################
|
readonly USAGE=\
|
||||||
#
|
"NAME
|
||||||
# disk-burnin.sh
|
$(basename "$0") -- disk burn-in program
|
||||||
#
|
|
||||||
# A script to simplify the process of burning-in disks. Intended for use
|
SYNOPSIS
|
||||||
# only on disks which do not contain valuable data, such as new disks or
|
$(basename "$0") [-h] [-e] [-f] [-o <directory>] <disk>
|
||||||
# disks which are being tested or re-purposed.
|
|
||||||
#
|
DESCRIPTION
|
||||||
# Be aware that:
|
A script to simplify the process of burning-in disks. Only intended for use
|
||||||
#
|
on disks which do not contain any data, such as new disks or disks which
|
||||||
# 1> This script runs the badblocks program in destructive mode, which
|
are being tested or re-purposed.
|
||||||
# erases any data on the disk.
|
|
||||||
#
|
The script runs in dry-run mode by default, so you can check the sleep
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
durations and to insure that the sequence of commands suits your needs. In
|
||||||
# !!!!! WILL DESTROY THE DISK CONTENTS! BE CAREFUL! !!!!!
|
dry-run mode the script does not actually perform any SMART tests or invoke
|
||||||
# !!!!! DO NOT RUN THIS SCRIPT ON DISKS CONTAINING DATA YOU VALUE !!!!!
|
the sleep or badblocks programs.
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
#
|
In order to perform tests on drives, you will need to provide the -f option.
|
||||||
# 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.
|
OPTIONS
|
||||||
#
|
-h show help text
|
||||||
# 3> Must be run as 'root'.
|
-e show extended help text
|
||||||
#
|
-f run in destructive, non-dry mode
|
||||||
# 4> Tests of large drives can take days to complete: use tmux!
|
ALL DATA ON THE DISK WILL BE LOST!
|
||||||
#
|
-o <directory> write log files to <directory> (default: $(pwd))
|
||||||
# Performs these steps:
|
<disk> disk to burn-in (/dev/ may be omitted)
|
||||||
#
|
|
||||||
# 1> Run SMART short test
|
EXAMPLES
|
||||||
# 2> Run badblocks
|
$(basename "$0") sda
|
||||||
# 3> Run SMART extended test
|
run in dry-run mode on disk /dev/sda
|
||||||
#
|
|
||||||
# The script sleeps after starting each SMART test, using a duration
|
$(basename "$0") -f /dev/sdb
|
||||||
# based on the polling interval reported by the disk, after which the
|
run in destructive, non-dry mode on disk /dev/sdb
|
||||||
# script will poll the disk to verify the self-test has completed.
|
|
||||||
#
|
$(basename "$0") -f -o ~/burn-in-logs sdc
|
||||||
# Full SMART information is pulled after each SMART test. All output
|
run in destructive, non-dry mode on disk /dev/sdc and
|
||||||
# except for the sleep command is echoed to both the screen and log file.
|
write the log files to ~/burn-in-logs directory
|
||||||
#
|
"
|
||||||
# You should monitor the burn-in progress and watch for errors, particularly
|
readonly USAGE_2=\
|
||||||
# any errors reported by badblocks, or these SMART errors:
|
"EXIT STATUS
|
||||||
#
|
exit 0: script finishes successfully
|
||||||
# 5 Reallocated_Sector_Ct
|
exit 2: dependencies are missing
|
||||||
# 196 Reallocated_Event_Count
|
not running as 'root'
|
||||||
# 197 Current_Pending_Sector
|
illegal options are provided
|
||||||
# 198 Offline_Uncorrectable
|
|
||||||
#
|
NOTES
|
||||||
# These indicate possible problems with the drive. You therefore may
|
Be warned that:
|
||||||
# wish to abort the remaining tests and proceed with an RMA exchange
|
|
||||||
# for new drives or discard old ones. Also please note that this list
|
1> The script runs badblocks in destructive mode, which erases any data
|
||||||
# is not exhaustive.
|
on the disk.
|
||||||
#
|
|
||||||
# The script extracts the drive model and serial number and forms
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
# a log filename of the form 'burnin-[model]_[serial number].log'.
|
!!!! ALL DATA ON THE DISK WILL BE LOST! BE CAREFUL! !!!!
|
||||||
#
|
!!!! DO NOT RUN THIS SCRIPT ON DISKS CONTAINING VALUABLE DATA !!!!
|
||||||
# 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'.
|
2> Run times for large disks can be several days. Use tmux or screen
|
||||||
#
|
to test multiple disks in parallel.
|
||||||
# The only required command-line argument is the device specifier, e.g.:
|
|
||||||
#
|
3> Must be run as 'root'.
|
||||||
# ./disk-burnin.sh sda
|
|
||||||
#
|
4> The script has the following dependencies:
|
||||||
# ...will run the burn-in test on device /dev/sda
|
|
||||||
#
|
smartmontools, available at https://www.smartmontools.org
|
||||||
# You can run the script in 'dry run mode' (see below) to check the sleep
|
Uses: grep, awk, sed, sleep, badblocks
|
||||||
# duration calculations and to insure that the sequence of commands suits
|
|
||||||
# your needs. In 'dry runs' the script does not actually perform any
|
Performs this test sequence:
|
||||||
# SMART tests or invoke the sleep or badblocks programs. The script is
|
|
||||||
# distributed with 'dry runs' enabled, so you will need to edit the
|
1> Run SMART short test
|
||||||
# DRY_RUN variable below, setting it to 0, in order to actually perform
|
2> Run badblocks
|
||||||
# tests on drives.
|
3> Run SMART extended test
|
||||||
#
|
|
||||||
# Before using the script on FreeBSD systems (including FreeNAS) you must
|
The script sleeps after starting each SMART test, using a duration based on
|
||||||
# first execute this sysctl command to alter the kernel's geometry debug
|
the polling interval reported by the disk, after which the script will poll
|
||||||
# flags. This allows badblocks to write to the entire disk:
|
the disk to verify the self-test has completed.
|
||||||
#
|
|
||||||
# sysctl kern.geom.debugflags=0x10
|
Full SMART information is pulled after each SMART test. All output except
|
||||||
#
|
for the sleep command is written to both stdout and the log.
|
||||||
# Tested under:
|
|
||||||
# FreeNAS 9.10.2 (FreeBSD 10.3-STABLE)
|
You should monitor the burn-in progress and watch for errors, particularly
|
||||||
# Ubuntu Server 16.04.2 LTS
|
any errors reported by badblocks, or these SMART errors:
|
||||||
#
|
|
||||||
# Tested on:
|
5 Reallocated_Sector_Ct
|
||||||
# Intel DC S3700 SSD
|
196 Reallocated_Event_Count
|
||||||
# Intel Model 320 Series SSD
|
197 Current_Pending_Sector
|
||||||
# HGST Deskstar NAS (HDN724040ALE640)
|
198 Offline_Uncorrectable
|
||||||
# Hitachi/HGST Ultrastar 7K4000 (HUS724020ALE640)
|
|
||||||
# Western Digital Re (WD4000FYYZ)
|
These indicate possible problems with the drive. You therefore may wish to
|
||||||
# Western Digital Black (WD6001FZWX)
|
abort the remaining tests and proceed with an RMA exchange for new drives or
|
||||||
#
|
discard old ones. Please note that this list is not exhaustive.
|
||||||
# Requires the smartmontools, available at https://www.smartmontools.org
|
|
||||||
#
|
The script extracts the drive model and serial number and forms a log file-
|
||||||
# Uses: grep, awk, sed, sleep, badblocks
|
name of the form 'burnin-[model]_[serial number].log'.
|
||||||
#
|
|
||||||
# Written by Keith Nash, March 2017
|
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
|
||||||
# KN, 8 Apr 2017:
|
a file named 'burnin-[model]_[serial number].bb'.
|
||||||
# Added minimum test durations because some devices don't return accurate values.
|
|
||||||
# Added code to clean up the log file, removing copyright notices, etc.
|
Before using the script on FreeBSD systems (including FreeNAS) you must
|
||||||
# No longer echo 'smartctl -t' output to log file as it imparts no useful information.
|
first execute this sysctl command to alter the kernel's geometry debug
|
||||||
# Emit test results after tests instead of full 'smartctl -a' output.
|
flags. This allows badblocks to write to the entire disk:
|
||||||
# Emit full 'smartctl -x' output at the end of all testing.
|
|
||||||
# Minor changes to log output and formatting.
|
sysctl kern.geom.debugflags=0x10
|
||||||
#
|
|
||||||
# KN, 12 May 2017:
|
Also note that badblocks may issue the following warning under FreeBSD /
|
||||||
# Added code to poll the disk and check for completed self-tests.
|
FreeNAS, which can safely be ignored as it has no effect on testing:
|
||||||
#
|
|
||||||
# As noted above, some disks don't report accurate values for the short and extended
|
set_o_direct: Inappropiate ioctl for device
|
||||||
# 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
|
Tested operating systems:
|
||||||
# self-tests had not completed. The new polling code helps insure that this doesn't
|
|
||||||
# happen.
|
FreeNAS 9.10.2 (FreeBSD 10.3-STABLE)
|
||||||
#
|
FreeNAS 11.1-U7 (FreeBSD 11.1-STABLE)
|
||||||
# Fixed code to work around annoying differences between sed's behavior on Linux and
|
FreeNAS 11.2-U8 (FreeBSD 11.2-STABLE)
|
||||||
# FreeBSD.
|
Ubuntu Server 16.04.2 LTS
|
||||||
#
|
CentOS 7.0
|
||||||
# KN, 8 Jun 2017
|
Tiny Core Linux 11.1
|
||||||
# Modified parsing of short and extended test durations to accommodate the values
|
|
||||||
# returned by larger drives; we needed to strip out the '(' and ')' characters
|
Tested disks:
|
||||||
# surrounding the integer value in order to fetch it reliably.
|
|
||||||
#
|
Intel
|
||||||
# KN, 19 Aug 2020
|
DC S3700 SSD
|
||||||
# Changed DRY_RUN value so that dry runs are no longer the default setting.
|
Model 320 Series SSD
|
||||||
# Changed badblocks call to exit immediately on first error.
|
HGST
|
||||||
# Set logging directoryto current working directory using pwd command.
|
Deskstar NAS (HDN724040ALE640)
|
||||||
# Reduced default tests so that we run:
|
Ultrastar 7K4000 (HUS724020ALE640)
|
||||||
# 1> Short SMART test
|
Ultrastar He10
|
||||||
# 2> badblocks
|
Ultrastar He12
|
||||||
# 3> Extended SMART test
|
Western Digital
|
||||||
#
|
Black (WD6001FZWX)
|
||||||
################################################################################
|
Gold
|
||||||
|
Re (WD4000FYYZ)
|
||||||
|
Seagate
|
||||||
|
IronWolf NAS HDD 12TB (ST12000VN0008)
|
||||||
|
|
||||||
|
VERSIONS
|
||||||
|
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.
|
||||||
|
No longer echo 'smartctl -t' output to log file as it imparts no useful
|
||||||
|
information.
|
||||||
|
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 '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.
|
||||||
|
|
||||||
|
KN, 8 Jun 2017
|
||||||
|
Modified parsing of short and extended test durations to accommodate the
|
||||||
|
values returned by larger drives; we needed to strip out the '(' and ')'
|
||||||
|
characters surrounding the integer value in order to fetch it reliably.
|
||||||
|
|
||||||
|
KN, 19 Aug 2020
|
||||||
|
Changed DRY_RUN value so that dry runs are no longer the default
|
||||||
|
setting.
|
||||||
|
Changed badblocks call to exit immediately on first error.
|
||||||
|
Set logging directory to current working directory using pwd command.
|
||||||
|
Reduced default tests so that we run:
|
||||||
|
1> Short SMART test
|
||||||
|
2> badblocks
|
||||||
|
3> Extended SMART test
|
||||||
|
|
||||||
|
MS, 9 Sep 2020
|
||||||
|
Add .editorconfig to streamlime editor behavior for developers.
|
||||||
|
Remove dependencies on pcregrep and tr.
|
||||||
|
Add documentation to functions and complex statements.
|
||||||
|
Reduce code duplication, simplify and decouple code where possible.
|
||||||
|
Improve portability and resiliency.
|
||||||
|
Check availability of dependencies during runtim.
|
||||||
|
Check for root privileges during runtime.
|
||||||
|
Add option parsing, most notably (-h)elp and -f for non-dry-run mode.
|
||||||
|
Add dry_run_wrapper() function.
|
||||||
|
Add disk type detection to skip badblocks for non-mechanical drives."
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# PRE-EXECUTION VALIDATION
|
# PRE-EXECUTION VALIDATION
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Check required dependencies
|
# parse options
|
||||||
readonly DEPENDENCIES="awk badblocks grep sed sleep"
|
while getopts ':hefo:' option; do
|
||||||
for dependency in ${DEPENDENCIES}; do
|
|
||||||
if ! command -v "${dependency}" > /dev/null 2>&1 ; then
|
|
||||||
echo "Command '${dependency}' not found" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check if running as root
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
|
||||||
echo "Please run as root" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly USAGE=\
|
|
||||||
"$(basename "$0") -- program to burn-in disks
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
$(basename "$0") [-h] [-f] [-o <directory>] <disk>
|
|
||||||
|
|
||||||
By default the program runs in dry mode and no data will be lost.
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h show help text
|
|
||||||
-f run in destructive, non-dry mode
|
|
||||||
ALL DATA ON THE DISK WILL BE LOST!
|
|
||||||
-o <directory> write log files to <directory>
|
|
||||||
default: $(pwd)
|
|
||||||
<disk> disk to burn-in: /dev/<disk>
|
|
||||||
e.g. specify 'sda' to burn-in '/dev/sda'"
|
|
||||||
|
|
||||||
while getopts ':hfo:' option; do
|
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
h) echo "${USAGE}"
|
h) echo "${USAGE}"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
f) DRY_RUN=0
|
e) echo "${USAGE}"
|
||||||
|
echo "${USAGE_2}"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
f) readonly DRY_RUN=0
|
||||||
;;
|
;;
|
||||||
o) LOG_DIR="${OPTARG}"
|
o) LOG_DIR="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
@@ -194,16 +222,32 @@ if [ -z "$1" ]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check required dependencies
|
||||||
|
readonly DEPENDENCIES="awk badblocks grep sed sleep"
|
||||||
|
for dependency in ${DEPENDENCIES}; do
|
||||||
|
if ! command -v "${dependency}" > /dev/null 2>&1; then
|
||||||
|
echo "Command '${dependency}' not found" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if running as root
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "Please run as root" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Drive to burn-in
|
# Drive to burn-in
|
||||||
readonly DRIVE="$1"
|
DRIVE="$1"
|
||||||
|
# prepend /dev/ if necessary
|
||||||
# Run in dry mode if -f wasn't provided
|
if ! printf '%s' "${DRIVE}" | grep "/dev/\w*" > /dev/null 2>&1; then
|
||||||
[ -z "${DRY_RUN}" ] && DRY_RUN=1
|
DRIVE="/dev/${DRIVE}"
|
||||||
readonly DRY_RUN
|
fi
|
||||||
|
readonly DRIVE
|
||||||
|
|
||||||
# Set to working directory if -o <directory> wasn't provided
|
# Set to working directory if -o <directory> wasn't provided
|
||||||
[ -z "${LOG_DIR}" ] && LOG_DIR="$(pwd)"
|
[ -z "${LOG_DIR}" ] && LOG_DIR="$(pwd)"
|
||||||
@@ -216,8 +260,8 @@ readonly HOSTNAME="$(hostname)"
|
|||||||
readonly OS_FLAVOR="$(uname)"
|
readonly OS_FLAVOR="$(uname)"
|
||||||
|
|
||||||
# SMART static information
|
# SMART static information
|
||||||
readonly SMART_INFO="$(smartctl --info "/dev/${DRIVE}")"
|
readonly SMART_INFO="$(smartctl --info "${DRIVE}")"
|
||||||
readonly SMART_CAPABILITIES="$(smartctl --capabilities "/dev/${DRIVE}")"
|
readonly SMART_CAPABILITIES="$(smartctl --capabilities "${DRIVE}")"
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Get SMART information value.
|
# Get SMART information value.
|
||||||
@@ -267,14 +311,21 @@ get_smart_test_duration() {
|
|||||||
# Get disk model
|
# Get disk model
|
||||||
DISK_MODEL="$(get_smart_info_value "Device Model")"
|
DISK_MODEL="$(get_smart_info_value "Device Model")"
|
||||||
[ -z "${DISK_MODEL}" ] && DISK_MODEL="$(get_smart_info_value "Model Family")"
|
[ -z "${DISK_MODEL}" ] && DISK_MODEL="$(get_smart_info_value "Model Family")"
|
||||||
|
[ -z "${DISK_MODEL}" ] && DISK_MODEL="$(get_smart_info_value "Model Number")"
|
||||||
readonly DISK_MODEL
|
readonly DISK_MODEL
|
||||||
|
|
||||||
|
# Get disk type
|
||||||
|
DISK_TYPE="$(get_smart_info_value "Rotation Rate")"
|
||||||
|
if printf '%s' "${DISK_TYPE}" | grep "rpm" > /dev/null 2>&1; then
|
||||||
|
DISK_TYPE="mechanical"
|
||||||
|
else
|
||||||
|
DISK_TYPE="non-mechanical"
|
||||||
|
fi
|
||||||
|
readonly DISK_TYPE
|
||||||
|
|
||||||
# Get disk serial number
|
# Get disk serial number
|
||||||
readonly SERIAL_NUMBER="$(get_smart_info_value "Serial Number")"
|
readonly SERIAL_NUMBER="$(get_smart_info_value "Serial Number")"
|
||||||
|
|
||||||
# The script initially sleeps for a duration after a test is started.
|
|
||||||
# Afterwards the completion status is repeatedly polled.
|
|
||||||
|
|
||||||
# SMART short test duration
|
# SMART short test duration
|
||||||
readonly SHORT_TEST_MINUTES="$(get_smart_test_duration "Short")"
|
readonly SHORT_TEST_MINUTES="$(get_smart_test_duration "Short")"
|
||||||
readonly SHORT_TEST_SECONDS="$(( SHORT_TEST_MINUTES * 60))"
|
readonly SHORT_TEST_SECONDS="$(( SHORT_TEST_MINUTES * 60))"
|
||||||
@@ -325,6 +376,94 @@ log_header()
|
|||||||
log_info "+-----------------------------------------------------------------------------"
|
log_info "+-----------------------------------------------------------------------------"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Ensure log directory exists and remove old logs.
|
||||||
|
# Globals:
|
||||||
|
# LOG_DIR
|
||||||
|
# LOG_FILE
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
##################################################
|
||||||
|
init_log() {
|
||||||
|
mkdir -p -- "${LOG_DIR}" || exit 2
|
||||||
|
[ -e "${LOG_FILE}" ] && rm -- "${LOG_FILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Remove redundant messages from log.
|
||||||
|
# Globals:
|
||||||
|
# LOG_FILE
|
||||||
|
# OS_FLAVOR
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
##################################################
|
||||||
|
cleanup_log() {
|
||||||
|
if [ "${OS_FLAVOR}" = "Linux" ]; then
|
||||||
|
sed -i -e '/Copyright/d' "${LOG_FILE}"
|
||||||
|
sed -i -e '/=== START OF READ/d' "${LOG_FILE}"
|
||||||
|
sed -i -e '/SMART Attributes Data/d' "${LOG_FILE}"
|
||||||
|
sed -i -e '/Vendor Specific SMART/d' "${LOG_FILE}"
|
||||||
|
sed -i -e '/SMART Error Log Version/d' "${LOG_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${OS_FLAVOR}" = "FreeBSD" ]; then
|
||||||
|
sed -i '' -e '/Copyright/d' "${LOG_FILE}"
|
||||||
|
sed -i '' -e '/=== START OF READ/d' "${LOG_FILE}"
|
||||||
|
sed -i '' -e '/SMART Attributes Data/d' "${LOG_FILE}"
|
||||||
|
sed -i '' -e '/Vendor Specific SMART/d' "${LOG_FILE}"
|
||||||
|
sed -i '' -e '/SMART Error Log Version/d' "${LOG_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Log command in dry-run mode, run command otherwise.
|
||||||
|
# Globals:
|
||||||
|
# DRY_RUN
|
||||||
|
# Arguments:
|
||||||
|
# Command to run.
|
||||||
|
##################################################
|
||||||
|
dry_run_wrapper()
|
||||||
|
{
|
||||||
|
if [ -z "$DRY_RUN" ]; then
|
||||||
|
log_info "DRY RUN: $*"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
eval "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Log runtime information about current burn-in.
|
||||||
|
# Globals:
|
||||||
|
# HOSTNAME
|
||||||
|
# OS_FLAVOR
|
||||||
|
# DRIVE
|
||||||
|
# DISK_TYPE
|
||||||
|
# DISK_MODEL
|
||||||
|
# SERIAL_NUMBER
|
||||||
|
# SHORT_TEST_MINUTES
|
||||||
|
# SHORT_TEST_SECONDS
|
||||||
|
# EXTENDED_TEST_MINUTES
|
||||||
|
# EXTENDED_TEST_SECONDS
|
||||||
|
# LOG_FILE
|
||||||
|
# BB_File
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
##################################################
|
||||||
|
log_runtime_info() {
|
||||||
|
log_info "Host: ${HOSTNAME}"
|
||||||
|
log_info "OS Flavor: ${OS_FLAVOR}"
|
||||||
|
log_info "Drive: ${DRIVE}"
|
||||||
|
log_info "Disk Type: ${DISK_TYPE}"
|
||||||
|
log_info "Drive Model: ${DISK_MODEL}"
|
||||||
|
log_info "Serial Number: ${SERIAL_NUMBER}"
|
||||||
|
log_info "Short test duration: ${SHORT_TEST_MINUTES} minutes"
|
||||||
|
log_info " ${SHORT_TEST_SECONDS} seconds"
|
||||||
|
log_info "Extended test duration: ${EXTENDED_TEST_MINUTES} minutes"
|
||||||
|
log_info " ${EXTENDED_TEST_SECONDS} seconds"
|
||||||
|
log_info "Log file: ${LOG_FILE}"
|
||||||
|
log_info "Bad blocks file: ${BB_File}"
|
||||||
|
}
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Poll repeatedly whether SMART self-test has completed.
|
# Poll repeatedly whether SMART self-test has completed.
|
||||||
# Globals:
|
# Globals:
|
||||||
@@ -341,13 +480,15 @@ poll_selftest_complete()
|
|||||||
{
|
{
|
||||||
l_poll_duration_seconds=0
|
l_poll_duration_seconds=0
|
||||||
while [ "${l_poll_duration_seconds}" -lt "${POLL_TIMEOUT_SECONDS}" ]; do
|
while [ "${l_poll_duration_seconds}" -lt "${POLL_TIMEOUT_SECONDS}" ]; do
|
||||||
smartctl --all "/dev/${DRIVE}" | grep -i "The previous self-test routine completed" > /dev/null 2<&1
|
smartctl --all "${DRIVE}" \
|
||||||
|
| grep -i "The previous self-test routine completed" > /dev/null 2>&1
|
||||||
l_status="$?"
|
l_status="$?"
|
||||||
if [ "${l_status}" -eq 0 ]; then
|
if [ "${l_status}" -eq 0 ]; then
|
||||||
log_info "SMART self-test succeeded"
|
log_info "SMART self-test succeeded"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
smartctl --all "/dev/${DRIVE}" | grep -i "of the test failed." > /dev/null 2<&1
|
smartctl --all "${DRIVE}" \
|
||||||
|
| grep -i "of the test failed\." > /dev/null 2>&1
|
||||||
l_status="$?"
|
l_status="$?"
|
||||||
if [ "${l_status}" -eq 0 ]; then
|
if [ "${l_status}" -eq 0 ]; then
|
||||||
log_info "SMART self-test failed"
|
log_info "SMART self-test failed"
|
||||||
@@ -373,17 +514,13 @@ poll_selftest_complete()
|
|||||||
##################################################
|
##################################################
|
||||||
run_smart_test()
|
run_smart_test()
|
||||||
{
|
{
|
||||||
log_header "Run SMART $1 test"
|
log_header "Running SMART $1 test"
|
||||||
if [ "${DRY_RUN}" -eq 0 ]; then
|
dry_run_wrapper "smartctl --test=\"$1\" \"${DRIVE}\""
|
||||||
smartctl --test="$1" "/dev/${DRIVE}"
|
log_info "SMART $1 test started, awaiting completion for $2 seconds ..."
|
||||||
log_info "SMART $1 test started, awaiting completion for $2 seconds ..."
|
dry_run_wrapper "sleep \"$2\""
|
||||||
sleep "$2"
|
dry_run_wrapper "poll_selftest_complete"
|
||||||
poll_selftest_complete
|
dry_run_wrapper "smartctl --log=selftest \"${DRIVE}\" | tee -a \"${LOG_FILE}\""
|
||||||
smartctl --log=selftest "/dev/${DRIVE}" | tee -a "${LOG_FILE}"
|
log_info "Finished SMART $1 test"
|
||||||
else
|
|
||||||
log_info "Dry run: would start the SMART $1 test and sleep $2 seconds until the test finishes"
|
|
||||||
fi
|
|
||||||
log_info "Finished SMART short test"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
@@ -391,6 +528,7 @@ run_smart_test()
|
|||||||
# !!! ALL DATA ON THE DISK WILL BE LOST !!!
|
# !!! ALL DATA ON THE DISK WILL BE LOST !!!
|
||||||
# Globals:
|
# Globals:
|
||||||
# BB_File
|
# BB_File
|
||||||
|
# DISK_TYPE
|
||||||
# DRIVE
|
# DRIVE
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# None
|
# None
|
||||||
@@ -398,62 +536,51 @@ run_smart_test()
|
|||||||
run_badblocks_test()
|
run_badblocks_test()
|
||||||
{
|
{
|
||||||
log_header "Running badblocks test"
|
log_header "Running badblocks test"
|
||||||
if [ "${DRY_RUN}" -eq 0 ]; then
|
if [ "${DISK_TYPE}" = "mechanical" ]; then
|
||||||
badblocks -b 4096 -wsv -e 1 -o "${BB_File}" "/dev/${DRIVE}"
|
dry_run_wrapper "badblocks -b 4096 -wsv -e 1 -o \"${BB_File}\" \"${DRIVE}\""
|
||||||
else
|
else
|
||||||
log_info "Dry run: would run badblocks -b 4096 -wsv -e 1 -o ${BB_File} /dev/${DRIVE}"
|
log_info "SKIPPED: badblocks for ${DISK_TYPE} device"
|
||||||
fi
|
fi
|
||||||
log_info "Finished badblocks test"
|
log_info "Finished badblocks test"
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
##################################################
|
||||||
# ACTIONS BEGINS HERE
|
# Log extensive SMART and non-SMART drive information.
|
||||||
################################################################################
|
# Globals:
|
||||||
|
# DRIVE
|
||||||
|
# LOG_FILE
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
##################################################
|
||||||
|
log_full_device_info() {
|
||||||
|
log_header "SMART and non-SMART information"
|
||||||
|
dry_run_wrapper "smartctl --xall --vendorattribute=7,hex48 \"${DRIVE}\" | tee -a \"${LOG_FILE}\""
|
||||||
|
}
|
||||||
|
|
||||||
# Create log directory if it doesn't exist
|
##################################################
|
||||||
mkdir -p -- "${LOG_DIR}" || exit 2
|
# Main function of script.
|
||||||
|
# Globals:
|
||||||
|
# SHORT_TEST_SECONDS
|
||||||
|
# EXTENDED_TEST_SECONDS
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
##################################################
|
||||||
|
main() {
|
||||||
|
init_log
|
||||||
|
log_header "Started burn-in"
|
||||||
|
|
||||||
if [ -e "${LOG_FILE}" ]; then
|
log_runtime_info
|
||||||
rm "${LOG_FILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_header "Started burn-in"
|
# test sequence
|
||||||
|
run_smart_test "short" "${SHORT_TEST_SECONDS}"
|
||||||
|
run_badblocks_test
|
||||||
|
run_smart_test "long" "${EXTENDED_TEST_SECONDS}"
|
||||||
|
|
||||||
log_info "Host: ${HOSTNAME}"
|
log_full_device_info
|
||||||
log_info "OS Flavor: ${OS_FLAVOR}"
|
|
||||||
log_info "Drive: /dev/${DRIVE}"
|
|
||||||
log_info "Drive Model: ${DISK_MODEL}"
|
|
||||||
log_info "Serial Number: ${SERIAL_NUMBER}"
|
|
||||||
log_info "Short test duration: ${SHORT_TEST_MINUTES} minutes / ${SHORT_TEST_SECONDS} seconds"
|
|
||||||
log_info "Extended test duration: ${EXTENDED_TEST_MINUTES} minutes / ${EXTENDED_TEST_SECONDS} seconds"
|
|
||||||
log_info "Log file: ${LOG_FILE}"
|
|
||||||
log_info "Bad blocks file: ${BB_File}"
|
|
||||||
|
|
||||||
# Run the test sequence:
|
log_header "Finished burn-in"
|
||||||
run_smart_test "short" "${SHORT_TEST_SECONDS}"
|
cleanup_log
|
||||||
run_badblocks_test
|
}
|
||||||
run_smart_test "long" "${EXTENDED_TEST_SECONDS}"
|
|
||||||
|
|
||||||
# Emit full device information to log:
|
# Entrypoint
|
||||||
log_header "SMART and non-SMART information"
|
main
|
||||||
smartctl --xall --vendorattribute=7,hex48 "/dev/${DRIVE}" | tee -a "${LOG_FILE}"
|
|
||||||
|
|
||||||
log_header "Finished burn-in"
|
|
||||||
|
|
||||||
# Clean up the log file:
|
|
||||||
|
|
||||||
if [ "${OS_FLAVOR}" = "Linux" ]; then
|
|
||||||
sed -i -e '/Copyright/d' "${LOG_FILE}"
|
|
||||||
sed -i -e '/=== START OF READ/d' "${LOG_FILE}"
|
|
||||||
sed -i -e '/SMART Attributes Data/d' "${LOG_FILE}"
|
|
||||||
sed -i -e '/Vendor Specific SMART/d' "${LOG_FILE}"
|
|
||||||
sed -i -e '/SMART Error Log Version/d' "${LOG_FILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${OS_FLAVOR}" = "FreeBSD" ]; then
|
|
||||||
sed -i '' -e '/Copyright/d' "${LOG_FILE}"
|
|
||||||
sed -i '' -e '/=== START OF READ/d' "${LOG_FILE}"
|
|
||||||
sed -i '' -e '/SMART Attributes Data/d' "${LOG_FILE}"
|
|
||||||
sed -i '' -e '/Vendor Specific SMART/d' "${LOG_FILE}"
|
|
||||||
sed -i '' -e '/SMART Error Log Version/d' "${LOG_FILE}"
|
|
||||||
fi
|
|
||||||
|
|||||||
Reference in New Issue
Block a user