33 lines
749 B
Bash
Executable File
33 lines
749 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 [short|long]"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" != "short" ] && [ "$1" != "long" ]; then
|
|
echo "Invalid argument: $1"
|
|
echo "Usage: $0 [short|long]"
|
|
exit 1
|
|
fi
|
|
|
|
# Get the list of all physical disks
|
|
declare -a disks
|
|
for disk in $(lsblk -ido KNAME | grep -v -e loop -e KNAME); do
|
|
disks+=("$disk")
|
|
done
|
|
|
|
# Run a SMART test on all disks
|
|
for disk in "${disks[@]}"; do
|
|
echo "Running $1 test on /dev/$disk"
|
|
if [ "$1" == "short" ]; then
|
|
sudo smartctl -t short /dev/$disk > /dev/null
|
|
elif [ "$1" == "long" ]; then
|
|
sudo smartctl -t long /dev/$disk > /dev/null
|
|
else
|
|
echo "Invalid argument: $1"
|
|
echo "Usage: $0 [short|long]"
|
|
exit 1
|
|
fi
|
|
done
|