Run the following command as root to install on Debian-based distribution:
sudo apt-get install hdparm pv
Or this one for a distribution based on RPM:
yum install pv hdparm
Our first reading test consists of reading all the data on a hard drive (/dev/sda), then measure the flow through the pv utility:
cat /dev/sda | pv -r > /dev/null
I get a transfer rate of 491MB/s. But the result is not very stable and changes regularly.
A second method, much more precise, is to use hdparm. The options used allow to know the reading speed from the disk cache (-t) and from direct access (-T).
An example of use:
hdparm -t -T /dev/sda
Timing cached reads: 5084 MB in 2.00 seconds = 2542.83 MB/sec
Timing buffered disk reads: 1368 MB in 3.00 seconds = 455.93 MB/sec
To test the write speed, you can simply use the dd command. This will create a 1 GB file (1024 block 1 MB = 1 GB) and indicate the transfer rate when finished. Note that here, use the “fdatasync” that can force the synchronization of data between memory and disk.
dd if=/dev/zero of=/tmp/test.data bs=1M count=1024 conv=fdatasync
rm -f /tmp/test.data
I get a rate of 151 MB/s
1073741824 bytes (1.1 GB) copied, 7.10035 s, 151 MB/s