«

»

Apr 05

SSD on a Raspberry Pi

As a part of building out the Cloud in a Box, I wanted some storage for Docker images, as well as data.

Based upon my previous experience, I believed that a SSD would be faster than a Micro SD, but I hadn’t tested it as yet. The challenge from Dieter Reuter (@Quintus23M), asking how I’d hooked up the SSD as well as whether it was faster than the Micro SD was a good motivator. I did find a couple of surprises along the way.

SSD Config

The SSD are (at the moment) in a USB 2.0 case such as Inland 2.5″ SATA to High-Speed USB 2.0 External Hard Drive Enclosure 434746 – Micro Center. There wasn’t much reason to go with USB 3 as the Pi doesn’t support it. I mainly wanted it for the cirucuit — a case with circuit and cable was $5 USD, whereas a conversion cable is over $10.

At some point I am thinking about building a sata to USB converter supporting multiple drives — the
JM20337 is an inexpensive chip and appears to be what the converter is using.

The Pi, even when plugged into a 2 Amp power supply, didn’t have enough juice to run the drive. Consequently I needed a powered hub. I think it’s quite possible that another, more expensive case/circuit might not need to have a powered USB hub.

Devices

Device Mount Point Type Notes
/dev/mmcblk0 / MicroSD Class 10, 16GB in Pi Micro SD slot
/dev/sdb /data SSD 240GB Sata 3 SSD
/dev/sda /opt2 Spinning Disk 2.5″ 5400 RPM, 160GB

Testing

In order to make as accurate a test as possible, the buffers and cache are dumped prior to every run:

Additionally, the data is sync‘d in order to ensure that the reads/writes are finished and measured as a part of the time elapsed in the test.

The hdparm tests have an implicit dump of the cache/buffers.

Sequential Write Test

Sequential Read Test

hdparm Buffered Disk Reads

hdparm Cached Disk Reads

Results

The main limitation of I/O on the Pi is the speed of the USB Bus. Given it’s limited to 480Mbs, the bus is much slower than the speed which the hard drive and SSD support.

By comparison, here is the HDParms results for a SSD on a desktop:

and a 5400 spinning disk on a laptop (doing other work at the same time):

The Micro SD device, however, is half the speed of the other two devices — I believe that this is to spec. “Difference between Speed Class, UHS Speed Class, and Speed Ratings (performance) for SD/SDHC/SDXC cards“, indicates that the class refers to the minimum speed that a card supports.

The Best microSD Card states that

It’s important to test SD cards via USB 3.0 to prevent bottlenecks, since USB 2.0 tops out around 33 MB/s

This is the approximate speed being seen for the SSD and Spinning Disk. Since the Micro SD is half the speed of the others, I’ve probably reached the limit of the card — approximately 1.6 times the minimum speed for reads and the spec for writes.

There are UHS cards which are faster, however. One of these should be able to match or exceed the performance of the SSD or spinning disk. For instance, the Samsung EVO Micro SDXC claims, depending on the version, speeds up to
48MB/s or 90MB/s.

Interestingly enough, the hdparm tests for cached reads has all three roughly within range of each other. The buffered tests, however, are similar to the Sequential Read test in the reported rates.

On writes, the spinning disk is slightly slower than the SSD. However, the SSD pulls a bit ahead on reads — ~1 MB/sec for buffered and then ~20 MB/sec on the cached reads.

At the end of the day, the SSD and Spinning Disk are faster than the Micro SD — however, this might be due to the Micro SD card I’m using.

6 comments

Skip to comment form

  1. Dieter Reuter (@Quintus23M)

    Well done and quick comparison, thanks!

  2. Dieter Reuter (@Quintus23M)

    Matt, here is a super-detailed post about what performance we could get on a RPi with SD cards, USB drives or Ethernet: http://raspberrypi.stackexchange.com/questions/1262/what-is-the-highest-performing-hardware-configuration. In short: SD card 15-20MB/sec, USB drive 30MB/sec.

    I just run your tests on Pi 2 with a SanDisk Extreme Pro 32GB SD card, which can handle up to 90MByte/sec R/W (tested on my 2015 MacBookPro).
    Sequential Writes: 14.3 MB/s
    Sequential Reads: 19.1 MB/s
    Buffered Reads: 18.25 MB/sec
    Cached Reads: 362.55 MB/sec

  3. Matt Williams

    Thank you for the challenge. I’d made some assumptions and hadn’t validated them!

  4. Matt Williams

    Thank you for this. I’m definitely going to check it out.

    I do think the main limiting factor is the USB 2.0 bus at this point…..

  5. reza

    recently RP3 with USB 3.0 just came out. Can anyone suggest how we can repeat the experiments to connect RP3 to SSD to get the highest possible data transfer speed?

  6. Matt Williams

    Actually, according the the raspberry pi site, https://www.raspberrypi.org/magpi/raspberry-pi-3-specs-benchmarks/, it’s still USB 2.0:

    The Raspberry Pi 3 shares the same SMSC LAN9514 chip as its predecessor, the Raspberry Pi 2, adding 10/100 Ethernet connectivity and four USB channels to the board. As before, the SMSC chip connects to the SoC via a single USB channel, acting as a USB-to-Ethernet adaptor and USB hub.

    The major differences for the Pi 3 are the wireless & bluetooth as well as the upgraded processor.

Leave a Reply

%d bloggers like this: