RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Bash script to test hard drive transfer speed

Here is a small bash script to test a hard drive transfer speed. It should be take as an approximation. The speed value is taken from Linux dd command output. One way to test your hard drive speed is to use hdparm command:

# hdparm -Tt /dev/sda

OUTPUT:

/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

However, in this case the hdparm command is accessing raw hard drive, disregarding all partitions and file systems. The weakness of the following script is that it does not take source hard drive reading speed into consideration, however it is accurate when measuring transfer speed between two hard drives or speed between two nodes over the network using NFS or samba. Run the script with 3 arguments, source file, destination file and number of runs to make an average:

NOTE: If you do not have a file to copy simply create one by running a following command for couple seconds and interrupt with 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=`dd if=$1 of=$2 2> some_random_file_ ; cat some_random_file_ | cut -d " " -f8 | tail -1`

SUM=`echo $SUM + $REC | bc`

done

RESULT=`echo $SUM / $NUM_TESTs | bc | awk '{ str1=str1 $0 }END{ print str1 }'`

echo $RESULT MB/s

#clean up
rm some_random_file_
rm $2

./speed_test.sh /mnt/sdb1/ubuntu.iso /mnt/sda1/ubuntu.dd 3

OUTPUT:

57 MB/s

Share this linux post:

Submit Bash script to test hard drive transfer speed in Delicious Submit Bash script to test hard drive transfer speed in Digg Submit Bash script to test hard drive transfer speed in FaceBook Submit Bash script to test hard drive transfer speed in Google Bookmarks Submit Bash script to test hard drive transfer speed in Stumbleupon Submit Bash script to test hard drive transfer speed in Technorati Submit Bash script to test hard drive transfer speed in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download