How long should a good micro sd card last?

I’m on my 3rd “quality” SD card (in less 8 months) and would love to have the option of moving the history log to my NAS / external disk / whatever works.
I have a pretty large installation with many PIRs (~40) and other sensors creating frequent updates. I can see the DB files getting updated several times every minutes so no surprise the the cards eventually gives up. Everything runs fine on the fresh card but over time the installation becomes unstable and usually dies during an upgrade.
Anyone with a solution for Raspberry with Hassio? (I’m pretty happy with hassio so would prefer to stick with that…)

First you can disable recording for entities you don’t need to retrieve history for, that will at least make the card live a little longer. Then if you have a NAS that support MySQL (Synology, Qnap) you can use that ad an external DB.

Thanks, have already moved many devices out of recorder. Have started looking at nas boxes, my old one just is not going to cut it.

I’ve just lost my 4th in 18 months :frowning:
How do I move my history to external flash drive on Hassio?

And I am using my current and cheap sd card for 3 years now. Running HA 24/7 with system reboot every with months.
I think sometimes you have luck with your sd cards or usb sticks and sometimes you don’t.

I have many rpi3 running for many years as Roon endpoints for outdoor audio, pi-hole … all my systems are powered by a UPS (7 total ) … low end amazon basics models that work pretty well

Last weekend I had my first SD card failure, 8GB Kingston running on a BeagleBone Black which sole purpose was acting as zigbee2mqtt interface. Zigbee2mqt log level was using defaults which means “info”, logging all zigbee messages that float around. I guess that was not such a good idea (I have about 10 Xiaomi sensor or so).

Granted the SD card is one I found in between all my electronics things and several years old, still it surprised me how only zigbee2mqtt running could kill it in a month or 2.

This lead me to seriously think about how to have backups, and as suggested before I will be using dd to make a clone of both my HA (on rp3) and zigbee2mqtt (on BBB) microsd cards.

Thank god it’s all running in Docker containers with the configuration files backed up on GitHub, which means restoring the dd’ed image to a new, exactly the same or larger SD card, would only take a git pull to get back up to speed.

I wonder, is there already a guide written somewhere on how to take proper backups and how to minimize sd card IO with HA?

yes you can back up an SD card or usb stick or harddrive by making a disk image. for windows use win32diskimager or Paragon Backup & Recovery both are free

We’re having power outages like 10 times a week. I have a Hass.io in R.Pi4 from 6 months and a motionEye camera system in Pi Zero W for about 2 years. The SD card in Pi Zero used for mobile for 1 year and later flashed motionEye and using from 2 years, set to record motion triggered videos for 1 month and delete after that and save new recordings. This will cause huge write cycles. Still working smooth. May be the issue is the time it starts to write data into flash and face a power outage. Thankfully, I’m using a UPS for my Hass system.

This is quite good info:

Flash memory indeed has limited write cycles. However, by now it is unlikely that you’ll encounter this within the normal lifetime of such a card. Usually this is in the order of 100,000 write cycles today and SD cards include circuitry to manage wear-leveling, that is, spread out writes over the storage media evenly to avoid “hot spots”—pages that are written too frequently and therefore failing early.

So a 64Gb SD card should allow for 6.4Pb or 6400Tb to be written before it shows signs of failure, in theory.

That sounds about very wrong to me.

100k write cycles is nothing a “normal”/cheap MLC/TLC/QLC NAND can deliver. The expected write/delete cycles are typically only within 1-5k for this types.

In the end the sd cards are normally dying early solely because of heavy write amplification and not because of a lot of data was intentionally written from the host system.

Sadly HaOS (at least till v7) is shipping with totally sane filesystem settings (5 second commit interval) which will heavily amplify a sd card death :put_litter_in_its_place: