Posted by CANbike on Fri, 18 Jan 2013

Linux: Storage Device Benchmarking

Linux contains several input/output benchmarking tools. The following are two commands that I commonly use to gauge performance of storage devices.

Read Benchmark

The command hdparm with the -t switch can be used to time sequential reads.

For example,

hdparm -t /dev/sdX

where according to the man page, the -t option

Perform timings of device reads for benchmark and comparison purposes. For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system (no other active processes) with at least a couple of megabytes of free memory. This displays the speed of reading through the buffer cache to the disk without any prior caching of data. This measurement is an indication of how fast the drive can sustain sequential data reads under Linux, without any filesystem overhead. To ensure accurate measurements, the buffer cache is flushed during the processing of -t using the BLKFLSBUF ioctl.

This will output the sequential read speed of /dev/sdX.

Write Benchmark

dd can be used to time sequential reads. However, it must be run from a mounted partition of the device in question.

For example,

dd if=/dev/zero of=temp bs=100M count=10 conv=fdatasync,notrunc


if=/dev/zero - reads from file a special *nix file that provide as many null characters as read from it.
of=temp - writes to file "temp"
bs=100m - read and write 100M bytes at a time
count=10 - copy 10 input blocks
conv - convert the file as fdatasync, notrunc
fdatasync - physically write output file data before finishing
notrunc - do not truncate the output file 

This will write 100MB of zeros at a time, for 10 counts to file temp. Final file size will be 1000MB.