Raspberry Pi Micro SD Cards
by jeff.cartwright.562 in Circuits > Raspberry Pi
3424 Views, 7 Favorites, 0 Comments
Raspberry Pi Micro SD Cards
Benchmark microSD cards used in my Raspberry Pi projects.
I like to run benchmarks on the Raspberry Pi, rather than on a laptop.
The Raspberry Pi Forum Moderator wrote: "It's worth noting that the usage pattern for a Pi is drastically different to the usage pattern in a camera or camcorder. Our own NOOBS 8GB SD card is a Class 6 card and outperforms most other cards on the market in terms of system responsiveness and "real-world" use cases. The majority of Class 10 cards perform worse than Class 4 / 6 cards."
Goals:
- Benchmark and select best micro SD card for Raspberry Pi applications
Notes:
- text enclosed in spades, like this ♣replace-this♣ should be replaced with an actual value
- In the Appendix, I’ve attempted to credit every source used. My apologies for any omissions.
- $ indicates a command executed in a terminal window on the MacBook and usually is being executed on the Raspberry Pi
Gather Parts
I have these:
- Working Raspberry Pi (see this instructable: Setup Raspberry Pi without Monitor or Keyboard)
I bought these memory cards from Amazon, CanaKit, Fry's and so on. I use Amazon as reference price:
- ??MB/s - SanDisk 8 GB Class 10 (UNKNOWN-8GB)
- 30MB/s - SanDisk Ultra 16 GB microSDHC Class 6 (SDSDQY-016G-U46A) $9.81
- 48MB/s - SanDisk Ultra 16 GB microSDHC Class 10 (SDSQUAN-016G-G4A) $8.99
- 70MB/s - Sony 8GB Micro SDHC Class 10 UHS-1 (SR8UY2A/TQ) $7.61
- 80MB/s - SanDisk Ultra 16GB Ultra Micro SDHC UHS-I/Class 10 (SDSQUNC-016G-GN6MA) $8.49
Create a Standard Disk_test.dmg Image
Use steps 3 and 12 in this instructable to create and save a disk test image:
Setup Raspberry Pi without Monitor or Keyboard
Use the same image on each SD card that is tested.
- Create an image and save to the MacBook
- For each SD card, burn the image from the MacBook to the micro SD card
Create Dd Read/Write Scripts
Initially, I ran the command line version of the dd write test five times and got three different results (12.9, 10.6 and 9.7 MB/s). So, I decided to create a script, which runs each command ten times and then calculate an average.
Open terminal window on MacBook
Login to Raspberry Pi
$ ssh pi@♣raspberry-pi-ip-address♣
Read Script
Open an editor
$ sudo nano diskreadtest.sh
and edit the file to look like:
#!/bin/bash # disk I/O read script for (( c=1; c<=10; c++ )) do dd if=~/test.tmp of=/dev/null bs=500K count=1024 done
Save and close
- CTRL-o
- ENTER
- CTRL-x
Change the file to be executable
$ sudo chmod u+x diskreadtest.sh
Write Script
Open an editor
$ sudo nano diskwritetest.sh
and edit the file to look like:
#!/bin/bash # disk I/O write script for (( c=1; c<=10; c++ )) do dd if=/dev/zero of=~/test.tmp bs=500K count=1024 done
Save and close
- CTRL-o
- ENTER
- CTRL-x
Change the file to be executable
$ sudo chmod u+x diskwritetest.sh
Create Hdparm Script
hdparm measures system performance as it relates to micro SD card IO
-t option shows speed of reading directly buffer cache without disk access.
-T measures how fast the drive can sustain sequential data reads, without any filesystem overhead.
Create a script that runs the command ten times to get an average.
Open terminal window on MacBook
Login to Raspberry Pi
$ ssh pi@♣raspberry-pi-ip-address♣
Install hdparm
$ sudo apt-get install hdparm
Open an editor
$ sudo nano hdparmtest.sh
and edit the file to look like:
#!/bin/bash # hdparm script for (( c=1; c<=10; c++ )) do hdparm -tT /dev/mmcblk0 done
Save and close
- CTRL-o
- ENTER
- CTRL-x
Change the file to be executable
$ sudo chmod u+x hdparmtest.sh
Run Tests on Raspberry MicroSD Cards
Open a terminal window on MacBook
Login into Raspberry Pi
$ ssh pi@♣raspberry-pi-ip-address♣
For each memory card, run the scripts (must write the file before running the read script):
Write:
$ bash diskwritetest.sh
Read
$ bash diskreadtest.sh
hdparm
$ sudo bash hdparmtest.sh
Average the results of each test and record in the Results step
Shutdown the Raspberry Pi, remove the power cord, put in the next SD card, and put the power back
$ sudo shutdown -h 0
Results
Higher is better. All SD cards are Class 10 unless otherwise noted.
UNKNOWN-8GB
- dd read = 549.4 MB/s
- dd write = 10.79 MB/s
- hdparm cached reads 432.25 MB/s
- hdparm buffered disk reads 18.16 MB/s
30MB/s, Class 6 - SanDisk SDSDQY-016G-U46A
- dd read = 554.9 MB/s
- dd write = 12.9 MB/s
- hdparm cached reads 427.88 MB/s
- hdparm buffered disk reads 18.17 MB/s
48MB/s - SanDisk SDSQUAN-016G-G4A
- dd read = 552.5 MB/s
- dd write = 15.38 MB/s
- hdparm cached reads 428.96 MB/s
- hdparm buffered disk reads 18.09 MB/s
70MB/s - Sony SR8UY2A/TQ
- dd read = 555 MB/s
- dd write = 16.53 MB/s
- hdparm cached reads 430.35 MB/s
- hdparm buffered disk reads 16.87
80MB/s - SanDisk SDSQUNC-016G-GN6MA
- dd read = 553.9 MB/s
- dd write = 12.61 MB/s
- hdparm cached reads = 428.45 MB/s
- hdparm buffered disk reads = 15.65 MB/s
32GB USB Drive (unknown make/model - used as main drive)
- dd read = 512.3 MB/s
- dd write = 14.27 MB/s
- hdparm cached read = 408.96 MB/s
- hdparm buffered disk reads = 17.98 MB/s
Appendix - References
I used these sources in writing this instructable
- AskUbuntu: How to check hard disk performance (raspbian, debian and ubuntu are related linux distributions)
- linux.org: Raspberry Pi SD Card Performance
- RaspberryPi.org: How can I test SD card speed?
- wiki.archlinux.org: Benchmarking/Data storage devices
- RaspberryPi.org: SD Card Benchmarks
- ozzmaker.com: How to Test the SD Card Speed on Your Raspberry Pi
- jamescoyle.net: Benchmark disk IO with dd and bonnie++