SyncingFeeling
Posts: 45
Joined: Thu Jan 03, 2013 9:15 pm

SD Card corruption, how to determine cause?

Tue Jun 11, 2013 5:36 pm

I have had a lot of SD Card card corruption problems. It boots up most of the time, but not always. Most often the error is "journal commit i/o error".

I am at a loss to determine the cause. Here is what I have eliminated and how:

* I have not shut down the pi improperly.

* After it became corrupted, I ran the following test. I formatted the card using SDFormatter, as recommended. I re-imaged the card. On this brand new image, I set up a cron job to reboot after every 10 minutes. I got a failed reboot after about 3 hours. So I concluded the corruption was not caused by any software I installed.

* The card, then? I tried 2 different cards. Same result. Both passed error checking fine (on both chkdsk and badblocks). Both were card sold by 'modmypi' and are compatible models.

* Too many peripherals? I removed everything except the USB keyboard. Same problem.

* There is no overclocking on these 10-min reboot tests.

* The warranty bit is not set, so the pi is not fried.

* The firmware updates don't make any difference.

* Believe me: I am not shutting down the pi improperly. Really :)

The only thing I can think is left is the power supply, although this was also from modmypi. The thing is my case is not one that can be opened, so I don't want to check it with the voltmetre unless I absolutely have to (this will involve damaging the case, and could give me warranty problems).

In the logs, how can I verify this is indeed a power supply problem? I'm just not sure what logs are for what :(.
Last edited by SyncingFeeling on Tue Jun 11, 2013 6:17 pm, edited 1 time in total.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: SD Card corruption, how to determine cause?

Tue Jun 11, 2013 5:51 pm

Most likely cause is loss of power during boot up or shut down. Typically not caused by the power supply.

First step to trouble shoot is how do you shut down when do you remove power from the pi (wait until the green led flashes in series)
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

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

Re: SD Card corruption, how to determine cause?

Tue Jun 11, 2013 5:54 pm

How do you shutdown?
Do you follow the normal shutdown procedure?
That is do you do a:

Code: Select all

sudo shutdown -h now
then wait for the PI to shutdown to finsh, then wait another few seconds so that the logic in the card itself can finish all the work it may still have to do, and only then remove power?

Shutdown faults are the prime reason for damaged file systems.

When the PI does a shutdown, it actually does an partial reboot, at the end of which it blinks the green led several times (I think it was six times if I remember it well). By the time it does that most SD-cards should have finished writing stuff as well.

SyncingFeeling
Posts: 45
Joined: Thu Jan 03, 2013 9:15 pm

Re: SD Card corruption, how to determine cause?

Tue Jun 11, 2013 6:15 pm

Yes, I know about how to shutdown. Since re-imaging it I have only ever shutdown -r'd anyway.

broo0ose
Posts: 317
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK

Re: SD Card corruption, how to determine cause?

Tue Jun 11, 2013 8:50 pm

I've had similar problems with shutdowns and reboots, I ended up disabling the swapfile and that seems to have helped.

maybe run these commands and then repeat your tests ...

Code: Select all

sudo chmod -x /etc/init.d/dphys-swapfile
sudo sync
sudo swapoff -a
sudo apt-get purge -y dphys-swapfile
sudo rm /var/swap
sudo sync
sudo reboot

broo0ose
Posts: 317
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK

Re: SD Card corruption, how to determine cause?

Wed Jun 12, 2013 12:14 pm

I spoke too soon, one of my Pis just corrupted its card after about 3 weeks uptime.

User avatar
hojnikb
Posts: 128
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home

Re: SD Card corruption, how to determine cause?

Wed Jun 12, 2013 7:21 pm

just use usb drive for rootfs and no such problems should accur..
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz :o, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian

SyncingFeeling
Posts: 45
Joined: Thu Jan 03, 2013 9:15 pm

Re: SD Card corruption, how to determine cause?

Mon Jun 17, 2013 4:28 pm

Thanks for the usb suggestion, I set up a script to keep rebooting, and it's done it a few dozen times without issue.

SyncingFeeling
Posts: 45
Joined: Thu Jan 03, 2013 9:15 pm

Re: SD Card corruption, how to determine cause?

Mon Jun 17, 2013 4:32 pm

broo0ose wrote:I've had similar problems with shutdowns and reboots, I ended up disabling the swapfile and that seems to have helped. maybe run these commands and then repeat your tests ...
I tried your way, and the pi managed to boot, but with all kinds of bizarre errors (such as forgetting the hostname, so that instead of pi@raspberry the prompt was pi@none)

Return to “Troubleshooting”