dd 硬盘测试脚本

#!/bin/bash
# create by xk
# date 2013-12-17

LOG_PATH=/home/xuekun

#init
>stat_W.log
>stat_R.log
#write
for Wm in {dsync,direct}
do
   echo ${Wm} >>stat_W.log
  #test
  #echo ${Wm}
  for((i=64;i<=1024;i+=i))
  do
    #init log file
    echo  >${LOG_PATH}/tempfile_W_${i}.log
    COUNT=$((2097152/${i}))
    dd if=/dev/zero of=/dev/sdb bs=${i}k count=${COUNT} oflag=${Wm} 2>${LOG_PATH}/tempfile_W_${i}.log
    echo -n ${i}----- >>stat_W.log
    grep GB tempfile_W_${i}.log |awk -F "," '{print $3}'|awk '{print $1,$2}' >>stat_W.log
    #echo "bs=${i}k------------coutn=${COUNT}"
  done
done

#read
for((i=64;i<=1024;i+=i))
do
    echo "direct" >>stat_R.log
    #init log file
    echo  >${LOG_PATH}/tempfile_R_${i}.log
    COUNT=$((2097152/${i}))
    dd if=/dev/sdb of=/dev/null bs=${i}k count=${COUNT} iflag=direct 2>${LOG_PATH}/tempfile_R_${i}.log
    echo -n ${i}--- >>stat_R.log
    grep GB tempfile_R_${i}.log |awk -F "," '{print $3}'|awk '{print $1,$2}' >>stat_R.log
    #echo "bs=${i}k------------coutn=${COUNT}"
done

你可能感兴趣的:(优化,测试,bash)