How to test your hard disk speed in Linux

Two of the most popular command line tools you can use to test your storage drive performance are hdparm or dd.

Hdparm is a nice tool focused specificaly on storage drives information and benchmarking. With hdparm you can test the read performance by running:

sudo hdparm -tT /dev/sda

Replace /dev/sda with the drive you want to test. If you are not sure you can use lsblk to list the available storage drives.

The two flags -t and -T specify device read test and cache read test.

The result should be sometehing like this:

/dev/sda:
Timing cached reads: 16656 MB in 2.00 seconds = 8328.37 MB/sec
Timing buffered disk reads: 2364 MB in 3.00 seconds = 787.92 MB/sec

To benchmark the write performance you can use dd:

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

The result should show you the write speed:

262144+0 records in
262144+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 5.4854 s, 392 MB/s

Keep in mind that benhcmarking is not always relevant to real life performance.