How to test disk speed in Linux using commands?

0 Comments

Reading Time: 4 minutes

use commands to test disk speed

I assume the reason you are on this page is that you want to learn how to test disk speed in Linux. Instead of obtaining a single number as ‘speed’, we are interested in measuring what better represents the real-world speed of storage devices such as Hard Disk Drive (HDD), Solid State Drive (SSD), SD cards, and USB memory stick/flash drives, etc. Every storage device provides a certain level of efficiency at a certain financial cost.

As a case in point, HDDs are rather more affordable but also are only appropriate for transferring bulk files to/from disks which has a sequential read/write pattern as opposed to having a random read/write pattern. Accordingly, not every speed measurement method may be good for every disk.

Linux VPS Hosting

Get yourself an economy or premium Linux VPS for hosting your website or remote desktop, at the cheapest price out there. VPS Running on Linux KVM for increased efficiency and working on powerful hardware with NVMe SSD storage for increased speed.

Check Out Linux VPS Plans
Linux VPS Hosting

In this article, I will walk you through how to use dd, hdparm utility, and fio method to test disk speed in Linux. Also, I will be elaborating on why the first two mentioned approaches provide rather poor estimates in certain use cases.

Test disk speed in Linux using commands

Well, there are multiple approaches to do this and you can use any of them.

Test Disk Speed in Linux using dd

dd is a Linux built-in tool and can be used to generally indicate how much time it takes to complete an operation. For obtaining a single digit as Write speed of the disk, you are supposed to run the following command and the output will look like the one in the picture below.

use dd to test disk speed

Also, you may use the two following commands to first delete the cached-in temporary file created in a buffer by our previous command, and then to measure the Read speed of the disk.

test disk speed in linux

If you run the above commands repeatedly, you will be displayed multiple results. To extract a better result, you may average 4, by the rule of thumb, measurements. Yet, the final result is far off the experience a user might have with the disk.

Test your HDD, SSD Read Speed using Hdparm

hdparm is another Linux command-line tool that can be used to derive a sequential read speed of a storage device.

First, you need to install hdparm on your Linux, and following that you may run a command to get a digit as the reading speed of the disk.

To install hdparm on CentOS, RHEL distributions:

test disk speed in linux via hdpram

To install hdparm on Mint, Ubuntu, Debian:

Execute the command below, and the output will look like this:

Better Test Disk Speed in Linux via fio

The aforementioned benchmarks only account for sequential read/write speed tests. In practice, read/write interaction with the disk more often than not follows a random access pattern. This unqualifies sequential-based methods from estimating the real-world write/read speed of a disk. To overcome this shortcoming, fio has been developed.

Linux VPS Hosting

Get yourself an economy or premium Linux VPS for hosting your website or remote desktop, at the cheapest price out there. VPS Running on Linux KVM for increased efficiency and working on powerful hardware with NVMe SSD storage for increased speed.

Check Out Linux VPS Plans
Linux VPS Hosting

Please note that speed is basically calculated in MBps. In this method, IOPS (Input/Output operations Per Second) is introduced for the sake of convenience. IOPS is just the same MB/s multiplied by BlockSize/1024, i.e. a bigger digit with the same unit.

fio, which is not available on Linux by default, can be unpacked from the package with that name. To install this utility:

Let’s first run a basic test with the following specifications:

Data volume: 250MB, Reads: 80% of the whole data, Write: 20% of the whole data

Block Size: 4k, Disk: SSD, Performance Indicators: IOPS and MB/s, Type of test: Random read/write

Test disk speed using fio

The results are as follows:

Now let’s run the exact same commands for an HDD:

This random write speed test on HDD shows weaker performance than that of an SSD. Overall, an SSD outperforms an HDD in random access usage and that is why it is more recommended.

The advantage of fio is that you can go for sequential reads and writes tests as well. To do that for our HDD, we will need to type in seqread and seqwrite for – – readwrite.

Conclusion

Linux readily has a built-in tool named dd for measuring disk speed, which is particularly efficient for HDDs speed test as the hard drives are commonly used for large sequential writes and read. However, dd and also hdparm are two easy-to-use methods to test disk speed in Linux, they only address sequential access patterns. In other words, they miserably fail to provide a decent speed estimate of disks like SSDs that are used for both large and small files.

Linux VPS Hosting

Get yourself an economy or premium Linux VPS for hosting your website or remote desktop, at the cheapest price out there. VPS Running on Linux KVM for increased efficiency and working on powerful hardware with NVMe SSD storage for increased speed.

Check Out Linux VPS Plans
Linux VPS Hosting

This is because an SSD can have a random read and write usage. fio is a more reliable utility as it mimics the real-world condition for speed test and runs a disk speed test for both random access and large sequential writes and reads. So the next time you purchase a service, make sure you rightly test the throughput to and from your disk so that you do not experience latency.

0
0

Comments

Leave A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *