From Fedora Project Wiki

  1. !/bin/bash

source /mnt/tests/kernel/storage/include/bash_modules/lxt/include.sh || exit 200 tlog "running $0"

function install_fio() {

       git_url=git://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git
       tok yum install libaio-devel zlib-devel -y
       tok git clone $git_url
       tlog "INFO: Installing Fio"
       tok "cd fio && git checkout fio-2.14 &&./configure  > /dev/null 2>&1 && make  > /dev/null 2>&1 && make install > /dev/null 2>&1"
       tok which fio
       if [ $? -ne 0 ]; then
               tlog "FAIL: Fio not succesffully installed"
               exit 1
       fi
       tlog "INFO: Fio succesfully installed"

}


mkdir -p /tmp/mnt/ multipath -F sleep 5 trun " dmsetup remove_all" sleep 5

  1. dev=$(fdisk -l |tail -10 |grep " /dev/sd"|cut -b 6-13)

ls /dev/sd* > dev_txt declare -a arr declare -a disk_list a=lsblk |grep disk |awk '{print $1}' arr=($a) >disk_txt for var in ${arr[@]} do num=cat dev_txt |grep "$var"|wc -l if [ $num = 1 ];then

  1. echo " $var is a disk,have no fenqu"
  2. echo "$var"

echo "$var" >> disk_txt fi done a=cat disk_txt arr=($a) echo "have ${#arr[@]} HDD don't partition" dev=/dev/"${arr[0]}" dh="${arr[0]}" echo "fenqu $dh" echo "$? $dev" fdisk "$dev" <<eof n p 1


w eof partprobe lsblk

  1. device=$(fdisk -l |tail -1|cut -d ' ' -f 1)

sd=cat /proc/partitions |grep "$arr"|tail -1|awk '{print $4}' device="/dev/$sd" echo " $? $device partition"

install_fio tlog "fio on device rand rw" (fio -filename=$device -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop) || exit 1 tlog "fio on device queue write" (fio -filename=$device -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest) || exit 1 tlog "fio on device randwrite" (fio -filename=$device -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest) || exit 1 tlog "fio on device randread" (fio -filename=$device -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest) || exit 1

sync sleep 5

which mkfs.xfs

  if [ $? -eq 0 ]; then
       FILESYS="xfs"
  else
       FILESYS="ext4"
  fi
       (mkfs -t $FILESYS $device) || (mkfs -t $FILESYS -f $device)
       if [ $? -ne 0 ]; then
               tlog "Create $FILESYS on $device failed"
               return 1
       fi
       tok mount $device /tmp/mnt
       if [ $? = 0 ];then
               tlog "run fio on fs randrw "
               (fio -filename=/tmp/mnt/date -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=200G -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop) || exit 1
               tlog "fio on fs queue write"
               (fio -filename=/tmp/mnt/date  -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest) || exit 1
       fi

sync sleep 5

umount $device partprobe fdisk "$dev" <<EOF d w EOF tend