How to Benchmark Hard Disks using hdparm and dd (linux)


We are going to benchmark reads and writes for a hard disk in a linux based system, using dd and hdparm tools.

IMPORTANT: We assume our device to test is /dev/sda (choose carefully yours, specially for writing tests.)


Info about Hard Disk


Display basic settings from the drive:
$ sudo hdparm -v /dev/sda

/dev/sda:
multcount = 16 (on)
IO_support = 1 (32-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 38913/255/63, sectors = 625142448, start = 0



Get detailed information directly from the drive:
$ sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
Model Number: TOSHIBA
Serial Number: 91XXXXXXX
Firmware Revision: GT001U
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Standards:
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 625142448
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
device size with M = 1024*1024: 305245 MBytes
device size with M = 1000*1000: 320072 MBytes (320 GB)
cache/buffer size = 8192 KBytes
Form Factor: 2.5 inch
Nominal Media Rotation Rate: 5400
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Advanced power management level: 254
DMA: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
....


READ benchmark


$ sudo hdparm -Tt /dev/sda

/dev/sda:
Timing cached reads: 5278 MB in 2.00 seconds = 2639.99 MB/sec
Timing buffered disk reads: 234 MB in 3.00 seconds = 77.90 MB/sec



WRITE benchmark


We write to a file "/tmp/output" because device is already mounted in /
If not we could write directly to the device /dev/sdX

$ dd if=/dev/zero of=/tmp/output conv=fdatasync bs=4M count=100; rm -f /tmp/output
100+0 records in
100+0 records out
419430400 bytes (419 MB) copied, 8.73378 s, 48.0 MB/s


fdatasync forces write to flush out to hard disk.

Change bs and count values to suit you.


REFERENCE


$ man hdparm

$ man dd

https://wiki.archlinux.org/index.php/Benchmarking/Data_storage_devices

http://askubuntu.com/questions/87035/how-to-check-hard-disk-performance

https://wiki.archlinux.org/index.php/hdparm