[recommendation] SD card that won't die in a few months

I was about to go through the whole thing with getting my Pi4 to boot off an external SSD drive, but further research landed me on this interesting blog post.

Analysis of Sandisk Endurance SD Card

It looks like the recent SanDisk High Endurance sd card uses 3D TLC NAND Flash, much like regular SSD drives on the market, and the latest Max Endurance card uses pMLC NAND Flash which should last even longer. Supposedly the WD Purple sd cards are similar but I don’t know what type of flash is behind it. They all have write leveling, so data writes will spread evenly throughout the entire drive, and the larger the drive, the longer it will last. Which explains why the 128GB version of the Max Endurance drive has a 10year guarantee while the 32GB version has 3 years.

So if you’re building a Home Assistant box through Raspberry Pi, you can probably pick up a 64GB Max Endurance card for $20 and be confident that it will last for a while. (or splurge $30 and get the 128GB version)

Of course this is just info from research, and I’ve only started using the Max Endurance card myself. Time will tell how long this SD card will really last. But given the data, so far I’m convinced, and with daily backups I can rest easy.

  • I’ve done a lot of searching on this topic, hope this isn’t redundant info. Hope you find this info useful.
5 Likes

Well as I am planning to migrate from VeraEdge to HA and was thinking to buy pi4 with SSD to, this is very interesting. Although external SSD is not that expensive, I prefer internal SD.

1 Like

Is it this one:
SanDisk 64GB Micro SD Max Endurance U3 100 MB/s - DataIO

What should I use for HA 64 or 128Gb?

A good SD card is essential. But there’s one other thing you need to do to extend the life of the card and avoid HA crashes: Manage the database!

By default, HA stores every event, every state change, and all the energy data in one database. The vast majority of that data is rarely, if ever, needed. Even a modest-size HA implementation will grow the database to multiple Gigabytes in no time, if you take the defaults. You really should tune the HA “Recorder” (thing that manages the database) to store the bare minimum you need.

6 Likes

Yeah that’s the one I got. Technically 64 should be plenty of space, as the HA partition just uses 2GB.

And CapTom has a great point. It helps to lower the amount of database writes also. (info here)

1 Like

Thanks for the info! So now I have to get an Pi 4, which is difficult these days.

If you’re buying a Pi4, consider buying the 4GB ram model so you can run SQLite in memory, that will also greatly increase the lifespan of the SD card. Great option after you’ve got everything setup and you won’t be rebooting much.

If you do this and have an unexpected reboot, what might you lose?

Just the part of your history of sensor values and state changes that had yet to be written to disk. Not sure how long the commit interval is though…
If you get the pMLC SD card you should be fine unless you have an enormous number of sensors.
I have a TLC SSD hooked up for mine, and it’s total writes for the last year and a half are about 40GB. The SSD is rated to do 200-something TB over 5 years :joy:

Once you’re off MMC (and avoiding QLC) you really don’t need to worry about endurance anymore outside of some very write intensive edge cases. Obviously there will be the exception but that’s why we do regular backups anyway and keep our receipts for warranty :stuck_out_tongue:

On every reboot (unexpected or not) you loose your history / logbook. And you can’t (or barely) use the energy features introduced in (I think) 2021.8

Blockquote Once you’re off MMC (and avoiding QLC) you really don’t need to worry about endurance anymore

Good point. I’m not going to bother with storing SQLite in memory now that I’m using the pMLC SD card. It’d be fun to have a reference point for how how it last. Hopefully it’ll take 5+ years for me to report back any failures. :slight_smile: (by then I can probably buy a huge SD card that will last forever)

1 Like

So it would be a good starting point to buy a Pi4 Model B 2GB and a 64Gb Max Endurance Sandisk? (without SQL light in memory).

Blockquote So it would be a good starting point to buy a Pi4 Model B 2GB and a 64Gb Max Endurance Sandisk?

That’s what I’m starting with. It should be very stable if the SD Card does what it claims. :slight_smile:

The energy features look like great fun, and I can’t wait to try them out. That said, to me these are advanced features, not designed for beginners with RPi and SD hardware.

Yes, that’s a bold statement. But hear me out. The design decision to stuff all the energy data into the existing database suggests the developers were not running the default database (SQLite) on an SD card. For one thing, the retention requirements for energy data are totally different from those for most other HA entities, yet there’s only one retention value allowed.

The RPi with SD card is presented in the Getting Started documentation as a good beginner platform, but ask any questions about it here and the advanced users and developers scoff. They’re using SSDs and alternative databases.

I’m going even farther out on a limb here and saying (as I have before) that the database design was pretty inefficient to begin with, and adding in the energy data only made it worse. And yes, I spent years as a DBA in real life. I’d be happy to contribute to a project to redesign the database, but I’m not at a point where I can take the lead in that, so I try not to complain. But beginner users are being set up for failure, so I try to warn them whenever the topic comes up. The default database can be managed successfully on an SD card, but it takes some effort.

Thanks for al the info. In the mean time, I read some good stories about using an external SSD. And a Kingston a400 240Gb is just around 30 Euro.

Or even better, the Raspberry Pi could support SD Express by then and you might just upgrade failure or not for the performance boost :joy:

From memory there was a second retention policy implemented to support long term statistics for the energy components, which was extended to support some other sensor types as well, although I believe it aggregates the data a little to reduce space usage in the long run.
Haven’t actually tried it out myself since I was already storing my energy stats in Influx already and I haven’t figured out bringing those values into HomeAssistant yet, so I could be misinformed/mixing in facts from something else :joy:

1 Like

In the meantime I took my NUC (gen6) bought a new SSD and installed HA on it. it runs very smooth.

@Lanzer

How is your Sandisk Max Endurance holding up? Curious because I have been running mine on a Max Endurance for only 6 weeks.

Hi, how is it holding ur sd card?