Hi there guys!!
I have seen lots of complains about people having problems with Raspberry + SD Card combination, and I believe we can reduce this kind of issue.
Not that the SSD is a bad option, but sometimes it’s just not necessary for some people, and they just don’t understand what’s going on.
As Home Assistant uses SQlite as its database, HA always needs to write an increasing number of sensors and entities we created in that database. and if you have influxDB also, this situation only gets worse, specially when you have short sensor update times, like once per second etc…
what happens is that your number of I/O writes increases and your wait/queue for i/o writes also increases.
So basically you are always writing a high volume of data to the SD, and in combination with an inappropriate power source or fluctuations in your electrical system, the card will get corrupt very quickly.
So, what to do?
1 - Decrease your I/O writings:
On sqlite, mariaDB or InfluxDB you can reduce the amount of sensors that write to the database by removing them in the integration.
# Here you choose what to write or not on sqlite recorder: exclude: # this section exclude entire domains or entities from writing to database domains: - sensor include: # this section includes entire domains or entities entities: - sensor.last_boot # see https://www.home-assistant.io/integrations/recorder/ for more details
Removing from InfluxDB
the nomenclature is the same, you just have to reproduce it within the influxdb section
influxdb: exclude: # this section exclude entire domains or entities from writing to influx database domains: - sensor include: # this section includes entire domains or entities entities: - sensor.last_boot # see https://www.home-assistant.io/integrations/influxdb/ for details
2 - Monitor your reads/writes
How to monitor the number of writes and reads? one way to do this is to add the system monitor. on this platform we can add CPU process waiting time. if it’s too high, the chance of crashing your card is very high.
- platform: systemmonitor resources: - type: load_1m - type: load_5m - type: load_15m
The last card I had, was overwhelmed with like 50 processes waiting for the processor at 1m load. today with the appropriate card this number has dropped to between 0.5 to 1.5 processes in 1m.
3 - Buy an SD with a good number of I/O writes
Many people buy SDcard Class 10 or UHS speed class 3 thinking that only this is necessary to get a good card, but the class that defines the number of writes/reads I/O is Class A2
If your card is A2 it prioritizes inputs and outputs of an operating system, some class 10 don’t even have A1 rating, so choose an A2 card.
With this simple steps i managed to get a stable system, It worked for me this way and I believe it can work for more people. Hope this helps.