SD Card Corruption Problem? Couple Tips

I’ve been seeing where people are having SD corruption problems on their RPi’s. I too have had experience with corruption not just using hassio but for other things I run on RPi’s. After some digging I’ve gotten to a point that it’s no longer an issue so a couple of tips I learned that helped me.

1: Power supply, we like to use inexpensive supplies but the Pi needs 2.5 amp and a minimum of 4.75v so get a good supply and quality USB cable to maintain the spec’s, voltage drop is your worst enemy on a Pi. I use a 3 amp supply on all my Pi’s. It is especially important when using web cam’s and other USB devices.

2: Make sure your SD card has “Wear Leveling” which writes all over the card instead of hammering at the same places as they become empty. Even some of the common name brands do not have wear leveling on all their cards. I have found Samsung Evo Plus cards to be reliable myself, I have not had any corruption issues since moving to them. There are other good cards out there like Sandisk that have the “Advanced Error Correction Code engine”, not all of them do. Not all cards will tell you they have wear leveling but the ones rated for intensive writes pretty much are, you usually see a long warranty associated with them as well like Samsungs 10 year.

I hope this helps anyone currently having issues or just getting started to avoid them not to say corruption can’t come from OS and App problems but at least this should help eliminate hardware as a cause.

6 Likes

I use a 5V 3A power supply and a Samsung EVO plus, and have got 2 already corrupted!
Any other tips?

1 Like

Stop logging/recording everything. Is it really that important to know you turned on the bedroom light at 6am 3 weeks ago?

3 Likes

My few words:
I am using Hass.io on RPi3B+ with a 2A power supply (with rather short cable so there’s only a small voltage drop; I think that low-quality / too long cable could give rise to a problems even with good power supply) for a half a year, without any issues.
And the interesting part: I was sure that I was using a 32GB, good quality card, but I was wrong. A few days ago I did cataloguing of my microSD cards used in different projects, and I’ve found out that I am using the cheap, no-name, 16GB and rather slow card for Hass.io… Now I’m in doubt what to do - replace the curent card with a new one, or leave it alone while it’s working fine :thinking: :grinning:.

AFARGAS I agree with Dixey… if you have a lot going on it could be the culprit and you can cut back on what you log. Also size is important, the more you have going on the bigger card you should run, 32 Gig minimum I would say. My system is pretty new I do not have a lot of automations running so it may be why I haven’t seen issue. I also just the other day setup a Maria Database on my Synology NAS to head off possible future issues.Have you looked at moving to a cheap SSD?

1 Like

I tend to leave things alone until they die if they are working well… but also be prepared to recover, stay up on your backups and copy them off to a safe place.

1 Like

I use Rpi with a Sd card. I’m a newbie and I don’t know how to disable registration.

Can you help me? Thank you.

In your configuration.yaml, recorder section (recorder: or recorder.yaml file), exclude every domain possible and include only the things you care about. I.e.:

purge_keep_days: 7
purge_interval: 1
include:
  entities:
    - binary_sensor.kitchen_opened
    - sensor.kitchen_temperature
    - sensor.kitchen_humidity 
    - binary_sensor.attic_opened
    - sensor.attic_humidity
    - sensor.attic_temperature
    - binary_sensor.tool_shed_opened
exclude:
  domains:
    - automation
    - binary_sensor
    - calendar
    - camera
    - climate
    - device_tracker
    - group
    - input_text
    - input_number
    - light
    - lock
    - media_player
    - remote
    - script
    - sensor
    - sun
    - switch
    - zone
    - weather

Thank you very much. I will modify my file “configuration.yaml”.

I can’t find the “recorder” section in my configuration file. I don’t have a file called “recorder.yaml” either.

What am I supposed to do? Thank you again

By default you won’t have an entry but you can create one. Here is a link to the document that covers it.

Thank you for your patience and help.

I haven’t been able to find anything about “recorder” in the Home Assistant docs. Now I know how to do it.

Tomorrow I will modify my configuration file.

My HASSIO instance just died a few days ago (this happened once before several months ago). I assume it is a corrupted SD card, because everything works fine with a new SD card. My latest backup was about a month old. Some headaches, but not the end of the world. I was back up and running in about 4 hours or so.

Now, a few days later, HASSIO just died again. I added the automatic backup to google drive add-on, so I have a snapshot from last night.

I am certainly guilty of logging way too much stuff. I barely have anything excluded and my log file takes FOREVER to open. I’ll have to change that. I have also been experiencing corrupted database files a lot in the past few months. Lots of deleting the database file and restarting.

I am using this SD Card: https://www.amazon.com/gp/product/B06XWN9Q99/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Maybe I need a new power supply. I have the power supply that came with the CanaKit which I would expect to be good, but something isn’t right. Anyone have a specific power supply to recommend that is reliable?

To check if your Canakit power supply is good (which it should be), hook up the Raspberry Pi to an HDMI monitor or TV and check the output to see if there are any under-voltage warnings. Bad power supplies should get warnings within a minute or two. If there aren’t, then your power supply should be good and think about other solutions.

The Samsung Evo Plus and Select are identical… Amazon has exclusive rights to use the Select branding. So yes you are using a good card. Get rid of all those writes that you don’t need is a big step in the right direction. If you have a Synology NAS maybe setup a MariaDB I think I spent 45 minutes moving the database off the Pi including time to install the DB and phpMyAdmin.

Just unplugged and replugged the raspberry pi and wouldn’t you know it, that sucker booted right up. Huh… That’s a new one.

I need to look into some of the database options. I know next to nothing about databases, so it may take me some time.

Funny thing… not sure if others have experienced this. I have a few Pi’s for different uses and each have done the same thing at one time or another… not booted up and a quick turn the power off and on and they come right up. They have different power supplies so I think it is something with the RPi 3 B+. One power supply is from the Canakit, one is a 3 amp I bought and another is a 5 volt 5 amp tap from a transformer so they all should have plenty of power.

The remote database is kind of a no-brainer depending on what you have to run it on. I could not believe how easy it was to setup.

I have a windows 10 machine available. Do you know if that will play nicely?

Just make sure that if you move to an external DB server, that it is always up and running. So a desktop is probably not a good candidate. Also, you would need to shutdown HA before you do maintenance/updates on the DB server system.

After my SD card died recently I switched to MariaDB on Synology using Docker, very simple and a noticeable speed boost too on the HA responsiveness.

What did surprise me was a raise from 30 IOPS to 100 IOPS average disk activity on the Synology; even though I have pruned what is sent to the recorder the amount of transactions from HA is still more than I’d expect. Not sure of the cause of those yet, I have to look into some further monitoring tools to trace activity. I’d be shocked if HA team have spent much time assessing efficiency of transactions.