Benchmark how fast a (network) disk handles large files and many small files with dd, split and rsync.

Benchmark write speedFeb 27, 2023 PDF

💾 Benchmark Write Speed to a Disk

Sometimes you need to test how fast a (network) disk can handle writes.

A common method is:

  1. Write one large file
  2. Split it into many small files
  3. Benchmark copying them using rsync or cp

Why? Some storage systems handle large sequential writes very well, but struggle with many small files (metadata overhead, IOPS limits, etc.).


1️⃣ Create a Large Random File

Generate a large file locally:

# Create a ~1GB file (conv=fdatasync: really write it to disk before dd stops)
dd if=/dev/urandom of=random_file bs=1M count=1024 conv=fdatasync

Measure how long it takes:

time dd if=/dev/urandom of=random_file bs=1M count=1024 conv=fdatasync

💡 Use count=10 for ~10GB, etc.

Alternative example (slightly smaller blocks):

dd if=/dev/urandom of=random_file bs=128K count=10000

2️⃣ Split Into Many Small Files

Create a directory and split the large file into 1MB chunks:

mkdir random_dir
split -b 1M -a 3 random_file random_dir/file_

This creates many small files like:

file_aaa
file_aab
file_aac
...

3️⃣ Benchmark with rsync

Copy Single Large File

rsync --info=progress2 random_file /target/path/

Copy Many Small Files

rsync --info=progress2 -r random_dir/ /target/path/

Example targets:

rsync --info=progress2 -r random_dir/ /mnt/storage1/test/
rsync --info=progress2 -r random_dir/ /mnt/storage2/test/
rsync --info=progress2 -r random_dir/ /mnt/bigstorage/test/

4️⃣ Local Copy Benchmark

You can also benchmark locally:

rsync --info=progress2 -r random_dir/ random_dir2/

Or using cp:

time cp -r random_dir random_dir2

5️⃣ Metadata / IOPS Test (Many Small Files)

To stress-test metadata performance:

time bash -c 'for i in $(seq 1 1000); do touch random_dir/$i; done'

This tests how fast the filesystem can create many small files.


🧪 What This Tests

Test TypeWhat It Measures
dd large fileSequential write throughput
rsync large fileNetwork + sequential performance
rsync small filesMetadata + IOPS + network
touch loopPure metadata performance


⚠️ Pitfalls

  • Without conv=fdatasync (or oflag=direct), dd measures how fast Linux fills its memory cache, not the disk. That’s why the commands above use it.
  • /dev/urandom itself can be slower than a fast NVMe disk. To test only the disk, create the random file once and then copy it, or write zeros: dd if=/dev/zero of=/target/zero_file bs=1M count=1024 conv=fdatasync (compressing storage will cheat with zeros, though).

🧰 The proper tool: fio

For real numbers (throughput and IOPS, sequential and random), use fio:

sudo apt install fio     # or: sudo dnf install fio

# sequential write, 1 GB, 1 MB blocks
fio --name=seqwrite --filename=/target/path/fio.test --rw=write --bs=1M --size=1G --direct=1

# random 4k writes: what databases and many small files feel like
fio --name=randwrite --filename=/target/path/fio.test --rw=randwrite --bs=4k --size=1G --direct=1 --iodepth=32 --ioengine=libaio --runtime=60 --time_based

Delete fio.test afterwards.