Eiko Wagenknecht
Software Developer, Freelancer & Founder

Testing Raspberry Pi SD Card Speed

Eiko Wagenknecht

In this post, I’ll explain how to perform read and write speed tests on a Raspberry Pi’s SD card using simple console commands over SSH. This can be particularly useful to determine if an SD card’s performance has degraded or if a new card meets your requirements.

Table of Contents

Materials Used

How to Do It

First, connect to the Raspberry Pi via SSH (you can find an explanation in my openHAB installation post) and log in. If there are services running on the Raspberry Pi that generate a lot of read and/or write load on the SD card, now is the right time to stop them so they don’t affect the test. This is usually done with a command like:

sudo systemctl stop servicename

Testing Write Speed

To start the write speed test, use the following command. This writes 1024 blocks of 500KB filled with zeros (so 500MB total) to the file ~/test.tmp:

dd if=/dev/zero of=~/test.tmp bs=500K count=1024

Testing Read Speed

Before testing the read speed, you need to clear the file system cache, otherwise the data will be read from there and you’ll get absurdly fast results (in my case about 600MB/s). To clean the cache, use:

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

Note: Some websites suggest adding the parameter oflag=dsync to the dd command as an alternative. This did not work in my tests on the current Raspberry OS.

To start the read speed test, use the following command. It reads the previously written 500MB into nowhere:

dd if=~/test.tmp of=/dev/null bs=500K count=1024

Cleaning Up

After the test, you should delete the temporary file that was created:

rm ~/test.tmp

Assessment

You should now see results similar to these:

In my case, the SD card writes sequentially at 26.6 MB/s and reads at 21.0 MB/s. If the values are significantly lower, the card is either generally very slow or defective. For example, after almost a year, a Sandisk Ultra 32GB suddenly delivered only about 3MB/s reading and writing, which paralyzed my entire openHAB system.

There are more sophisticated testing methods available, but they usually require installing additional tools. For example, this script by Jeff Geerling tests with hdparm and iozone and thus also provides values for random read and write access:

curl https://raw.githubusercontent.com/geerlingguy/raspberry-pi-dramble/master/setup/benchmarks/microsd-benchmarks.sh | sudo bash

For a quick test, however, the “dd method” is more than adequate.

No Comments? No Problem.

This blog doesn't support comments, but your thoughts and questions are always welcome. Reach out through the contact details at the bottom of the page.

Support Me

If you found this page helpful and want to say thanks, you can support me here.