Problem:
In the current version, my SAS drive had empty fields:
* Drive Model
* Serial Number
* Short/Extended test duration
The script got stuck after the first SMART short test, reporting it would wait for 0 seconds.
Assumptions:
* smartctl reports different values in different fields on SAS drives (e.g. smartctl --capabilities only reports "SCSI device successfully opened")
* Every drive offers a "short" test. SAS drives do not provide information about that
* Every drive offers a "long" test. ATA drives will translate this into "extended"
* A burn-in is not time critical but must be exhaustive
Actions:
* Made grep case insensitive for Serial number on SAS vs Serial Number on ATA
* Changed "discard first two columns" to "discard everything until first colon" in get_smart_info_value
* Added colon at the end of every inquired smart info
* Changed test behavior "if success in smartctl then success; else if error in smartctl then error" to "if ATA error in smartctl then error; else if no test in progress then success" in poll_selftest_complete
Remaining problems:
* For SAS drives it will still print and log "waiting 0 seconds for test completion"
Propositions:
* Show Progress of SMART Test / remaining % instead of a fixed "waiting for ### seconds"
* Print and log actual time until completion instead of reported test duration, or maybe both
* As even SAS drives report a "long test duration", POLL_TIMEOUT_SECONDS could be set relative to that (like 1.5x), and not fixed to 4 hours.
* Maybe warn on POLL_TIMEOUT and report time tested until now, instead of abort?
* Switch to some other output form of smartctl, like json, and parse it with something like jq
INFO ABOUT RUNNING TEST:
SAS running short test
smartctl -l selftest /dev/sdc
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.15-arch1-1] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
Self-test execution status: 84% of test remaining
SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background short Self test in progress ... - NOW - [- - -]
# 2 Background short Completed - 29626 - [- - -]
# 3 Background short Completed - 29626 - [- - -]
# 4 Background short Completed - 29625 - [- - -]
# 5 Background short Completed - 29625 - [- - -]
# 6 Background long Completed - 29625 - [- - -]
# 7 Background short Completed - 29612 - [- - -]
# 8 Background long Completed - 29608 - [- - -]
Long (extended) Self-test duration: 3772 seconds [62.9 minutes]
SAS not running short test: "Self-test execution status" line is missing
ATA running extended test: smartctl -c /dev/sdg
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.15-arch1-1] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status: (0x05) Offline data collection activity
was aborted by an interrupting command from host.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 242) Self-test routine in progress...
20% of test remaining.
Total time to complete Offline
data collection: ( 45) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 113) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
ATA drive after abort:
Self-test execution status: ( 25) The self-test routine was aborted by
the host.
ATA drive after successful short test:
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
SMART INFO ON SAS DRIVE
# echo $SMART_INFO
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.15-arch1-1] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: TOSHIBA
Product: AL13SXB600N
Revision: 5202
Compliance: SPC-3
User Capacity: 600,127,266,816 bytes [600 GB]
Logical block size: 512 bytes
Rotation Rate: 15000 rpm
Form Factor: 2.5 inches
Logical Unit id: 0x500003975861d374
Serial number: X6S0A03FFIYA
Device type: disk
Transport protocol: SAS (SPL-3)
Local Time is: Sat Nov 20 14:18:01 2021 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Disabled or Not Supported
FYI:# smartctl -A /dev/sdc
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.15-arch1-1] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
Current Drive Temperature: 51 C
Drive Trip Temperature: 65 C
Accumulated power on time, hours:minutes 29625:34
Manufactured in week 43 of year 2016
Specified cycle count over device lifetime: 50000
Accumulated start-stop cycles: 15
Specified load-unload count over device lifetime: 600000
Accumulated load-unload cycles: 15
Elements in grown defect list: 0
FYI to get info like ATA "reallocated sector" or "pending sector" os SAS devices:
# smartctl -l error /dev/sdc
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.14.15-arch1-1] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
Error counter log:
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 0 2567 1986 1986 0 993683.879 0
write: 0 0 0 0 0 49874.645 0
verify: 0 0 0 0 0 106222.531 0
Non-medium error count: 0
|
||
|---|---|---|
| .editorconfig | ||
| burnin-SAMSUNG_HD204UI_XXXXXXXXXXXXXX.log | ||
| disk-burnin.sh | ||
| license.txt | ||
| README.md | ||
Shell script for burn-in and testing of drives
Purpose
disk-burnin.sh is a POSIX-compliant shell script I wrote to simplify the process of burning-in disks. It is intended for use only on disks which do not contain data, such as new disks or disks which are being tested or re-purposed. I was inspired by the "How To: Hard Drive Burn-In Testing" thread on the FreeNAS forum and I want to give full props to the good folks who contributed to that thread.
Warnings
Be warned that:
- This script runs
badblocksin 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 be several days. Use
tmuxorscreento test multiple disks in parallel. - Must be run as 'root'.
Tests
Performs these steps:
- Run SMART short test
- Run
badblocks - Run SMART extended test
The script calls sleep after starting each SMART test, using a duration based on the polling interval reported by the disk, after which it polls for test completion.
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:
| ID | Attribute Name |
|---|---|
| 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 for new drives or discard old ones. Also please note that this list is not exhaustive.
The script extracts the drive model and serial number and creates a log filename of the form burnin-[model]_[serial number].log.
badblocks Options
badblocks is invoked with the following options:
-b 8192: Use a block size of 8192-e 1: Abort thebadblockstest immediately if an error is found (override this setting with the-xoption below)-v: Verbose mode-o: Write list of bad blocks found (if any) to a file namedburnin-[model]_[serial number].bb-s: Show progress-w: Write-mode test, writes four patterns (0xaa, 0x55, 0xff, 0x00) on every disk block
Usage
./disk-burnin.sh [-h] [-e] [-f] [-o <directory>] [-x] <disk>
Options
-h: show help text-e: show extended help text-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))-x: perform a full pass ofbadblocks, using the-e 0option.<disk>: disk to burn-in (/dev/may be omitted)
Examples
./disk-burnin.sh sda: run in dry-run mode on disk/dev/sda./disk-burnin.sh -f /dev/sdb: run full, destructive test on disk/dev/sdb./disk-burnin.sh -f -o ~/burn-in-logs sdc: run full, destructive test on disk/dev/sdcand write the log files to~/burn-in-logsdirectory
Dry-Run Mode
The script runs in dry-run mode by default, so you can check the sleep durations and 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
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
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
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
Operating System Compatibility
Tested under:
- FreeNAS 9.10.2-U1 (FreeBSD 10.3-STABLE)
- FreeNAS 11.1-U7 (FreeBSD 11.1-STABLE)
- FreeNAS 11.2-U8 (FreeBSD 11.2-STABLE)
- Ubuntu Server 16.04.2 LTS
- CentOS 7.0
- Tiny Core Linux 11.1
- Fedora 33 Workstation
Drive Models Tested
The script should run successfully on any SAS or SATA disk with SMART capabilities, which includes just about all modern drives. It has been tested on these particular devices:
- Intel
- 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)
- Green
- Red
- WD140EDFZ
- Seagate
- IronWolf NAS HDD 12TB (ST12000VN0008)
- IronWolf NAS HDD 8TB (ST8000NE001-2M7101)
Prerequisites
smartmontools, available at www.smartmontools.org
Uses: grep, awk, sed, sleep, badblocks, smartctl
Tested with the static analysis tool at www.shellcheck.net to insure that the code is POSIX-compliant and free of issues.
Author
Original author: Keith Nash, March 2017. Modified on 19 February 2021.