Thursday, March 23, 2023

Checking Disk Read & Write Speed in Linux

We are going to use 2 tools for this, one is called hdparm to test read speed, and the second one is called dd, to test write speed.

First, install hdparm
$ sudo apt install hdparm -y

Then, get the disk name. The name of the disk in below example is /dev/sda.
$ lsblk







Test read speed using hdparm. -t option is to record the timing for the read process. In below example, the read speed is around 700MB/sec.
$ sudo hdparm -t /dev/sda








To test write speed, we will use dd command. dd will write a 1M file called speedtest.img to disk, and the "oflag=direct" option will make dd use direct IO, skipping any filesystem cache. dd will show the disk write speed after it finishes writing the file to disk. In below example, the write speed is 100MB/s.
$ dd if=/dev/zero of=speedtest.img bs=1M count=1 oflag=direct


No comments:

Post a Comment