Скрипт теста вашего диска SSD и установки оценки его)

follow

Пользователь
Пользователь
Регистрация
24 Окт 2019
Сообщения
45
Реакции
24
apt install hdparm
apt install bc

Bash:
#!/bin/bash
#
# Script to test SSD disk speed and give an average rating

echo "Testing SSD disk speed..."
echo ""

# Run hdparm command to test read speed
hdparm -t /dev/sda > speedtest.txt

# Extract speed from result and print to console
read_speed=$(cat speedtest.txt | awk '/Timing buffered/ {print $5}')
echo "Read speed: $read_speed MB/s"

# Calculate rating based on speed
rating=""
if (( $(echo "$read_speed < 200" |bc -l) )); then
    rating="Poor"
elif (( $(echo "$read_speed < 400" |bc -l) )); then
    rating="Average"
else
    rating="Excellent"
fi

# Print rating to console
echo "Disk rating: $rating"

# Clean up
rm speedtest.txt
 
Чуть поправил
Bash:
#!/bin/bash
#
# Script to test SSD disk speed for read and write operations

echo "Testing SSD disk speed for read and write operations..."
echo ""

# Run read speed test using hdparm command
echo "Testing read speed..."
hdparm -t /dev/sda > read_speed.txt
read_speed=$(cat read_speed.txt | awk '/Timing buffered/ {print $5}')
echo "Read speed: $read_speed MB/s"
rm read_speed.txt

# Run write speed test using dd command
echo "Testing write speed..."
write_speed=$(dd if=/dev/zero of=testfile bs=1M count=1024 conv=fdatasync 2>&1 | awk '/bytes/ {print $8 " " $9}')
echo "Write speed: $write_speed"
rm testfile

# Calculate rating based on read speed
read_rating=""
if (( $(echo "$read_speed < 200" |bc -l) )); then
   read_rating="Poor"
elif (( $(echo "$read_speed < 400" |bc -l) )); then
   read_rating="Average"
else
   read_rating="Excellent"
fi

# Calculate rating based on write speed
write_rating=""
if (( $(echo "$write_speed < 50" |bc -l) )); then
   write_rating="Poor"
elif (( $(echo "$write_speed < 100" |bc -l) )); then
   write_rating="Average"
else
   write_rating="Excellent"
fi

# Print ratings to console
echo "Read speed rating: $read_rating"
echo "Write speed rating: $write_rating"
 
Сверху