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

Re: Prevent SD-Card Corruption

Fri Nov 29, 2013 9:03 am

The latest firmware has some fixes for SD card corruption that will almost certainly help.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

mosu03ab
Posts: 1
Joined: Tue Dec 24, 2013 9:57 am

Re: Prevent SD-Card Corruption

Tue Dec 24, 2013 10:03 am

The corruption also appears if the write protect is enabled by the physical tab. After underclocking by 33%, the corruptions seemed less frequent.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5099
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Prevent SD-Card Corruption

Tue Dec 24, 2013 11:46 am

mosu03ab wrote:The corruption also appears if the write protect is enabled by the physical tab. After underclocking by 33%, the corruptions seemed less frequent.
The write protect tab is an optional feature of the sdcard host, and does nothing on the Pi.
We believe the sdcard corruption issue is fixed on the Pi with latest firmware. Are you seeing this with updated firmware?

Sdcard corruption is still possible following an unclean shutdown, or following voltage drops from an unstable power supply, and obviously sdcards can eventually fail.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4602
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 Dec 24, 2013 11:53 am

I've noticed I have some cards that work fine in one pi but not another (and I have accumulated quite a few pis now). Then sometimes I have to re-insert the card a few times or push the card against the board to make it boot. Over on IRC I see other people having the same issues once in a while.

I have ordered a the metal replacement slot that was used on the old pi dev boards and will see how I go after replacing the slots.

Is it possible that the remainder of SD card issues are due to poor contact?

tvjon
Posts: 551
Joined: Mon Jan 07, 2013 9:11 am

Re: Prevent SD-Card Corruption

Tue Dec 24, 2013 12:49 pm

[quote="ShiftPlusOne".....
Is it possible that the remainder of SD card issues are due to poor contact?[/quote]


http://www.raspberrypi.org/phpBB3/viewt ... 0e#p405398

videostorm
Posts: 28
Joined: Fri Oct 26, 2012 2:19 am

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 1:35 am

Dom,

Which firmware version has the fixes for the sd card issues?

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1186
Joined: Sat Sep 10, 2011 11:43 am

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 10:51 am

If you download and install the latest Raspbian from the downloads (or use network install in NOOBS) then that has the latest updates to SD card corruption...

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

User avatar
Richard-TX
Posts: 1545
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 11:55 am

Run the command sync before removing power. That should help.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

videostorm
Posts: 28
Joined: Fri Oct 26, 2012 2:19 am

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 3:24 pm

Thanks!

I actually need to know the specific version of GPU code/firmware that the fixes were applied. Also, if the fix was done in the linux kernel which version as well.

I use hundreds of PIs and need to identify which ones require updates for this.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5099
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 3:44 pm

videostorm wrote:I actually need to know the specific version of GPU code/firmware that the fixes were applied. Also, if the fix was done in the linux kernel which version as well.
It's a firmware only fix (i.e. start.elf/fixup.dat not kernel.img). The fix appeared here:
https://github.com/Hexxeh/rpi-firmware/ ... 3f73677fac

so "vcgencmd version" returning Nov 11 or later should be okay.

videostorm
Posts: 28
Joined: Fri Oct 26, 2012 2:19 am

Re: Prevent SD-Card Corruption

Sat Dec 28, 2013 7:30 pm

Thanks again :)

Have you done much experimenting with F2FS for the root partition? If so, any feedback on its stability verses ext4?

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: Prevent SD-Card Corruption

Sun Dec 29, 2013 2:54 pm

So far F2FS has been stable for me

See http://www.raspberrypi.org/phpBB3/viewt ... 29&t=63553

KCE
Posts: 5
Joined: Fri Jun 21, 2013 9:40 am

Re: Prevent SD-Card Corruption

Sat Jan 11, 2014 8:42 pm

Hi. New to this forum so bear with me!
I've had a Pi Mod B for a year now, using Kingston Class 4 8GB SD cards, no overclocking, powered by a Micro USB Mains Power Wall Supply Charger For Raspberry Pi (1000mAh / 1A) from UK Micro. I'm running a regularly-updated build based on 2013-02-09-wheezy-raspbian, and my method has been that after about a week or so of apt-get updates and upgrades (with no apparent file errors), I use Win32 DiskImager to save the image to my PC. However, I frequently get "Error 1117 I/O device error" after writing about 3.5GB. Quite often, the card then fails to boot up in the Pi, so I guess that it's already corrupt. If I reimage the SD card with my last good image file, all seems OK - for a few days ... I've used two models of SD card reader, and I get similar errors when trying to save an updated image using DD on a laptop.
I use "sudo shutdown -h now" and wait 10 minutes after all activity ceases on my wireless adapter before removing power - either switching off the power supply at the mains, or just removing the micro USB plug from the Pi.
Reading a previous post, I've just tried a "sync" before shutting down, and had the same error when trying to save the image.
Any recommendations on how I should be shutting down, please?
Last edited by KCE on Sat Jan 11, 2014 10:32 pm, edited 1 time in total.

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

Re: Prevent SD-Card Corruption

Sat Jan 11, 2014 9:37 pm

Have you tried a new card? The card will remap blocks underneath the partition (this is called wear levelling) and that will randomly move the good data onto the bad blocks

KCE
Posts: 5
Joined: Fri Jun 21, 2013 9:40 am

Re: Prevent SD-Card Corruption

Sat Jan 11, 2014 10:32 pm

Have had the same results with two Kingston 8GB Class 4, which is what made me think it was my shutdown method. Or possibly the power supply - is there an idiot-proof of measuring 5V, say using a multimeter across the GPIO pins, or by software?

User avatar
DougieLawson
Posts: 29714
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Prevent SD-Card Corruption

Sun Jan 12, 2014 1:15 am

The board has two test points (TP1 & TP2) you can measure the voltage across those pins.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5099
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Prevent SD-Card Corruption

Sun Jan 12, 2014 11:34 am

videostorm wrote:Have you done much experimenting with F2FS for the root partition? If so, any feedback on its stability verses ext4?
My OpenELEC install has been f2fs (on USB stick) for a few weeks. No problems so far.

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

Re: Prevent SD-Card Corruption

Sun Jan 12, 2014 5:37 pm

KCE wrote:Have had the same results with two Kingston 8GB Class 4, which is what made me think it was my shutdown method.
It's not that; sync just flushes the cache, which is something that happens automatically at the end of proper shutdown (ie with "sudo shutdown"). it's either a hardware issue (damaged card, dodgy psu, etc) or there is still a bug in raspbian where it does not wait for the card to finish it's own leveling before saying that it's safe to remove the power. In theory that bug has been fixed but if you have a reproducable test case (with a new card) the developers were swapping out kit

KCE
Posts: 5
Joined: Fri Jun 21, 2013 9:40 am

Re: Prevent SD-Card Corruption

Wed Jan 22, 2014 7:52 am

Thanks!
The voltage checked out (under load) at 4.89 - 4.95V, so I assume my existing (and less than 1 year old) Kingston Class 4 8GBs are getting shot, and bought a new card.
As Class 10 cards are competitively priced, I went for a Sandisk C10 8GB. I flashed my latest good image to it, put it in the Pi, downloaded software updates, shut down, copied the new image to my PC. So far, so good – a Class 10 is definitely faster than a Class 4!
I then came to flash the new image to one of the old C4 cards – and it failed ‘Not enough space’. Whaaat!!! Sure enough, when I compared the new image with some older ones, it’s 100+MB bigger …!
I use Win32 Disk Imager. Any ideas as to why a 7,639,040KB image that gets written to the Sandisk C10 comes back as a 7,761,920KB file?

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

Re: Prevent SD-Card Corruption

Wed Jan 22, 2014 8:38 am

AIUI SD cards are only targetted at a size (eg 8gb) but as part of manufacturing they are checked and any bad blocks are mapped out; this means you get minor variations in size.

If you want to copy your larger image to another, smaller card you'll have to resize the filing system & partition to something smaller, then you can make a copy of it onto your other card.

4DallasC
Posts: 6
Joined: Sat Aug 24, 2013 7:22 am

Re: Prevent SD-Card Corruption

Thu Feb 06, 2014 11:58 pm

I'm still having the same problem when the power goes the sd card corrupts. The only fix I've found is to put the sd card into the laptop and run:-
dallas@Dallas-E6530:~/$ sudo fsck /dev/mmcblk0p2
[sudo] password for dallas:
fsck from util-linux 2.20.1
e2fsck 1.42.5 (29-Jul-2012)
/dev/mmcblk0p2: recovering journal
Setting free inodes count to 159129 (was 159132)
Setting free blocks count to 423651 (was 424031)
/dev/mmcblk0p2: clean, 78439/237568 files, 524829/948480 blocks

Then it will again boot from the sd card. The laptop don't need to fix the sd-card to read from it, but the raspberry pi just refuses to read a corrupted card, which is stopping the boot.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1186
Joined: Sat Sep 10, 2011 11:43 am

Re: Prevent SD-Card Corruption

Fri Feb 07, 2014 6:36 am

So what you're saying is the SD card doesn't actually corrupt? It's just getting into a bad state which the Pi can't get it out of but the PC does seem to be able to?

What's the error on the Pi look like?

Was the Pi shutdown correctly when this happened or is it likely to may have happened while the SD card was still actively doing something?

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

4DallasC
Posts: 6
Joined: Sat Aug 24, 2013 7:22 am

Re: Prevent SD-Card Corruption

Sat Feb 22, 2014 4:23 am

Thanks GSH

Yeah, I think you've got the idea. It does not happen all then time. My pi refused to boot so I left it in the corner until reading this message. I again tried to boot and it worked a second time. I'll continue trying to reproduce the error to get more information, but I think it only happens when the power goes from a hot pi (one that has been on for a couple of hours).

There are only a couple of background processes running, probably 5% cpu usage, and most of the memory is free.

Cheers,
Dallas
ekkysoftware.com

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1186
Joined: Sat Sep 10, 2011 11:43 am

Re: Prevent SD-Card Corruption

Sat Feb 22, 2014 7:17 am

gsh wrote: What's the error on the Pi look like?

Was the Pi shutdown correctly when this happened or is it likely to may have happened while the SD card was still actively doing something?

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

cabbers
Posts: 47
Joined: Sat Nov 17, 2012 10:58 am

Re: Prevent SD-Card Corruption

Wed Apr 16, 2014 2:44 pm

Hi all
Jumping on this thread, as I have multiple Pi's, and most have suffered SD card corruption at some point. I'm a Linux noob so most of this I have picked up along the way. Hopefully it helps some people
Starting off with voltage, an interesting test today-Pi has Samsung 8GB SDHC card (has been recommended on these forums), with wifi adaptor Netgear WNDA 3200 Dual Band. Ethernet also connected. So a good test
1.8m cable, that came with the Pi, and approved pwr supply=4.35vdc
0.3m cable, that got online, and approved power supply=4.88vdc
Big difference, as you can see-the first combo was the one I was using, and I have no doubt this was a contributory factor in the last SD card corruption. Lesson for me here, especially if using peripherals, is to keep the cable as short as possible-0.5vdc makes all the difference. Link to the place where I got the cables http://www.kenable.co.uk/?cPath=23_41

This is where I need some feedback-using another Pi, and a USB to SD card reader, I "fixed" the /boot partion by using dosfstools http://daniel-baumann.ch/software/dosfstools/ It seems to do the job, and I have built a small batch script that runs in crontab every day

Code: Select all

!/bin/sh

#Script to check FAT32 disk

sudo umount /dev/mmcblk0p1
sleep 10
sudo dosfsck -w -r -l -a -v -t -V /dev/mmcblk0p1
sleep 10
sudo mount /dev/mmcblk0p1
exit 0
does this sound like a good idea? Also using tune2fs, I now schedule a fsck every 2nd boot. Are there any performance/read/write issues I can expect doing this?

Last thing, some of the Pi's I now have an 8GB Sandisk mini USB drive installed http://www.amazon.co.uk/SanDisk-SDCZ33- ... 2PGEZR2JK4, and so just use the SD card for the original boot. I'm actually thinking is it a bad idea/make any sense to unmount the /boot partion pernamently (until the next boot of course!), as it doesn't seem to do much?

cheers

cabs

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 44 guests