Wednesday, February 10, 2010

Linux Hard Drive Performance measurements

Many people trust vendor specs, moreover they trust hard drive speed, disk controller speed and so on. However, reality is that you will never get those specs when you set up the hardware. Why? Vendors test their hardware on special environments, with specific combination of hardware.

I was trying to set up a server with fast access to hard drives so I did a little research of how to test different configuration of hard drives. These are my findings:

Note: All these tests should be executed several times. The real results are affected by hard drive cache, controller cache, and operative system cache.

1- (Read Speed) hdparm -t /dev/sda
This is a very well known command that It can give you the max read speed (sequential).

2- (Write Speed) dd count=1k bs=10M if=/dev/zero of=/data/test.img
This is another well known command that It can give you an average of writes.
This command creates a 10G file and measure the speed.

3- (Write speed) This people created a C program that logs write speed.
#gcc -O2 dskwtst.c -o dskwtst

(Compiling probably you would get an error)

dskwtst.c: In function âmainâ:
dskwtst.c:32: warning: incompatible implicit declaration of built-in function âexitâ

This error is only a warning so it should not affect results.

#./dskwtst > /data/ouputfile 2> ./log

The command will create a file on /data/ and it will send the results to log.

4- (Random access)This guy created a C program that can measure the seek time of the hard drive.

#gcc -O2 seeker.c -o seeker
#./seeker /dev/sda

Enjoy it ...


  1. Aside from the hdparm command, none of these require root authority and they should NOT be performed while logged in as root or executing within an su(1) environment.

    In addition, interested readers will Google for it, but I like bonnie++ and iozone, each for different reasons. With a RHEL5 kernel (or similar) you can also use SystemTap to monitor activities anywhere within the system. Once such example is blktrack (I think that's the name).


  2. @ Carlos Gomez
    "This error is only a warning so it should not affect results."

    What does that mean? Error != Warning

  3. bonnie++ is nice but it is out of date...iozone is also really great, easy to install (available on repos), however it is a little complex. I suggest these tools because are really easy to use and they can give you an idea of how a new HW is behaving.