One of the important factors that determine how fast your computer works is the speed of your hard drive. Generally, the faster the CPU can read and write from your drive, the faster the applications can run. Having a larger RAM can often help with the speed of the applications, but hard disk speed also plays a major part.
Most times it is also important to test the speeds to make sure that the hard disks are working optimally. If you find that your read or write speed are not optimal then you can use various utilities to fine tune the performance.
Read speed of a disk is the speed at which data can be read and loaded into the memory. The faster the applications can read the data, the faster they can load up and run.
The Linux utility that allows you to quickly time the read speed is hdparm. It is actually a utility that allows you to get and set various different hard disk parameters. This means that it can be used to fine tune and optimize your hard disks as well.
hdparm has several command line options. The options that lets you perform device read timings are -t and -T. The -t option lets you perform device read timings, while the -T lets you perform read timings from the cache.
bash$ hdparm -tT /dev/sda
The last argument, /dev/sda in the above example is the device.
You should perform these tests a meaningful number of times, usually 3 to 5 times and then average out the value to get a good estimate of the speed.
Write speed is the speed at which the application can write to your hard disk. Usually write speeds are much slower than the read speeds of a disk.
hdparm does not have the ability to find the write speed. You will have to use another command line utility called dd to find the write speed. dd command can be used to write random bytes of a specific size to the disk which can then be measured for speed.
bash$ dd if=/dev/zero of=/tmp/sample.bin bs=8k count=128k
Creating larger files will give a better estimate about the write speed than when writing a small file. Smaller files usually write to the disk much faster than large files that usually need repeated block writes. A file size of 1GB is usually appropriate and be sure to run it at least 3 times to get a good estimate.
Apart from the command line utilities mentioned above, there are also a couple of other utilities that can perform speed tests on the mounted disk. It is quite possible that these are not part of your Linux distro and you might have to install them separately.
bonnie++ is a powerful tool with quite a bit of options. You can check out all the options by just running the bonnie utility without any command line options.
bash$ bonnie++ -d /home/dave/temp/bonnie -s 12g -x 5 -u dave
-s option denotes the size of the file to size. It is recommended that you use double the size of your RAM.
piozone is another utility with some options. The application itself is sparsely documented so you will need to play around with it. The generic format of the command is
piozone [-dvh] [-t <seconds>] <device> [<interval>]
bash$ piozone -v /dev/sda 10
This will perform and print out read transfer rates where the reads are done linearly and also for random access reads.
Comparison and Benchmarks
It is not really much use unless you have a good idea as to what the expected values are. It is a good thing to have an idea as to what the expected value of your hardware is. This will give you an idea whether the machine is performing optimally. Compare your speeds to the benchmark results that you can find for your specific hard disk type and model. Some of the sites that you might be able find these are at hard drive benchmark, Toms’ hardware or on the website of the manufacturer.