No description
|
||
---|---|---|
LICENSE | ||
README.md | ||
smartdrivecheck.sh |
SMART and Badblocks Testing Script
This script performs diagnostic tests on a specified block device using smartctl
and badblocks
. It enables SMART, checks device health, runs various SMART tests, and conducts a non-destructive write test.
Prerequisites
Ensure the following dependencies are installed on your system:
smartctl
(part of thesmartmontools
package)badblocks
Usage
./smartdrivecheck.sh <device>
<device>
: The block device to test (e.g.,/dev/sda
).
Example
./smartdrivecheck.sh /dev/sda
Script Workflow
-
Dependency Check
- Verifies that
smartctl
andbadblocks
are installed and executable.
- Verifies that
-
Device Validation
- Ensures the specified device is a valid block device.
-
Enable SMART
- Enables SMART on the device if it is not already enabled.
-
SMART Data Checks
- Runs a series of checks on existing SMART data, including health status, error logs, and self-test logs.
-
Polling Time Extraction
- Extracts polling times for various SMART self-tests (short, extended, and conveyance).
-
Self-Tests
- Depending on available polling times, performs conveyance, short, or extended tests, waiting for their completion.
-
Non-Destructive Write Test
- Uses
badblocks
to perform a non-destructive write test on the device.
- Uses
-
Final Extended Test
- If applicable, performs a final extended SMART test.
Environment Variables
During execution, the script extracts the following variables based on device capabilities:
CONVEYANCE_SLEEP
: Estimated time (in minutes) for the conveyance test.SHORT_SLEEP
: Estimated time (in minutes) for the short test.EXTENDED_SLEEP
: Estimated time (in minutes) for the extended test.
Notes
- Non-Destructive Testing: The script ensures that the write test is non-destructive, preserving existing data on the device.
- SMART Compatibility: This script assumes the device supports SMART. Ensure your device is compatible before running the script.
Error Handling
- The script terminates if any critical error occurs during execution.
- Specific error messages will be printed to
stderr
.
License
This script is open source and available under the AGPL License. See attached License.
Disclaimer
Use this script at your own risk. Always back up your data before performing diagnostics or tests on storage devices.