BASH Storage Check Script and Load Generator

Linux Random

Sometimes it is helpful just to get a script running on a machine to generate some disk IO load. I use this for two main reasons, one is during the testing or proving of a storage platform in terms of its availability during a fail-over or maintenance situation (e.g. it’s storage processors), the other is to generate some random storage IO to see performance impact (often with multiple machines at once).

The script is very simple, just put it onto a Linux machine, add execute permissions with “chmod u+x” and then run with the command, where in this case “/tmp/test” is the location where the script will generate a load of random test files as it runs.

check_disk /tmp/test

The script is as follows:

#!/bin/bash


nfsv3_path=$1

while :
do
        date

        for n in {1..1000}; do
          echo -n "Creating a random file called random.img."$n" in "$nfsv3_path"....."
          dd if=/dev/urandom of=$nfsv3_path/random.img.$n count=100 bs=8K
        echo "Done!"
done
        sleep 1
        echo "Deleting the random files...."
        rm $nfsv3_path/random.img.*

        sleep 1
done

Leave a Reply

Your email address will not be published. Required fields are marked *