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.

  • 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 8: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 9 '13 at 13:00
  • 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 3 '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 4 '13 at 15:10

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.

  • 12
    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
  • 1
    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 3 '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 9 '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

The problem is that you can't go to the console as the Raspberry Pi is hung, SSH works partly but won't accept a password, and Adafruit's WebIDE is hung and will not accept input. There is no choice but to pull the plug. About 25% of the time this works but it is inevitable that the file system gets corrupted eventually. It gets worse as even though the boot loader drops you to the kernel it too is hung and you can't type anything to fsck the card. Reimaging means losing all of your work. We definitely need a better solution.

You can use 'hdparm -r0 /dev/xxx' to reset it to read-write. I personally had to delete the partitions and reinsert the sdcard to be able to use dd to copy a new image to the card.

  • I tried this, but dd still blocks. I think the card must be broken. – Thomas Rynne Apr 16 '13 at 23:06

There is a better solution - just put the card into a reader attached to another machine and run fsck from that machine [then hope it works!]. Of course, the real issue is having to run fsck in the first place - which can often be avoided by shutting down the machine properly as opposed to pulling power, regardless of whether or not it's headless.

After dd failed on an SD card repeatedly, I used a Windows 7 machine to delete the partitions and reformat as FAT32. Only then would dd give me a working Raspberry Pi image.

Now I often run the following before dd(or dcfldd)-ing a new image:

time dcfldd if=/dev/zero of=/dev/sdc statusinterval=1 sizeprobe=of

The source suggesting /dev/zero did note that the process may shorten the life of the card.

protected by Community Nov 5 '13 at 3:20

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.