HowTo: Linux Check IDE / SATA Hard Disk Transfer Speed

Posted on in Categories CentOS, Debian Linux, Gentoo Linux, Howto, Linux, RedHat/Fedora Linux, Suse Linux, Ubuntu Linux, UNIX last updated October 7, 2007

So how do you find out how fast is your hard disk under Linux? Is it running at SATA I (150 MB/s) or SATA II (300 MB/s) speed without opening computer case or chassis?

You can use the hdparm command to check hard disk speed. It provides a command line interface to various hard disk ioctls supported by the stock Linux ATA/IDE/SATA device driver subsystem. Some options may work correctly only with the latest kernels (make sure you have cutting edge kernel installed). I also recommend compiling hdparm with the included files from the most recent kernel source code.

Measure Hard Disk Data Transfer Speed

Login as the root user and enter the following command:
$ sudo hdparm -tT /dev/sda
OR
$ sudo hdparm -tT /dev/hda
Sample outputs:

/dev/sda:
 Timing cached reads:   7864 MB in  2.00 seconds = 3935.41 MB/sec
 Timing buffered disk reads:  204 MB in  3.00 seconds =  67.98 MB/sec

For meaningful results, this operation should be repeated 2-3 times. This displays the speed of reading directly from the Linux buffer cache without disk access. This measurement is essentially an indication of the throughput of the processor, cache, and memory of the system under test. Here is a for loop example, to run test 3 time in a row:
for i in 1 2 3; do hdparm -tT /dev/hda; done
Where,

  • -t :perform device read timings
  • -T : perform cache read timings
  • /dev/sda : Hard disk device file

To find out SATA hard disk speed, enter:
sudo hdparm -I /dev/sda | grep -i speed
Output:

	   *	Gen1 signaling speed (1.5Gb/s)
	   *	Gen2 signaling speed (3.0Gb/s)
	   *	Gen3 signaling speed (6.0Gb/s)

Above output indicate that my hard disk can use 1.5Gb/s, 3.0Gb/s, or 6.0Gb/s speed. Please note that your BIOS / Motherboard must have support for SATA-II/III.

dd Command

You can use the dd command as follows to get speed info too:

dd if=/dev/zero of=/tmp/output.img bs=8k count=256k
rm /tmp/output.img

Sample outputs:

262144+0 records in
262144+0 records out
2147483648 bytes (2.1 GB) copied, 23.6472 seconds, 90.8 MB/s

The recommended syntax for the dd command is as follows

dd if=/dev/input.file  of=/path/to/output.file  bs=block-size  count=number-of-blocks  oflag=dsync
 
## GNU dd syntax ##
dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
 
## OR alternate syntax for GNU/dd ##
dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync

Sample outputs from the last dd command:

1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 4.23889 s, 253 MB/s

GUI Tool

You can also use disk utility located at System > Administration > Disk utility menu.

Read Only Benchmark (Safe option)

Then, select > Read only:

Fig.01: Linux Benchmarking Hard Disk Read Only Test Speed
Fig.01: Linux Benchmarking Hard Disk Read Only Test Speed

The above option will not destroy any data.

Read and Write Benchmark (All data will be lost so be careful)

Visit System > Administration > Disk utility menu > Click Benchmark > Click Start Read/Write Benchmark button:

Fig.02:Linux Measuring read rate, write rate and access time
Fig.02:Linux Measuring read rate, write rate and access time

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

31 comment

    1. “sudo hdparm -I /dev/sda | grep -i speed” does not show actual speeds which your hardware is capable. As it reports SATA and SATAII speeds even on my laptop which does not have a single SATA port.

  1. in serial ata,how fast datatrnsfer?how it is possible?what is the main difference between PATA & SATA.i want deatails about SATA harddisk communication to motherboard

  2. you have to make sure you know what you’re monitoring. this tool looks like it’s measuring the transfer speed to the raw disk which doesn’t really have much value other than to verify your raw speeds are reasonable.

    in reality, your disk has a file system and writing to a formatted disk will always be slowly, sometimes significantly slower depending on whether you’re reading/writing large sequential ones or small one. your blocksize can also make a dig differences. btw – if you’re doing random I/O expect a significant drop in numbers.

    graphics are good to see, and I like them as well, but for simple benchmarking I like to see numbers and collectl makes that real easy to do. some like iostat but the output can be very difficult to read, especially if you’re taking samples every second which IS a good thing to do if you want to see exactly what’s going on.

    -mark

    1. This is a great comment. conv=fdatasync shows more realistic speeds. Running dd without this conv will only tell part of the story and a false sense of performance. On a database server or other server with constant disk activity, you want to know the performance *including* including the physical write time.

      For me, running dd without `conv=fdatasync` shows double the write speed.

  3. What would be considered terrible? I’m trying to figure out why all of my applications (skype, firefox) are running at 100% and am wondering if my HDD is dying. I’m getting results like the following on my laptop
    /dev/sda:
    Timing cached reads: 512 MB in 2.00 seconds = 255.74 MB/sec
    Timing buffered disk reads: 102 MB in 3.05 seconds = 33.41 MB/sec

    …which is /dev/sda:
    Timing cached reads: 6678 MB in 2.00 seconds = 3342.16 MB/sec
    Timing buffered disk reads: 358 MB in 3.01 seconds = 118.94 MB/sec
    much worse then my desktop

  4. [email protected] ~ $ sudo hdparm -tT /dev/md0
    [sudo] password for boot:

    /dev/md0:
    Timing cached reads: 24454 MB in 2.00 seconds = 12239.97 MB/sec
    Timing buffered disk reads: 1886 MB in 3.00 seconds = 628.60 MB/sec

    Arf! Arf!

  5. Script to get sata link speeds and display in readable format.

    #!/bin/sh
    for i in `grep -l Gbps /sys/class/ata_link/*/sata_spd`; do
     echo Link "${i%/*}" Speed `cat $i`
     cat "${i%/*}"/device/dev*/ata_device/dev*/id | perl -nE 's/([0-9a-f]{2})/print chr hex $1/gie' | echo "    " Device `strings` | cut -f 1-3
    done
  6. Four years later…

    /dev/sdc:
    Timing cached reads: 24932 MB in 2.00 seconds = 12478.39 MB/sec
    Timing buffered disk reads: 4260 MB in 3.00 seconds = 1419.88 MB/sec

Leave a Comment