The purpose of this tutorial is to describe some simple hard drive speed tests that you can perform using your Linux system and the command line tool hdparm.
hdparm tool is an easy to use tool to quickly assess your hard drive’s speed. When performing speed tests, hdparm disregards the file system currently in use and writes to the raw device instead.
The actual real read/write speed of your hard drive will be slightly slower and dependent on the file system you decide to format it with. In any case, the hdparm tool should provide you with a solid overview of your hard drive’s speed.
In this tutorial, you will see how to install hdparm on major Linux distos and then use the command to perform a speed test.
In this tutorial you will learn:
- How to install hdparm on major Linux distros
- How to perform speed test of HDD with hdparm
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
|Conventions||# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Install hdparm on major Linux distros
In order to check the speed of a storage device, you’ll need to install the
hdparmsoftware package. This software is available in official repositories on nearly all Linux distributions.
On some systems, hdparm may already be installed by default. But if not, you can use the appropriate command below to install the program with your system’s package manager.
$ sudo apt install hdparm
$ sudo dnf install hdparm
$ sudo pacman -S hdparm
After it’s installed, check out the examples below to see how to run the hdparm command.
Hard drive hdparm speed test
The only thing you need to know before getting started is the path to the drive’s device file that you wish to test. In the examples below, we will be testing the speed of a hard drive at path
/dev/sda. You can see a list of all your connecte storage devices and their corresponding device paths with the following command:
# fdisk -l
- The first and most basic test is a transfer speed test with the
-toption. Please note that all tests should be run multiple times and average time should be calculated to get more accurate results.
$ sudo hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 1570 MB in 3.00 seconds = 522.76 MB/sec
- Adding the
--directoption to our command syntax will perform another transfer rate, but this time bypassing the hard drive’s buffer cache memory, and thus reading directly from the disk.
$ sudo hdparm -t --direct /dev/sda /dev/sda: Timing O_DIRECT disk reads: 2900 MB in 3.00 seconds = 966.60 MB/sec
- In the next example, we will instruct hdparm to read data from the second half of the disk. In our case, the hard drive size is 40 GB, meaning we will instruct hdparm to read data starting at 20 GB.
$ sudo hdparm --offset 20 -t /dev/sda /dev/sda: Timing buffered disk reads (offset 20 GB): 1640 MB in 3.00 seconds = 546.27 MB/sec
- To obtain cached reads, run the following Linux command.
$ sudo hdparm --offset 20 -T /dev/sda /dev/sda: Timing cached reads: 7074 MB in 1.99 seconds = 3546.33 MB/sec
- Add the
-voption to your command to increase verbosity and gain some more helpful output from hdparm.
$ sudo hdparm -tv /dev/sda /dev/sda: multcount = 128 (on) IO_support = 1 (32-bit) readonly = 0 (off) readahead = 256 (on) geometry = 5221/255/63, sectors = 83886080, start = 0 Timing buffered disk reads: 1580 MB in 3.01 seconds = 525.58 MB/sec
In this tutorial, we saw how to measure the speed of a hard drive or other type of storage device in Linux. This is facilitated by the hdparm command, which gives us a quick and easy way to determine the speed of any connected storage device. The hdparm commands comes with a lot of options, as seen here, but more can be found within the man pages.