How to measure the data rate of hard drives on your computer or server

botond published March 2019, 11, Thu - 14:13 time

Content

 

Introductory

An important consideration when building a home computer or server is the data transfer rate of the machine's hard drives. If the speed of the drives in the machine is slow, it will severely degrade overall performance, even if the processor and / or RAM represent a stronger category. It is possible to measure this with all operating systems, it is not different with Linux systems. We test the speed of our HDD in several ways to get a more comprehensive picture of the status of our devices.

 

 

test Subjects

In this description, I will show the measurement of the speeds of the SSD in my desktop computer as well as the 1 TB traditional SATA2 in my same computer and the SATA2 winchesters in my old laptop.

For me, this topic is still relevant to the laptop as it is old and with the only SATA2 HDD in it, the machine is quite slow. Your processor is still tolerable, it includes a 2 GHz Intel Core2 Duo (T5870):

Processor info: Intel Core2 Duo cpu (t5870), 2 GHz

and 4 GB of RAM. For each of the operating systems I have installed over the years, I have found that the CPU is not fully utilized, the system is constantly waiting for the hard drive. When booting or starting programs, the HDD LED stays on while the CPU is far from the top. From this, it can be concluded that the winchester in the machine is the weakest link in the chain, so it is ripe for replacement. But before that, I still do his speed test out of curiosity so that I can compare it to the new one. The laptop currently has a Debian 10 (Buster) system with an LXQT desktop that I recently installed.

Since it only has a SATA2 interface, you would not be able to take full advantage of the speed of an SSD drive. So far, I have acquired an approx. A 1-year 512GB Toshiba HDD with a speed limit that still fits well in the SATA2 standard. Although, if you think about it, it might be better to have an SSD that doesn't run at max speed than a traditional mass storage device, but it will still develop ...

Otherwise, the speeds of SATA (1-3) standards are as follows:

  • SATA 1.0 => 1.5 Gbit / s, approx. 150 MB / s
  • SATA 2.0 => 3 Gbit / s, approx. 300 MB / s
  • SATA 3.0 => 6 Gbit / s, approx. 600 MB / s

 

Read useful hardware information

Discovering the SATA interface

First of all, it doesn’t hurt to be able to find out which version of SATA interface is available on your computer so we know what to expect in terms of maximum speeds. Of course, in the case of today's modern computer, this is no longer as important as when we are already using SATA Express, but it is also an important factor in an older computer, such as my laptop.

To query this, run as root dmesg with the appropriate filtering:

dmesg | grep -i sata | grep 'link up'

The command at my desktop gives the following output:

SATA check 1.

You can see here that a 6 Gbps SATA3 connection is available as well as compatible with older standards, so the maximum data transfer of a hard drive today on this machine can be around 600 Mbps.

In the laptop, the same command is given:

SATA check 2.

Here, only the SATA 2 standard can be used, from which we cannot expect more than a maximum transfer rate of about 300 Mbps.

Read hard disk data

You may even want to read the other data on the hard drive you want to measure to see if we can find useful information among them. To do this, install as root Smartmontools package:

apt-get install smartmontools

The package includes the ones we need smartctl command to read the exact data of our mass storage.

If you have more than one storage device in your machine, it is lsblk command to retrieve their achievements.

lsblk

Then run the smartctl command to retrieve data for the appropriate block device, for example:

smartctl -i /dev/sda

This is the only hard drive on my laptop, the above commands give this output:

Query HDD data

And so we can query all our drives to get even more information about our SATA devices.

Now that we know the version of the SATA ports on our machine and the details of our hard disks, we can start measuring.

 

 

HDD speed tests in many ways

There are many ways to measure the speed of hard disks on your machine or server in Linux. In this section we will look at some of these.

Measurement using the dd command

The first, and probably the most obvious, solution is a dd linux command which is also well suited for this purpose. The command is part of the base system, so you don't have to install anything, you can use it right away.

Writing tests

First, we measure the write speed by creating a file at the destination and filling it with null characters. If your machine has multiple hard disks, use the lsblk command to locate the mount point of the device you want to measure, so that the file is written to the correct location:

lsblk

Example output at my desk:

Example output of lsblk command

Here, the sda ​​device is the SSD drive that is mounted on the root file system, so the / tmp directory is a good place for me to test the write speed of the SSD.

Go to a similar directory that suits us,

cd /tmp

then run the dd command:

sync; dd if=/dev/zero of=./tesztfile bs=4k count=256k conv=fdatasync

First we run one sync a command that prints the previous content left in the write buffer before the measurement, e.g. delayed write data should not interfere with the measurement. So you can start writing the file and measuring it with a "clean sheet".

The dd command has the following options:

  • if = / dev / zero: Input: A / Dev / zero reading from a file yields as many null characters as the read operation requests (Wikipedia).
  • of = / test file.: Output file. This command uploads null characters. In this case, you create a file named testfile in the current directory.
  • bs = 4: Block size: 4 Kbyte. That is the size of the blocks.
  • count = 256: Number of iterations: 256 performs the write a thousand times with the above block size.
  • conv = fdatasync: This ensures that data is physically written to the disk until the command is executed. This ensures accurate measurement, no delayed writing, etc.

This specific command creates a round 1 GB file in the specified location and provides the following output:

262144+0 beolvasott rekord
262144+0 kiírt rekord
1073741824 bájt (1,1 GB, 1,0 GiB) másolva, 2,48485 s, 432 MB/s

The output speed is also displayed. In this case, it is 432 MB / second. This is normal for an SSD drive.

Of course, one piece of measurement is not worth much, we have to repeat it several times and then look at the average of the results.

In addition, the block size must be increased, as is customary in HDD tests, to get a more comprehensive picture of the speed of our hard drive. However, when measuring larger block sizes, we need to reduce the number of repetitions so that the write test does not take too long and our test file does not gain too much weight.

Accordingly, the result of a series of tests on the SSD drive with increasing block sizes and decreasing repetition numbers:

SSD speed test with dd command

And this is the test series for the traditional SATA2 HDD:

Conventional HDD write speed test with the dd command

And finally, the HDD tests on the laptop:

Conventional HDD iris speed test with dd command 2.

When performing speed tests with the dd command, always make sure that the read / write directory is physically located on the destination drive.

Reading tests

In the next step, we will read the test files created by reading the hard drives.

To do this, you must also go to the subdirectory of the corresponding hard disk and read the test file created there with the dd command.

The difference here is that our input will be the previously written test file and the output will be / dev / null, meaning we will write the file to "nothing" without any additional write to disk. As a result, it was used to empty the previously used write buffer sync command and disable delayed writing conv = fdatasync switches expire so we leave them. Instead, the sysctl command clears the read buffer before measurement. Accordingly, our sample command looks like this, so we can only run as root:

sysctl -w vm.drop_caches=3; dd if=./tesztfile of=/dev/null bs=4k count=256k

If we omitted the sysctl command, the dd command would measure the read time from the memory buffer, resulting in more Gbps. So we can achieve accurate measurement using this.

The test sequence on SSD with the usual increasing block sizes:

SSD read speed test with dd command

And on the SATA 2 storage in your laptop:

Conventional HDD read speed test with dd command

Tests need to be run multiple times and you need to look at the average of the results to get more accurate data.

Be sure to delete the test files at the end of the reading tests.

 

 

Measurement using the hdparm command

Hdparm is a disk management program that can be used to retrieve information, tests, and many parameters from our HDD devices. THE hdparm The linux command is not part of the Debian system by default, so your package must be installed:

apt-get install hdparm

You can now use it.

Get hardware information

You can also use hdparm to get all the technical information on your hard disk by running the following command:

hdparm -I /dev/sda

Where the / Dev / sda instead, we need to replace our block device to be scanned. Run this command to get useful information. For example, with my old HDD in my laptop, it gives you:

/dev/sda:

ATA device, with non-removable media
        Model Number:       Hitachi HTS545025B9A300                 
        Serial Number:      091002PB42081SC46M2L
        Firmware Revision:  PB2OC64G
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
        Used: unknown (minor revision code 0x0028) 
        Supported: 8 7 6 5 
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:    16514064
        LBA    user addressable sectors:   268435455
        LBA48  user addressable sectors:   488397168
        Logical/Physical Sector size:           512 bytes
        device size with M = 1024*1024:      238475 MBytes
        device size with M = 1000*1000:      250059 MBytes (250 GB)
        cache/buffer size  = 7208 KBytes (type=DualPortCache)
        Form Factor: 2.5 inch
        Nominal Media Rotation Rate: 5400
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Vendor, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 16
        Advanced power management level: 254
        Recommended acoustic management value: 128, current value: 254
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4 
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    DOWNLOAD_MICROCODE
           *    Advanced Power Management feature set
                Power-Up In Standby feature set
           *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
                Automatic Acoustic Management feature set
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    IDLE_IMMEDIATE with UNLOAD
           *    WRITE_UNCORRECTABLE_EXT command
           *    {READ,WRITE}_DMA_EXT_GPL commands
           *    Segmented DOWNLOAD_MICROCODE
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
           *    Phy event counters
           *    NCQ priority information
                Non-Zero buffer offsets in DMA Setup FIS
                DMA Setup Auto-Activate optimization
                Device-initiated interface power management
                In-order data delivery
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT Write Same (AC2)
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
Security: 
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
                frozen
        not     expired: security count
                supported: enhanced erase
        82min for SECURITY ERASE UNIT. 84min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000cca5e8c1ea51
        NAA             : 5
        IEEE OUI        : 000cca
        Unique ID       : 5e8c1ea51
Checksum: correct

A quick read test from the command line

The program provides a quick and easy read speed test as root from the command line:

hdparm -Tt /dev/sda

Read speed test with hdparm from command line

Timing cached reads a value after the cache reads followed by a Timing buffered disk reads and reads from normal disk. Of course, these values ​​are based on the average of multiple samples.

 

 

Reading test on graphical interface

If you have already installed the hdparm program, the program package also contains a graphical frontend that you can use to graph the results. Because it may vary from desktop to menu, which menu the program icon will drop out of or not at all, it's easier to run the boot command as root:

gnome-disks
I also had the hdparm graphical interface on both Debian 9 (Stretch) and LXDE, but I needed to install Debian 10 (Buster) + LXQT on my laptop. gnome-disk-utility package. If the above command is not found anywhere else, it is included in this package.

After the program starts, the following window will appear:

The main window of the gnome-disks graphics program

By default, this program is a disk partitioner such as Gparted, but it also has a speed part which is important here. First, select the disk device you want to measure on the left, then click the 3 stripe (hamburger) menu on the right of the header to use the speed test, and a drop-down will appear. In this, select Disc Performance Test ... option. The following window will appear:

Gnome-disks - Performance Test

Click here on the bottom left Start a performance test button. Another window will appear:

Gnome-disks - Performance Test Settings

Here at the top warns you to save your data for the write test, but you won't need it because no writing test! You can leave the two fields above as default values ​​and then Writing performance test checkboxból take out the check mark, as I marked in red!

Important!
This program only performs write tests when the drive is unmounted and then moves raw data on it, so our data on it may be lost! So now we're just doing a read test!
Be sure to uncheck the box marked with the red arrow.
If you still want to experiment, for example, you can try it with a blank flash drive or with blank USB HDDs, but by no means with our devices in use!

So if we unchecked the write performance test, you could go to Starting performance test ... orb. You will be prompted for the root password and testing will begin. I had these results:

On my desktop SSD:

Gnome-disks - Performance Test - Kingston SSD Drive

SATA2 HDD on your desk:

Gnome-disks - Performance Test - Samsung SATA2 Hard Drive

And my slowest SATA2 drive in my laptop:

Gnome-disks - Performance Test - Hitachi SATA2 Laptop Hard Drive

At the top of the graphs we can see the sequential read speeds - which are always faster - and below we can see the random read results. In essence, the lower part is decisive because, for example, at the start of an operating system or during everyday use, random read and write operations alternate. For example, if you copy larger files to your machine, you will only take advantage of the higher read speeds shown in the sections above the graphs.

 

 

Conclusion

Without being exhaustive, these would be some HDD speed measurement methods. Of course, there are alternatives, and I didn't want to go into the description anymore. For starters, the methods mentioned here are excellent, and to get a comprehensive picture of the state and performance of our storage.