How to test disk speed in Linux

Disk speed tests in Linux show whether backups, package operations, database jobs, or VM workloads are waiting on the storage layer instead of the CPU or network. A short benchmark is often the quickest way to confirm whether a slowdown is really in the disk path before changing applications or moving data.

Two commands cover the most useful baseline checks. hdparm reads from the whole block device to show sequential read throughput, while dd writes a real file on the mounted filesystem so the result includes the filesystem layer used by normal workloads. lsblk ties those commands back to the correct whole disk, partition, and mount point before any benchmark runs.

Run the tests against the correct disk on an otherwise quiet system, because live I/O from package updates, databases, or backup jobs can skew the numbers and add latency for other workloads. The example flow below was verified on Ubuntu Server 24.04 with the current hdparm package from the default repositories, a writable filesystem under /var/tmp, and a whole-disk device at /dev/sda.

Steps to test disk speed in Linux:

  1. List block devices and mount points so the correct disk and writable filesystem are selected before any benchmark runs.
    $ lsblk -o NAME,PATH,SIZE,TYPE,MOUNTPOINTS
    NAME   PATH          SIZE TYPE MOUNTPOINTS
    sda                       /dev/sda                            64G disk
    ├─sda1                    /dev/sda1                            1G part /boot/efi
    ├─sda2                    /dev/sda2                            2G part /boot
    └─sda3                    /dev/sda3                         60.9G part
      └─ubuntu--vg-ubuntu--lv /dev/mapper/ubuntu--vg-ubuntu--lv 30.5G lvm  /
    sr0                       /dev/sr0                          1024M rom

    Run hdparm against the whole disk such as /dev/sda or /dev/nvme0n1. Write the temporary dd file to a normal directory on the filesystem backed by that disk, such as /var/tmp or another writable mount point. If the mounted filesystem sits on LVM or another mapper path, keep using the whole physical disk for hdparm and the mounted directory for dd.

  2. Measure cached and buffered sequential read speed on the selected disk.
    $ sudo hdparm -Tt /dev/sda
    
    /dev/sda:
     Timing cached reads:   37040 MB in  1.99 seconds = 18580.99 MB/sec
     Timing buffered disk reads: 4794 MB in  3.00 seconds = 1597.81 MB/sec

    Timing cached reads reflects Linux page cache speed. Timing buffered disk reads is the more useful number when comparing disks or storage backends. The hdparm manual recommends repeating timing tests two or three times on an otherwise inactive system for more meaningful comparisons.

  3. Measure sequential read speed again with direct I/O when the cleaner device baseline matters more than cached behavior.
    $ sudo hdparm -t --direct /dev/sda
    
    /dev/sda:
     Timing O_DIRECT disk reads: 9228 MB in  3.00 seconds = 3075.99 MB/sec

    The --direct option makes hdparm use O_DIRECT for the -t timing test, which bypasses the page cache and reads straight from the device into hdparm buffers.

    Disk benchmarks increase live I/O. Avoid running them on the wrong block device or during busy production periods.

  4. Write a temporary file on the target filesystem to estimate sequential write throughput through the filesystem layer.
    $ sudo dd if=/dev/zero of=/var/tmp/disk-benchmark.img bs=1G count=1 oflag=direct status=progress
    1+0 records in
    1+0 records out
    1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.615533 s, 1.7 GB/s

    The of= target in this step must be a regular file on a mounted filesystem. Pointing of= at a device such as /dev/sda overwrites disk data.

    oflag=direct bypasses the page cache for the file write. If the destination filesystem rejects direct I/O with Invalid argument, rerun the same test with conv=fdatasync so dd flushes the data before it exits. status=progress prints a running byte count while the write is still active.

  5. Remove the temporary benchmark file after the write test finishes.
    $ sudo rm -f /var/tmp/disk-benchmark.img

    Leaving the file in place consumes real disk space and can skew later capacity or cleanup checks.

  6. Repeat the same read and write tests on the same quiet host when comparing disks or before-and-after storage changes.

    Keep the whole-disk device, the test file location, the block size, and the total write size the same so the hdparm and dd numbers remain comparable from one run to the next.