mrdebug
Posts: 72
Joined: Sun Apr 07, 2013 6:08 pm

Prevent SD-Card Corruption

Mon Jun 08, 2015 6:42 pm

Hi. I have started a project based on raspberry pi.
The raspberry pi will never switched off. My program writes something in a sqlite database 10 times for each day.
Now, having 3 prototypes switched on 10 months ago more less, today I have replaced the second flash card because broken.
Is there a way to know why a flash will be broken? Is a problem related to a bad flash quality?
www. ???
www. ???
GMT+1
Skype: mrdebug

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13003
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Prevent SD-Card Corruption

Mon Jun 08, 2015 6:50 pm

just buy a good quality SD-Card, its 99% of the solution!

sd-cards are not like floppies, they are flash-memory banks with a memory controller, a bad controller can corrupt the flash-memory easily, a good one won't corrupt the flash-memory, and will make sure to not continuously write to the same flash memory cells.

Also, (generic, not specific to your situation) when doing a shutdown, wait long enough before disconnecting the power!

Heater
Posts: 15831
Joined: Tue Jul 17, 2012 3:02 pm

Re: Prevent SD-Card Corruption

Mon Jun 08, 2015 9:41 pm

mahjongg,
..a bad controller can corrupt the flash-memory easily, a good one won't corrupt the flash-memory,..
OK, so which are the good ones and which are the bad ones?

In my experience SD cards go bad no matter what you do. That experience is across all Pi versions since the beginning and many different SD card brands and types.

Perhaps the only way to prevent corruption is to ensure all the file systems are only ever mounted as read only. Which of course means writing to a database on the card is a no-no.
Last edited by Heater on Tue Jun 09, 2015 8:51 am, edited 1 time in total.
Memory in C++ is a leaky abstraction .

Richdotward
Posts: 17
Joined: Fri Mar 08, 2013 6:35 pm

Re: Prevent SD-Card Corruption

Tue Jun 09, 2015 5:09 am

100 % fix is to run everything from a laptop hardrive. Had corruption about once per week. Installed os to hd and 18 months later 24/7 not a single problem.

Return to “General discussion”