Here is a shell script that you can use to test disk throughput using 1MB, 10MB, 100MB, 1000MB, and 10000MB:
#!/bin/bash
# Define variables for file sizes in MB
sizes=(1 10 100 1000 10000)
# Define a function to perform the disk throughput test
function test_disk_throughput() {
# Create a temporary file of the specified size
dd if=/dev/zero of=tempfile bs=1M count=$1 conv=fdatasync
# Measure the write speed of the temporary file
write_speed=$(dd if=tempfile of=/dev/null bs=1M count=$1 2>&1 | awk '/copied/ {print $8 " " $9}')
# Measure the read speed of the temporary file
read_speed=$(dd if=tempfile of=/dev/null bs=1M count=$1 iflag=direct 2>&1 | awk '/copied/ {print $8 " " $9}')
# Print the results
echo "File size: $1 MB"
echo "Write speed: $write_speed"
echo "Read speed: $read_speed"
echo ""
# Remove the temporary file
rm tempfile
}
# Loop through the file sizes and perform the disk throughput test for each size
for size in ${sizes[@]}; do
test_disk_throughput $size
done
Save the script to a file, for example disk_throughput_test.sh
, and make it executable by running chmod +x disk_throughput_test.sh
in the terminal. Then, you can run the script by typing ./disk_throughput_test.sh
in the terminal.
The script will create a temporary file of each size, measure the write and read speeds of the file, and print the results to the terminal. The dd
command is used to perform the disk I/O operations, and the awk
command is used to extract the relevant information from the output of the dd
command.