Linux – Disk Speed

Reading Time: 2 minutes

Last Updated: 5/9/2024

I use this last bit too often not to have it posted. Having said that I had this in notes somewhere. As of today this posting at least ensures that I have it on the site. Hopefully I will remember.

At some point you are going to want to test your disk speeds, your disk I/O. You are going to want to generate some metrics to help validate if you have a problem or not. Or, at the very least where you stand. A standard such test could be done simply by using one of the earliest created tools – dd.

Example:

dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync

The following are actual tests.

Example 1: Home Brew storage system – badly maintained – using actual disks (not SSD)

root@node3:/home/ubuntu# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 160.346 s, 6.7 MB/s


Example 2: A more respectable production site.

1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.7785 s, 604 MB/s


Of the two you will note a massive discrepancy.

Testing Server Latency: Nature of the test using smaller block size

dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

Don’t forget to delete temporary space you created.

rm -v -i /tmp/test1.img

Using HDparm: maybe easier if you have it installed.

Using “hdparm” makes this a little easier. It might be worth it to do a “man hdparm” and glance through the explainations.

Please note
* -T cached reads.
* -t buffered reads.

Example 1: Back to.

root@node3:# hdparm -t /dev/sda2

/dev/sda2:
 Timing buffered disk reads: 198 MB in  3.00 seconds =  65.98 MB/sec

Example 2: Example system revisited again (for comparison)

/dev/sda2
 Timing buffered disk reads: 1578 MB in  3.00 seconds =  525.55 MB/sec

And using them both will give you a side-by-side comparison.

root@node3:# hdparm -Tt /dev/sda2

/dev/sda2:
Timing cached reads:   5246 MB in  1.98 seconds = 2643.64 MB/sec<br> Timing buffered disk reads: 220 MB in  3.00 seconds =  73.32 MB/sec


Example: on AWS EC2. For comparison. This is not an advertisement or cliam. This is merely a reporting of a point in time in not spoken of circumstances so for all I know the phases of the moon might also be effecting this.

root@ip-x-x-x-x:/home/ubuntu# hdparm -t /dev/xvda1

dev/xvda1:
HDIO_DRIVE_CMD(identify) failed: Invalid argument
Timing buffered disk reads: 244 MB in 3.00 seconds = 81.27 MB/sec


EXAMPLE: From AWS Lightsail. Not intended to showcase expectations. But is an actual metric captured on a a system today 5/8/2024.

root@ip-x-x-x-x:/# ./usr/sbin/hdparm -t /dev/xvda1

/dev/xvda1:
 Timing buffered disk reads: 252 MB in  3.00 seconds =  83.90 MB/sec<br>root@ip-172-26-4-203:/# 


Reference:
* https://www.cyberciti.biz/faq/howto-linux-unix-test-disk-performance-with-dd-command/

This entry was posted in Storage. Bookmark the permalink.