Skip to content

Instantly share code, notes, and snippets.

@caffeineflo
Last active January 4, 2023 20:22
Show Gist options
  • Save caffeineflo/1dd15a3d682a8c99519905cb1e28eb33 to your computer and use it in GitHub Desktop.
Save caffeineflo/1dd15a3d682a8c99519905cb1e28eb33 to your computer and use it in GitHub Desktop.
Burn-in Test for new HDDs
#!/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