awx
Posts: 2
Joined: Sat Nov 10, 2012 12:17 am

Is there a way to prevent the SD card from getting corrupt?

Sat Nov 10, 2012 12:42 am

Hi,

I am playing since 3 days with the Raspberry Pi, learned a lot about Linux and I really like this little computer :-) BUT during this time, the SD card gets corrupt a dozen times (I used 4 different cards).
Reasons for this were Crashes/Freezes but mostly just to turn off the RasPi without shutdown.

This might become a serious problem for my next project -> I want to build a headless (no keyboard / monitor) webcam-server for a friend of mine, he´s quite old and has no idea about copy image files to a SD card or ssh and all the rest. It will happen that the RasPi will be turned on and off a couple of times without propper shutdown.

I guess to make the SD card read only won´t work, because of the missing switch at the SD card holder on the RasPi board.

BUT what if the root filesystem will be moved to an USB stick? After this the SD card will only be used for booting up the RasPi - the "work" itself happens then on the USB stick. Can this be an option or is a filesystem on USB stick also in the same danger to get corrupted?

Or is there an other solution for this?

I hope s/o can answer my questions, Thanks in advance...

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24923
Joined: Sat Jul 30, 2011 7:41 pm

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 9:12 am

We are looking in to the corruption issue. It's seem more common if overclocked, so turn that off if on. I believe people have put the rootfs on a USB stick - you';ll need to google for that.

Also, might be worth trying a different card, perhaps class 6 rather than higher.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 9:27 am

I have this issue too, i think it depends on SD, when im using a class4 SD card, it happens, but once i swap to a class10 SD, it no longer happen.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24923
Joined: Sat Jul 30, 2011 7:41 pm

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 9:41 am

Narf03 wrote:I have this issue too, i think it depends on SD, when im using a class4 SD card, it happens, but once i swap to a class10 SD, it no longer happen.
That's interesting, thanks for the information.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Cael
Posts: 93
Joined: Sat Jul 07, 2012 7:08 am

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 11:31 am

if your overclocking, try adding this to your config.txt

initial_turbo=30

(sets it to run in turbo mode for 30 seconds at boot time)
im seeing it on Microcenter brand Class 10's as well without that

awx
Posts: 2
Joined: Sat Nov 10, 2012 12:17 am

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 2:57 pm

Hi, thanks for the answers...

No, I do not overclocking the RasPi, but I had a look which classes my SD cards are (4 and 6).
So i will buy a class 10 card and try it with this one...

Maybe a survey regarding used SD cards and entered problems might be helpfull to give a recommendation which SD cards are best to use...

Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 5:40 pm

awx wrote:Hi, thanks for the answers...

No, I do not overclocking the RasPi, but I had a look which classes my SD cards are (4 and 6).
So i will buy a class 10 card and try it with this one...

Maybe a survey regarding used SD cards and entered problems might be helpfull to give a recommendation which SD cards are best to use...
Please do not blame me if your class 10 also have the same issue =]
But do share with us your test result. Thanks.

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 11:04 pm

I'm kicking myself for updating one of my IMPORTANT images a few hours ago...
I will fsck the fs later in hope of salvage but it ended in a bang...

And since "real men don't take backups, they redo the work instead" I might have to start over with my directfb driven uae project...

8GB Micro SD class 2 was the memory card to take the hit.

Perhaps you should revert the commit that caused the fragmentation until solved?
There's nothing in the git about the issue - not that I saw anyway...
Raspberry Pi - finally a worthy replacement for A500!!!

metis
Posts: 4
Joined: Mon Nov 05, 2012 8:23 pm

Re: Is there a way to prevent the SD card from getting corru

Sat Nov 10, 2012 11:43 pm

SD card corruption has nothing to do with the class of the card. I own many different SD cards, and they all corrupted (class 2 to class 10). To avoid SD card corruption, I added the flag "sync" in the option collumn in the fstab file for the root partition. The filesystem is more consistent this way and less in a corruptable state since the os writes the data right now on the card. Otherwise, it can be made a a later time and corrupt the filesystem. The only drawback is that the write speed is reduced when using this flag. But until the card corruption is not fixed I recommend to use this flag.

embeddedsys
Posts: 7
Joined: Tue Nov 06, 2012 8:36 pm

Re: Is there a way to prevent the SD card from getting corru

Sun Nov 11, 2012 12:35 pm

metis wrote:To avoid SD card corruption, I added the flag "sync" in the option collumn in the fstab file for the root partition.
Can you please give more specific howto for us ?

metis
Posts: 4
Joined: Mon Nov 05, 2012 8:23 pm

Re: Is there a way to prevent the SD card from getting corru

Sun Nov 11, 2012 4:20 pm

In the file /etc/fstab

Partition number may differ

/dev/mmcblk0p3 / ext4 defaults,sync,noatime 0 0

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Is there a way to prevent the SD card from getting corru

Sun Nov 11, 2012 4:42 pm

Must be doing something wrong, none of my 3 Pis have ever corrupted an SD card. I generally but not always shut them down but haven't made any other changes or allowances. All running on Class 4 cards. Some of them have the official overclocking in place. I do run them all headless...
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

summers
Posts: 63
Joined: Mon Jan 30, 2012 4:27 pm

Re: Is there a way to prevent the SD card from getting corru

Mon Nov 12, 2012 11:13 am

Mount all directories off the SD as read only.

Any directory that needs write access, create as a ram disk.

You won't be able to save anything, and will run out of memory at some stage, but should be far more immune to having the power pulled.

Return to “General discussion”