#!/bin/bash
# Simple script to test speed of hdd
# by using dd and /dev/zero and /dev/null
# @author Julius Beckmann
# @url http://juliusbeckmann.de/

# Config
FILE_TMP="tmpfile_hdd-speed-test-1gb.tmp"
FILE_TMP_SIZE_MB="1000"

# Header
echo "------------------------------"
echo "--- Simple hdd speed test  ---"
echo "---  by Julius Beckmann    ---"
echo "------------------------------"

# Write test
echo "[Info] Performing WRITE test"
dd if=/dev/zero of="$FILE_TMP" bs=1M count="$FILE_TMP_SIZE_MB" 2>&1 | grep --color=never "MB"
echo "[Info] Finished WRITE test"
echo "------------------------------"

# READ test
echo "[Info] Performing READ test"
dd if="$FILE_TMP" of=/dev/zero 2>&1 | grep --color=never "MB"
echo "[Info] Finished READ test"
echo "------------------------------"

# Clean up
echo "[Info] Removing tmp file"
rm -f "$FILE_TMP"
echo "------------------------------"

