Testing Disk Read/Write Speed on CentOS with dd
Databases, logs, and caches are all I/O-intensive workloads where disk speed directly affects request latency. The "500MB/s" a vendor claims on the spec sheet often does not match what you actually measure, so a quick dd sanity check before going to production is worth it. dev is the mounted disk directory (for example /www or /data), and the test file is written into that directory. The three commands below cover write, read, and small-block synchronous write.
Even without lab-grade precision, dd answers "can this disk handle my current workload": for database transactions and log flushes, the bottleneck is almost always synchronous write speed.
1. Test Write Speed
dd if=/dev/zero of=/test.bin bs=1M count=256 conv=fsync
if=/dev/zero: read from the zero device (produces all-zero data);of=/test.bin: write to the test file;bs=1M: read/write 1M at a time;count=256: read/write 256 times, producing a 256M test file;conv=fsync: physically sync before counting, to avoid inflated memory cache numbers.
2. Test Read Speed
dd if=/test.bin of=/dev/zero bs=1M count=256 iflag=direct
iflag=direct: bypass the filesystem cache and read directly from disk, producing results closer to real disk read performance.
3. Test Synchronous Write Speed (Small Blocks)
dd if=/dev/zero of=/test.bin bs=64k count=1k oflag=dsync
bs=64k: write 64K each time;count=1k: write 1024 times, 64M in total;oflag=dsync: sync to disk on every write, simulating a real small-file write scenario; the speed will be noticeably lower than the cached write above.
How to tell whether the result is normal
Different media differ widely in speed; here is a reference range:
| Storage type | Sequential write | Sequential read | Typical use |
|---|---|---|---|
| HDD | 80-150 MB/s | 100-180 MB/s | Cold data backup |
| SATA SSD | 300-500 MB/s | 400-550 MB/s | Entry cloud data disk |
| NVMe SSD | 1000-3500 MB/s | 1500-7000 MB/s | Databases, high-concurrency apps |
If a disk marketed as SSD measures only tens of MB/s, you probably bought a shared-I/O or rate-limited instance, or the load was too high during the test. Fast reads with slow writes usually reflect write-cache policy or firmware differences and are acceptable; if reads and writes are both more than double the baseline for the same SKU, contact the vendor.
Bonus: hdparm read test
If you only want a quick look at read capability, hdparm is lighter:
yum install -y hdparm
hdparm -t /dev/vda1
-t measures buffered reads, -T measures cache reads. Note that hdparm needs root and only works on block devices, not mounted directories.
Why run fio too
dd is simple and intuitive, but it only measures sequential reads/writes, not random IOPS. For capacity planning in production, use fio:
fio --name=randwrite --rw=randwrite --bs=4k --size=1G --numjobs=4
fio covers random read/write, mixed workloads, and latency distribution, matching a database's real load much more closely — a good next step after dd. Watch disk space while running it: --size=1G creates a 1GB test file, so point it at the target mount and clean up afterward.
When and where to test
Think about the goal before testing. For a "physical exam" of a new cloud host, run it once on both the system disk and the data disk; for a database migration evaluation, test the data disk attached to the target instance, not the system disk — they are often not the same physical disk. Avoid business peaks; run in the early morning or a low-traffic window, repeat three times, and take the median.
A common question is "it measured slow — should I return it?" First classify the media against the reference ranges above, then check for throttling: cheap cloud instances often share host I/O, and a rate far below the advertised figure is usually a limited SKU rather than a bad disk.
Example Output
1073741824 bytes (1.1 GB) copied, 4.63867 s, 231 MB/s
The final 231 MB/s is the measured read/write speed. Note that dd measures sequential read/write speed and is affected by CPU, filesystem, and disk cache policy, so results may vary slightly between runs on the same disk — run it three times and take the median.
Also keep units straight: dd reports decimal MB/s (1 MB = 1,000,000 bytes), and most vendors use decimal too, so they compare directly; if a vendor quotes binary GiB, the number looks "smaller" — normalize before concluding.
Notes
Testing is easy; leaving behind a mess is not. Follow these and you will stay out of trouble:
-
Remember to delete the test file after testing to avoid wasting disk space:
rm -f /test.bin -
Test when the server load is low for more accurate results;
-
conv=fsyncandoflag=dsynctrade some speed for more realistic disk data, which is exactly what we want; -
The test file lands on whichever mount point you point it at, so change the path when switching disks;
-
Record the synchronous-write result before deleting the test file so you can compare it after swapping disks or scaling up.
Disk performance testing is an important part of server performance testing. For more server operations and performance optimization content, see the cloud servers category.
Original post: https://www.cnblogs.com/cqzhuomi/articles/17284297.html (cnblogs.com CQZHUOMI, repost)
Reference: fio docs — https://fio.readthedocs.io ; Red Hat performance docs — https://access.redhat.com/documentation/
Integration & Code Examples
Example 1: Measure sequential write, read and synced small writes with dd
# Confirm the target filesystem first so you don't fill the system disk
df -hT /data
# 1) Sequential write of 1G; conv=fsync makes the timing include real I/O
dd if=/dev/zero of=/data/ddtest.bin bs=1M count=1024 conv=fsync
# 2) Sequential read, bypassing the page cache with iflag=direct
dd if=/data/ddtest.bin of=/dev/null bs=1M iflag=direct
# 3) Synced small writes, closer to per-commit database and log traffic
dd if=/dev/zero of=/data/ddtest.bin bs=4k count=16384 oflag=dsync
# 4) A quick look at device type and queue setup
lsblk -d -o NAME,ROTA,SCHED,SIZE
rm -f /data/ddtest.bin
ROTA=0 means SSD and ROTA=1 means spinning disk; bs times count is the file size, so always delete the test file afterwards.
Example 2: Quick read test with hdparm and random IOPS with fio
yum install -y hdparm fio smartmontools
# hdparm: -t for buffered reads, -T for cached reads, block devices only
hdparm -tT /dev/vdb
# Rule out hardware errors before talking about performance
smartctl -H /dev/vdb
# fio: 4K random write, 4 jobs, 60 seconds - closer to database load
fio --name=randwrite --rw=randwrite --bs=4k --iodepth=32 \
--size=1G --numjobs=4 --runtime=60 --time_based \
--filename=/data/fio.test --direct=1 --group_reporting
rm -f /data/fio.test
hdparm reports MB/s while fio is about iops and clat; great dd numbers with poor random writes usually mean no write cache or a disk shared with other tenants.
What Each dd Variant Actually Measures
The three dd commands differ in whether the result waits for the data to land and whether the page cache is bypassed, not in file size.
| Command | Block size and volume | What it measures | Matching workload |
|---|---|---|---|
| Write | bs=1M × count=256 (256M), or count=1024 (1G) |
Sequential write; conv=fsync counts the flush |
Large file writes, backup dumps |
| Read | bs=1M with iflag=direct |
Sequential read with the page cache bypassed | Cold data reads |
| Small synchronous write | bs=64k × count=1k (64M), or bs=4k × count=16384 |
Write per commit with oflag=dsync |
Database commits, log appends |
| fio random write | --bs=4k --iodepth=32 --numjobs=4 --runtime=60 |
Random IOPS and clat |
Databases, high-concurrency apps |
bs multiplied by count is the size of the test file, which is why the same three scenarios appear at 256M and at 1G in this article. The larger file amortises startup cost; the smaller one finishes faster on a busy host.
The gap between a buffered write and a dsync write is the write cache doing its job. On the same disk the small synchronous write is expected to be far slower, and it is the number that matches what a database commit actually waits for.
Use the reference table earlier in this article as the baseline: 80-150 MB/s sequential write for an HDD, 300-500 MB/s for a SATA SSD, 1000-3500 MB/s for NVMe. A result inside its band needs no further action; one well below it points at the instance or the load rather than the filesystem.
Confirm the Mount Point and the Media Type First
df -hT /data tells you which filesystem and partition the test file will land on, so you do not fill the system disk by accident. The test only measures the mount point you write to; move the path when you want to measure another disk.
lsblk -d -o NAME,ROTA,SCHED,SIZE identifies the media: ROTA=0 is an SSD and ROTA=1 is a spinning disk. Comparing a result against the wrong row of the reference table is the most common way to misjudge a healthy disk.
Run smartctl -H /dev/vdb before benchmarking a new machine. A disk reporting a hardware fault will produce low numbers no matter how the test is configured, and it needs to be replaced rather than retested.
Limitations
- This article reflects public information as of 2023-04-03; terms, prices and quotas follow the provider's current published terms.
- Third-party capability and limit statements follow their official documentation; no further commitment is implied here.
- Licensing, filing and data-residency decisions must be verified against the regulations of your operating region.
FAQ
Is dd's MB/s the same unit vendors quote?
Only if both use decimal units. dd reports decimal megabytes, where 1 MB equals 1,000,000 bytes, and most vendors quote the same way. If a vendor quotes GiB its number looks smaller, so normalise the unit first and compare medians from three runs rather than one.
Why does an SSD benchmark show only tens of MB/s?
Most often the instance shares host IO and is rate-limited. Compare with the reference ranges: SATA SSDs should reach 300–500 MB/s on sequential writes, NVMe 1000–3500 MB/s. A far lower number under normal load means host contention, so change the instance size or ask the provider, not reinstall the OS.
Is a fio random-write test worth adding?
Yes. dd only covers sequential reads and writes, not random IOPS. Database and high-concurrency workloads need a 4K random-write run on the target mount with --iodepth=32 --numjobs=4, checking iops and clat. A good dd number with poor random writes usually means write caching is missing.
Related Providers
- Alibaba Cloud ECS: confirm volume type and provisioned IOPS ceilings in the console before comparing dd results across cloud disk tiers.
- AWS EC2: note the gap between baseline IOPS and burst credits when choosing between gp3 and io2 from measured write speed.
- Hetzner: read the data centre disk and network specs when advertised throughput has to be checked against measured writes.
Community & Resources
Official docs and communities
- dd(1) manual — authoritative notes on
bs,count,conv,iflag/oflag - fio documentation — parameter reference for random, mixed and latency tests
- smartmontools — SMART collection and disk-health interpretation
- Stack Overflow: dd — reading results and avoiding common misuse
Learning resources and tools
- fio repository — source plus ready-made job files in the examples directory
- smartctl(8) manual — SMART attributes and self-test commands
- hdparm(8) manual — reference for
-t,-T,-I - Linux block layer docs — scheduler and I/O path context that explains the numbers
- GPU Cloud Server Comparison: 2026 AI
Original source: cnblogs.com (CQZHUOMI) ↗