Disk benchmarks in Linux help confirm whether slow backups, package installs, database jobs, or VM storage are waiting on the disk path. A short read and write test gives an operator a baseline before moving data, replacing hardware, or tuning applications.
Use lsblk to map the whole disk, partitions, and mount points before running a test. hdparm measures read timing from the block device, while dd writes a temporary file through the mounted filesystem so the write number reflects the path used by normal files.
Run benchmarks on a quiet host and keep the device and file path consistent when comparing results. The hdparm timing options read from a whole disk such as /dev/sda or /dev/nvme0n1, while the dd write target must be a regular file such as /var/tmp/disk-benchmark.img rather than a block device.
Related: How to show disk information in Linux
Related: How to check disk health in Linux
Steps to benchmark disk speed in Linux:
- Map the disk and mount point that will be tested.
$ lsblk --output NAME,PATH,SIZE,TYPE,MOUNTPOINTS NAME PATH SIZE TYPE MOUNTPOINTS sda /dev/sda 100G disk ├─sda1 /dev/sda1 1G part /boot/efi └─sda2 /dev/sda2 99G part / nvme0n1 /dev/nvme0n1 500G disk └─nvme0n1p1 /dev/nvme0n1p1 500G part /data
Use the whole-disk path, such as /dev/sda or /dev/nvme0n1, for hdparm. Use a directory on the mounted filesystem, such as /var/tmp or /data, for the dd write file.
- Measure cached and buffered read timing on the selected disk.
$ sudo hdparm -Tt /dev/sda /dev/sda: Timing cached reads: 36258 MB in 1.99 seconds = 18224.37 MB/sec Timing buffered disk reads: 4824 MB in 3.00 seconds = 1607.72 MB/sec
Timing buffered disk reads is the device read number to compare. Timing cached reads mostly measures memory and kernel page-cache speed.
- Measure direct read timing when a page-cache-free device baseline is needed.
$ sudo hdparm -t --direct /dev/sda /dev/sda: Timing O_DIRECT disk reads: 9174 MB in 3.00 seconds = 3057.77 MB/sec
--direct makes hdparm use O_DIRECT for the -t timing test, bypassing the page cache.
Disk benchmarks increase live I/O. Avoid running them during busy production periods or on a block device selected by guesswork.
- Write a temporary 1 GiB test file on the mounted filesystem.
$ dd if=/dev/zero of=/var/tmp/disk-benchmark.img bs=64M count=16 oflag=direct status=progress 16+0 records in 16+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.675606 s, 1.6 GB/s
The of= target 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 filesystem rejects direct I/O with Invalid argument, rerun the same test with conv=fdatasync so dd flushes the file before it exits.
Related: How to check dd progress in Linux
Related: How to show disk activity on Linux - Remove the temporary benchmark file.
$ rm -f /var/tmp/disk-benchmark.img
Leaving the file in place consumes real disk space and can skew later capacity checks.
- Repeat the same read and write tests when comparing disks or before-and-after storage changes.
Keep the whole-disk device, mounted test directory, block size, total write size, and system load as similar as possible so the hdparm and dd numbers remain comparable.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.