Needing Vital Memory Expeditiously For A Raspberry Pi

Wed 25 January 2023

Prologue

This statement shouldn't come as a shock to anyone who's handled them for an extended period of time, but SD cards are one of the worst storage options to run a computer from - putting the godawful latency and throughput of your average card aside, the low-quality flash is almost guaranteed to wear out after a couple years of normal use if a bout of random corruption doesn't take your install down anyway - and after one too many kernel panics after an upgrade I decided I wasn't going to take it anymore.

At the time Youtube's Algorithm™ was suggesting a lot of Level1Techs videos to me and Wendell was just beginning his Optane obsession, which got me thinking: used Optane H10s are pretty cheap, and even though their iffy first-gen QLC flash doesn't perform that well against its contemporaries, it should still be far more consistent than the $30 Micro Center NVMe drive I'd buy otherwise and far faster than the Raspberry Pi it'll be connected to can handle. Will I be able to enable PCIe bifurcation on a Pi so I can access the flash and Optane at the same time? For $30 I'm willing to spin the wheel and find out.

Making A Pi Speak NVMe

Now that I'd decided to put an NVMe drive in my PI, the next question was how I was going to do it. Obviously the immediate first answer was to just buy a case with NVMe support, but the one case with NVMe support I could find only supported the RPi 4 while I have an RPi 3B and 1B [1].

OK then, how about an NVMe-SATA enclosure? SATA's a lot slower than NVMe, but it'll still saturate any Pi connection; I'd need an adapter cable on top of the enclosure, but it'd allow me to use the drive with the big dick rackmount I'd been thinking of buying which only supports SATA drives. Unfortunately, this was also a bust; most NVMe devices don't speak AHCI natively and I couldn't find an enclosure that translated NVMe to AHCI for use on a SATA bus.

OK then, what about a Pi HAT of some sort? People love building all kinds of ridiculous stuff for this computer, surely someone had the idea of Pi + NVMe before me, right? Good news - someone had. Bad news - I was too late and the HAT has since been discontinued. Good news - there's an updated version of the HAT that isn't discontinued; the wiki says it isn't compatible with the RPi 3 because of USB port placement, a normal cable should work. Bad news - it's impossible to find, and incredibly expensive when you can.

An eBay listing of an X873 NVMe adapter hat; the price is $119 with free shipping

At this point I'd had three strikes and was feeling a bit down-and-out. During my search for cases with built-in NVMe support I found the TerraPi, which I thought looked neat but couldn't use since the SSD was a structural part of the case. After staring at that case late at night in my sleep-deprived state for a not-insignificant amount of time, I wondered if there were any standard NVMe-USB enclosures that had the dimensions of a 2.5" drive - and unsurprisingly there was! Surprisingly there was only the one and it was also ridiculously expensive, but realizing I would be fine with a generic enclosure also made me realize any cheap eBay enclosure that supports 10Gbit USB would work just fine. I decided such an enclosure and a TerraPi equivalent that could hold it was sufficient, pulled the trigger and closed this chapter of worrying about computers.

Conclusions

So, what did I learn? First and foremost NVMe is unnecessary overkill for a Raspberry Pi - in most cases you'll have to use an adapter that seriously bottlenecks performance, and even if you find some setup that allows a direct connection at best the Pi exposes only one lane of second-gen PCIe available so even an also-ran like the H10 would be wasted.

If the point of this experiment wasn't to use an Optane H10 I would've picked a drive that spoke mSATA instead, which can be put in an enclosure with a SATA connector and would've kept the rackmount in play, even though it's very likely NVMe support among Pi peripherals will increase.

All in all, even though I went spiralling in a rabbit hole for a couple days just to come up with "buy a cheap eBay NVMe enclosure", I'm still glad I went through it and learned something [2]. I guess.

[1]Both non-plus models.
[2]I learned there isn't even an expensive NVMe enclosure that does PCIe bifurcation