Late last year, I published a blog post with comprehensive benchmarks of various microSD cards used with the internal Raspberry Pi 2 reader, based on the comprehensive (and always-up-to-date Raspberry Pi microSD card benchmark page I maintain for the Pi Dramble project). After publishing the blog post, a few different readers pointed me to some overclocking tweaks that could help boost the speeds further for UHS microSD cards, allowing large file I/O speed to double, and random I/O to get a solid boost as well.
I finally got my hands on a Raspberry Pi 3 and wanted to see how it compares to the Pi 2 (review + benchmarks incoming!), but one of the first things I wanted to test was overclocking the microSD clock for better disk I/O. On average, with all the cards I've tested so far, overclocking the microSD reader resulted in 25-50% better performance for real-world disk operations (benchmarks further down in this post). And with a reliable power supply, you shouldn't need to worry about reliability or corruption (in my limited stress testing, I only had one corruption, and that was when I was using my cheaper iClever power supply).
Overclock the microSD reader with sdhost
First, a caveat: I generally treat my Pis as cattle, not pets, so I do crazy things to them on an hourly basis, and typically rewrite the microSD cards dozens of times trying new configurations, building new servers, etc. If you have anything important on your Pi, overclocking the reader can cause data corruption, especially for non-UHS-certified cards. Make a backup! You've been warned!
dtoverlay directive to overclock the microSD reader to 100 MHz (it defaults to 50):
sudo bash -c 'printf "dtoverlay=sdhost,overclock_50=100\n" >> /boot/config.txt'
Reboot the Raspberry Pi (
sudo reboot), and you should experience much better disk I/O!
Note: The above instructions work on the Raspberry Pi 2 and other models as well (assuming you use a valid integer divisor of the core clock—on the Pi 2 you could try
Benchmarking microSD cards
There are a couple benchmark scripts you can run to test the speed and verify the updated microSD clock:
# Installs and run hdparm, dd, and iozone benchmarks.
$ curl https://raw.githubusercontent.com/geerlingguy/raspberry-pi-dramble/master/setup/benchmarks/microsd-benchmarks.sh | sudo bash
# Run hdparm and some large file read/write benchmarks.
$ curl http://www.nmacleod.com/public/sdbench.sh | sudo bash
Here are a couple quick benchmarks comparing the same cards at normal clock and overclocked:
Random disk I/O performance has the highest impact on most day-to-day Pi usage (especially if you use it as a desktop computer!), so I tend to focus my benchmarking on it; large file operations (e.g. large file reads and writes) basically doubles with the 2x clock speed increase, so if you do things like copy giant files across the network or stream large video files, then the performance boost may be even more noticable. 4K random writes don't benefit as much, mostly because microSD cards typically max out at much lower speeds than would saturate the Pi's bus.
If you notice the clock is not set at 100 MHz after changing these settings (both of the above benchmark scripts output the current clock setting before running the benchmarks), and you've confirmed the steps above were run correctly, there are two things that could be causing problems:
- If your power supply can't supply at least 2.4A at a consistent 5V, then the Pi might not even boot, or might automatically under clock the SD reader.
- If you run
dmesgafter bootup, see if there are any messages relating to
mmc0and "reducing overclock"; the card might not be able to sustain a full 100 MHz overclock.
Sometimes a simple hard power off and power on will resolve these issues; other times it just means either your card, your Pi, or your power supply won't sustain the overclock setting reliably. You can try other, lower overclock settings, as long as the number is an integer divisor of the core clock (default is 400 MHz on the Pi 3), e.g.
Also, if you experience WiFi issues, or if your Raspbian version doesn't include the
sdhost overlay inside
/boot/overlays, you can download
sudo wget -O /boot/overlays/sdtweak-overlay.dtb https://dl.dropboxusercontent.com/u/1221084/share/Raspberry-Pi/sdtweak-overlay.dtb; it's better to update/upgrade, though, so the sdhost overlay is present. You will also need to change 'sdtweak' to 'sdhost' in the overlay line in config.txt if you do this.