Havinit
Posts: 52
Joined: Sat Feb 09, 2013 12:34 pm

Re: Prevent SD-Card Corruption

Sat May 10, 2014 4:57 pm

Might as well add my report to the pile...

My Pi runs a Raspbian image from mid-December '13, in full-time use as a mailserver and mysql server (the latter only used for spamassassin's database, but that is pretty large now). Using a Transcend Class 10 4GB SDHC card, but (like someone above) I made it a readonly root by moving /var and other writable stuff onto a thumbdrive. /boot is not mounted except during updates.

The "corruption" occurred after I'd taken a backup of the card (dd over ssh). I couldn't reconnect via SSH after that and, because the box is headless and has no way to shutdown gracefully (I must really get around to that :roll: ) I hard-halted it via an inline on/off switch connected to the power unit (RS's finest).

On restoring power it wouldn't boot. I powered off again and checked the storage bits on a laptop: the thumbdrive needed fsck'ing from the hard reset as expected, but the SD was apparently fine (although oddly, e2fsck did hang for about 20-30sec after checking the root partition).

Subsequent attempts (~5 times) got the same results (except the thumbdrive didn't need fsck'ing again, so it never got mounted again).

I conclude that the failure is low-level, maybe that the flash is not initialising fast enough for whatever timeout the Pi imposes on it.

I've had a similar Transcend card fail rapidly on another Pi that's used much less frequently (but that is always shut down gracefully); I wonder if they are just quite crap cards...?

sor
Posts: 1
Joined: Wed May 21, 2014 4:06 am

Re: Prevent SD-Card Corruption

Tue Jun 17, 2014 5:23 am

It sounds like many people are having trouble with power failure. Has anyone tried mounting their filesystem with the "data" journal mode? This essentially makes a copy of the data being written to disk before making the actual write, to recover in the event of outages. Normally this only happens for metadata.

davidtuti
Posts: 83
Joined: Tue Oct 22, 2013 6:21 am

Re: Prevent SD-Card Corruption

Tue Jul 08, 2014 8:37 am

I have corruption sd card in tree sd cards now.So there is some tutorial to can move the necessary filesystem to a flash usb storage?

gkreidl
Posts: 6047
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Prevent SD-Card Corruption

Tue Jul 08, 2014 8:54 am

davidtuti wrote:I have corruption sd card in tree sd cards now.So there is some tutorial to can move the necessary filesystem to a flash usb storage?
Here: http://www.raspberrypi.org/forums/viewt ... 29&t=44177

But a better solution may be an USB HD.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

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

Re: Prevent SD-Card Corruption

Tue Jul 08, 2014 9:31 am

davidtuti wrote:I have corruption sd card in tree sd cards now.So there is some tutorial to can move the necessary filesystem to a flash usb storage?
Couple of things - is your firmware up to date? And how old are the SD cards - they do wear out.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

davidtuti
Posts: 83
Joined: Tue Oct 22, 2013 6:21 am

Re: Prevent SD-Card Corruption

Tue Jul 08, 2014 12:38 pm

The firmware is update.
The sd card have 3 months and I have a power supply is 1.2 mA.

gabriel.klein
Posts: 19
Joined: Mon Jul 28, 2014 1:50 pm

Re: Prevent SD-Card Corruption

Mon Aug 11, 2014 10:40 pm

In my fstab, I have (to avoid corruption...)

vim /etc/fstab
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=64M 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=64M 0 0

Warning some memory is used instead when you write a file/log!

And I have the following cron
@reboot /root/bin/reboot.sh > /dev/null

With
more /root/bin/reboot.sh
/opt/vc/bin/tvservice -o
swapoff -a

swappoff remove the swap. tvservice shut down HDMI (used to avoid energy consumption.)

padel
Posts: 3
Joined: Tue Aug 12, 2014 3:14 am

Re: Prevent SD-Card Corruption

Tue Aug 12, 2014 4:00 am

I am suspicious that the intermittent power interruptions are actually poor contact in the SD card slot. My experience: one 4GB SanDisk SD card with just raspbian OS, works reliably. One 8GB SanDisk SD card that has never been readable on the pi. One 16 GB SanDisk SD card with raspbian and raspbmc, requires frequent attempts to start up even after proper shutdown (via raspbmc shutdown icon or using shutdown from command line). Currently, I have to press down gently on the SDcard in order to get the 16GB card to reliably boot. Otherwise the boot process crashes at various points with various useless results. If this sounds familiar, and anyone has figured out a physical fix to keep the card contacts and slot pins together, please advise. I make this note because loss of contact while the pi is running could corrupt the OS.

davidtuti
Posts: 83
Joined: Tue Oct 22, 2013 6:21 am

Re: Prevent SD-Card Corruption

Tue Aug 12, 2014 6:33 am

I cant solve it using a pendrive like sd card. I don't want buy more sd card

User avatar
r3d4
Posts: 967
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Prevent SD-Card Corruption

Tue Aug 12, 2014 5:04 pm

padel wrote: Currently, I have to press down gently on the SDcard in order to get the 16GB card to reliably boot. Otherwise the boot process crashes at various points with various useless results. If this sounds familiar, and anyone has figured out a physical fix to keep the card contacts and slot pins together, please advise. I make this note because loss of contact while the pi is running could corrupt the OS.
I have not faced the conditions you describe but recall post's stating use of a clothes peg helped booting in some cases , that or replace the sd-slot .. bending the pins abit ?
Real life is, to most, a long second-best, a perpetual compromise between the ideal and the possible.
-
Meanwhile, the sysadmin who accidentally nuked the data reckons "its best not run anything more with sudo today"
-
what about spike milligan?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Prevent SD-Card Corruption

Tue Aug 12, 2014 5:05 pm

clothes peg will work. I replaced the sd slot with a metal one.

padel
Posts: 3
Joined: Tue Aug 12, 2014 3:14 am

Re: Prevent SD-Card Corruption

Tue Aug 12, 2014 10:12 pm

Thanks ShiftPlus1 and r3d4. Will give the old clothes peg a try.

is r3d4 = R2D2 + r1d2?

User avatar
r3d4
Posts: 967
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: Prevent SD-Card Corruption

Thu Aug 14, 2014 5:55 pm

No problem !
padel wrote: is r3d4 = R2D2 + r1d2?
it might be more

( 1, 1, 2, 3, 5, 8, 13, 21 ) +1
=
2, 2, 3, 4, 6, 9, 14, 22

or less this

Code: Select all

fib(8).map(function(num){
  return num + 1;
});
:?
Real life is, to most, a long second-best, a perpetual compromise between the ideal and the possible.
-
Meanwhile, the sysadmin who accidentally nuked the data reckons "its best not run anything more with sudo today"
-
what about spike milligan?

zertyz
Posts: 2
Joined: Mon Aug 26, 2013 9:02 pm

Re: Prevent SD-Card Corruption

Fri Aug 15, 2014 4:08 am

dom wrote: There's no reason to not make the timeout big. A good card will never trigger the small or large timeout.
We know hitting the timeout results in sdcard corruption.
There is an argument to making the timeout infinite (I'd prefer a hang to corruption), but that would make removing a misbehaving sdcard and inserting a good one impossible (In the case I'm running from USB/nfs rootfs).
It seems the timeout just happened to me:

[218862.728402] mmc0: Timeout waiting for hardware interrupt - cmd18.
[218862.741103] mmcblk0: error -110 transferring data, sector 1934688, nr 24, cmd response 0x900, card status 0xb00
[218862.788283] mmcblk0: retrying using single block read

The timeout will break the card or the broken card issued the timeout?

My uname is Linux alarmpi 3.12.26-1-ARCH #1 PREEMPT Fri Aug 8 17:40:14 MDT 2014 armv6l GNU/Linux, installed with NOOB, network version, downloadad a week ago.

My Pi is a model B and isn't overclocked.

The microSD card is a no-branded one (2g, class 4) -- mmcblk0: mmc0:1234 SA02G 1.85 GiB

After the message, reading the whole card with dd gave no errors.

I didn't boot yet. Lets see if I manage to make an image of the card just before booting...

[Update] -- The system operated normally after the incident and also after boot.

[]s
Luiz

jurem
Posts: 3
Joined: Wed Sep 03, 2014 8:22 am

Re: Prevent SD-Card Corruption

Wed Sep 03, 2014 8:27 am

Hi,

I have read this thread and did not find a solution to a problem which causes sudden power failure. It does not happen often but when it does it corrupts SD card and RPi does not boot up again.

Is there a solution to prevent SD corruption with a sudden power failure?

Aydan
Posts: 688
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Prevent SD-Card Corruption

Wed Sep 03, 2014 12:30 pm

jurem wrote:Hi,

I have read this thread and did not find a solution to a problem which causes sudden power failure. It does not happen often but when it does it corrupts SD card and RPi does not boot up again.

Is there a solution to prevent SD corruption with a sudden power failure?
You could try with the root FS on a USB stick or HDD. Usually theyre less prone to corruption due to power failures.
Or you could try to use a UPS to prevent the sudden power loss from happening

Regards
Aydan

User avatar
RaTTuS
Posts: 10412
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Prevent SD-Card Corruption

Wed Sep 03, 2014 12:35 pm

jurem wrote:Hi,

I have read this thread and did not find a solution to a problem which causes sudden power failure. It does not happen often but when it does it corrupts SD card and RPi does not boot up again.

Is there a solution to prevent SD corruption with a sudden power failure?
the only way is to have a battery backup solution if you have sudden power fails and you want to do it properly
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

jurem
Posts: 3
Joined: Wed Sep 03, 2014 8:22 am

Re: Prevent SD-Card Corruption

Thu Sep 04, 2014 9:18 am

RaTTuS wrote:
jurem wrote:Hi,

I have read this thread and did not find a solution to a problem which causes sudden power failure. It does not happen often but when it does it corrupts SD card and RPi does not boot up again.

Is there a solution to prevent SD corruption with a sudden power failure?
the only way is to have a battery backup solution if you have sudden power fails and you want to do it properly
That's what I was afraid of! I am using AVRs (see here) and AVRs hardly need a backup battery for the case of power failure. An AVR wakes up nicely after power is restored back. With my RPi I have made a web radio which does work nicely but it would be strange that beside RPi (packed in it's enclosure) there is a huge LiPo battery backup :roll: I was hoping that there is some sort of SW setting which would prevent RPi to write to SD while Python script is already loaded and running.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Prevent SD-Card Corruption

Thu Sep 04, 2014 9:24 am

Use a read only root and use either an overlay fs or tmpfs to write things to.

jurem
Posts: 3
Joined: Wed Sep 03, 2014 8:22 am

Re: Prevent SD-Card Corruption

Thu Sep 04, 2014 9:42 am

ShiftPlusOne wrote:Use a read only root and use either an overlay fs or tmpfs to write things to.
I am such a newbie in RPi - can you please "translate" that into steps what to do.

User avatar
RaTTuS
Posts: 10412
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Prevent SD-Card Corruption

Thu Sep 04, 2014 9:44 am

How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Prevent SD-Card Corruption

Thu Sep 04, 2014 9:56 am

I don't think the topic fits well into a howto format, since you need to know what you're doing to achieve exactly what you want. It's just a matter of understanding linux, reading documentation and googling bits and pieces.

I'm sure there are tutorials out there though, as RaTTuS has mentioned.

chewmanfoo
Posts: 1
Joined: Wed Feb 20, 2013 4:50 am

Re: Prevent SD-Card Corruption

Thu Jan 08, 2015 3:40 pm

I have 6 pi's in a cluster - I use Kingston 16 GB class 6 cards with short usb cables to two Plugable usb hubs ( http://www.amazon.com/Plugable-Terminus ... le+usb+hub). I have corruption all the time.

I can't boot the pi after properly shutting it down (using shutdown -h now) - it shows disc errors.

1.) does this mean that the sd cards are destroyed? Do I need to replace them? After I pull them out and plug them back into my mac and reformat, all appears to be ok, until the corruption occurs again.

2.) I'm thinking of buying six separate dedicated power supplies, like these: http://www.amazon.com/gp/product/B00GF9 ... YR2W3VAJ0A Would this improve my situation?

I'm sitting here looking at 5 dead pi's because of sd card corruption. I just built these again last night.

johnspackman
Posts: 18
Joined: Tue Jul 16, 2013 9:29 am

Re: Prevent SD-Card Corruption

Fri Jan 09, 2015 7:13 am

It could be that the cards are shot - personally I'd replace them all and see if that improves things. We have around 60 pis and using the standard raspbian they're reliable so long as there are no power cuts; we've since modified the OS so that it uses a read only root FS (all writes are to a ramdisk that's synced to the card once per hour) and it's definately an improvement (no failures so far). The cards I buy are the official NOOBS 8Gb cards.

Having a good PSU is certainly recommended (esp if you're also using USB devices that draw power) - we use these: http://uk.rs-online.com/web/p/plug-in-p ... y/7263069/

mmfc
Posts: 15
Joined: Tue Jan 06, 2015 6:40 pm

Re: Prevent SD-Card Corruption

Fri Jan 09, 2015 11:45 am

I'd never had corruption before, but it seems more likely that this might be my current problem (Pi won't boot from any SD, just tells me it has power... after numerous reformatting/rewriting with different programs etc).

Is the core_freq issue still present in RASPBMC?

Return to “Troubleshooting”