测试硬盘速度的一种方法是使用hdparm命令:
# hdparm -Tt /dev/sda
输出:
/dev/sda: Timing cached reads: 7216 MB in 2.00 seconds = 3615.89 MB/sec Timing buffered disk reads: 288 MB in 3.00 seconds = 95.87 MB/sec
我们也可以通过复制文件的方式来大致测试硬盘的速度。
运行以下linux命令几秒钟并使用CTRL+C中断即可创建一个文件:
$cat /dev/zero > myfile.zero
speed_test.sh:
#!/bin/bash # USAGE: # ./speed_test.sh /path/to/my/file /path/to/destination number_of_tests NUM_TESTs=$3 SUM=0 for i in$(seq 1 $NUM_TESTs); do REC=`ddif=$1 of=$22>some_random_file_ ; catsome_random_file_|cut -d " " -f8 |tail -1` SUM=`echo$SUM + $REC|bc` done RESULT=`echo$SUM/$NUM_TESTs|bc|awk'{ str1=str1./speed_test.sh /mnt/sdb1/ubuntu.iso /mnt/sda1/ubuntu.dd 3}END{ print str1 }'` echo$RESULT MB/s #clean up rmsome_random_file_ rm$2
54 MB/s
输出:
##代码##日期:2020-07-07 20:54:29 来源:oir作者:oir