30

My Raspberry Pi was running fine for two months. Then some files in /usr/bin got corrupted and there were many errors on reboot.

I tried to write a fresh image but dd would block and do nothing.

sudo dd if=~/2013-02-09-wheezy-raspbian.img of=/dev/mmcblk0 bs=4M

I noticed that my SD card was not listed as compatible, so I started with a new supported SD card a week ago and now the same thing has happened.

The cards seem to be stuck in a read-only state, and dd and fdisk have no impact.

I did pull the power cord a few times to reboot after ssh stopped working - I run it without a monitor and keyboard.

Is it possible to permanently damage an SD card by pulling the power cord?

I have read about corrupted SD cards and would like to get to the bottom of that problem, but my current concern is that I need to buy a new SD card each time I try. For other people they seem to be able to start again by writing a new image.

Is there anything else I can try to get the SD cards working again?

If I try to format the card with my camera it says 'format error'.

When I insert the SD card dmesg shows

...
[52254.614980] end_request: I/O error, dev mmcblk0, sector 1696056
[52254.614983] end_request: I/O error, dev mmcblk0, sector 1696064
[52254.614987] end_request: I/O error, dev mmcblk0, sector 1696072
[52254.615058] Aborting journal on device mmcblk0p2-8.
...
[52666.031183] journal commit I/O error
[52666.031186] journal commit I/O error
....
[52666.031220] journal commit I/O error
[52666.031227] journal commit I/O error
[52666.083902] EXT4-fs error (device mmcblk0p2): ext4_put_super:819:     
Couldn't clean up the journal
[52666.083910] EXT4-fs (mmcblk0p2): Remounting filesystem read-only

Update: I have managed to write a fresh image to the second SD card, but the first card (Kingston 8 GB class 4, not on the supported list) is still broken. As it's only one card which seems broken I am not so concerned that it will keep happening. I guess this was a one-off.

My Raspberry Pi now rarely boots. I checked the voltage on the Raspberry Pi, and it is quite low, so I suspect that it is the cause of my troubles. I have ordered a new power supply. However, I don't know why the Raspberry Pi worked for so long before.

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
Thomas Rynne
  • 401
  • 1
  • 4
  • 4
  • 1
    Could you please confirm that when you try to write something to broken cards you are using some other computer with SD card reader that works OK for other cards? Could you provide the dd command you are using to write to the card? Could you please check dmesg to see if there are any I/O errors about your card? – Krzysztof Adamski Apr 15 '13 at 08:56
  • If you're going to cut power to the Pi make sure it is abruptly and not slowly. Pulling the cord out slowly can and will corrupt your SD cards eventually. I strongly suggest getting a power source with a power switch. Once I started using a power switch instead of just pulling the power cord from the Pi I've never had an SD card corrupted. Also, your choice of power supply is very important. Make sure it is at least 1000 mA and has a consistent output. I also would not power the Pi from the same USB hub you're using to connect it to devices. – Jerry Gagnon Jul 09 '13 at 13:00
  • 1
    Had the same problem, absolutely bizarre corruption making booting a crap shoot. After getting a dedicated Raspberry Pi certified power supply and a new SD card all my problems went away. The old SD card could only be used again after finding a Windows machine and running the free low level formatter from the SD association. They state that no block level formatter can produce the true low level formatting needed to completely repair problematic SD cards. YMYV – rob Nov 03 '13 at 21:36
  • I have three Raspberry Pi's and have had the same issue. I've now had two SD cards become corrupt and read-only and no tricks using fsck, fdisk or any other utilities in Linux or Windows fixed them. On a whim, I decided to throw one of the cards into my Samsung camera and try formatting it. To my surprise and delight, the format function in the camera restored the card and it is usable again. Unfortunately, I cannot recover the other card with this as it is a full size SD card and not a MicroSD with an adapter and my camera has the MicroSD slot. Camera is a Samsung ST72, just FYI. – Kelli Mac Nov 04 '13 at 15:10

5 Answers5

12

Issues and Potential Damage

Yes, shutting down the Raspberry Pi by pulling out the cord can cause damage. In fact, there was an answer which detailed this issue exactly. This issue is not specific to the Raspberry Pi. Taking the power cable out without warning to the OS can cause issues - I corrupted my Windows kernel that way.

How to fix

  1. Mac

Plug the SD card into the Mac. Then, open Disk utility and delete your partitions. Then restore. Finally, re-image the card. If you need any more help, please see this tutorial.

  1. Windows

Use the Win32 Disk Imager Software. Again, delete the partitions, restore it, and then re-image the card.

  1. Linux

To reset the SD to read-write, type hdparm -r0 /dev/xxx into the terminal. You may have to delete the partitions first.

How to avoid

From now on, you should never shut down the Raspberry Pi by unplugging it. Instead, go to the console and type:

sudo shutdown -h now

Or, if you are using startx, click the log off button and select shutdown.

xxmbabanexx
  • 3,258
  • 7
  • 35
  • 56
  • 16
    As far as I know it is not possible to damage SD card itself by pulling out the power. It is possible to damage filesystem on the card, however. – Krzysztof Adamski Apr 15 '13 at 17:42
  • 3
    Most modern filesystems are journeling file systems and won't be corrupted by losing power this way (though they might lose the most current changes). However, memory cards tend to lie to the kernel about what has been sync'd out. THIS leads to corrupt filesystems. – DonGar May 03 '13 at 21:04
  • I've had unexpected power outages fry my SD card to where no amount of wiping and re-imaging would "take", there seemed to be bad sectors that would make the reinstall fail. I had to buy a new card. So yes, you can damage the card itself. – Yamikuronue Jul 09 '13 at 15:17
  • Another, shorter way of turning off the pi is 'sudo halt'. – Matthew Aug 10 '13 at 17:37
  • A better way to reformat SD cards on Windows and Mac OS is to use the SD Association's SD Formatter. It's the official way you're supposed to hard-format cards. – scruss Jun 22 '15 at 22:27
  • I experienced a lot of damages until I replaced my cheap power adapter by a Samsung power adapter for a Galaxy S4.

  • After shut down always wait a few seconds before switching the power off.

  • In case your SD card looks damaged and has become unusable in Windows try to format it on a camera. I could always reformat my SD cards in my Digital IXUS 400.

  • –  Jan 07 '16 at 15:54
  • @OP do you really need to delete the partitions? I don't think it's necessary when you re-image it. – Aloha Feb 26 '16 at 02:02