Last active
January 4, 2023 20:22
-
-
Save caffeineflo/1dd15a3d682a8c99519905cb1e28eb33 to your computer and use it in GitHub Desktop.
Burn-in Test for new HDDs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure the script is being run as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
# Iterate through the hard drives | |
for i in {b..f}; do | |
# Set the device path | |
device="/dev/sd$i" | |
# Check if the device exists | |
if [ -e "$device" ]; then | |
( | |
echo "Testing $device..." | |
# Perform SMART short self-test | |
smartctl -t short $device | |
# Wait for the SMART self-test to complete | |
while true; do | |
output=$(smartctl -l selftest $device) | |
if ! grep -q "Self-test routine in progress" <<<"$output"; then | |
break | |
fi | |
sleep 1 | |
done | |
# Perform SMART conveyance self-test | |
smartctl -t conveyance $device | |
# Wait for the SMART self-test to complete | |
while true; do | |
output=$(smartctl -l selftest $device) | |
if ! grep -q "Self-test routine in progress" <<<"$output"; then | |
break | |
fi | |
sleep 1 | |
done | |
# Perform SMART long self-test | |
smartctl -t long $device | |
# Wait for the SMART self-test to complete | |
while true; do | |
output=$(smartctl -l selftest $device) | |
if ! grep -q "Self-test routine in progress" <<<"$output"; then | |
break | |
fi | |
sleep 1 | |
done | |
# Perform bad blocks testing | |
badblocks -wsv $device | |
) & | |
else | |
echo "$device does not exist" | |
fi | |
done | |
# Wait for all processes to complete | |
wait | |
echo "Burn-in test complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment