Raspberry Pi SD Card Corruption Fix

Published: 2014-08-24
Tagged: raspberry-pi linux guide

Another post in the "note to self for future reference" series. Nothing sucks more than coming home after work, hitting play on an MPD client to get some music into your tired out head and getting nothing.

What happened was that the sd card that I run my Pi off of became corrupted. I've used it in my Pi for about 9 months and kaput. The most telling sign is the ACT diode flashing regularly at about 2HZ and if you happen to be ssh'ed in - stderr will print out journaling errors.

FSCK wasn't able to fix it, but it was worth a try. What did however helped was to move the root file system to a usb thumbdrive. Even though this is flash memory as well, I hope it'll last out longer and if not, I'll have to check out 2.5" external hard drives.


It's simple as pie (no pun intended):

First we have to make a good copy, saving permission and everything. Doing this is real easy with rsync:

# assuming usb drive is /dev/sda1/ and mounted on /mnt/usb
sudo rsync -axv / /usb

Then we'll edit the fstab file to automount /dev/sda1 as / by adding this entry to the /etc/fstab file and commenting out the existing root mount:

/dev/sda1       /      ext4     defaults,noatime     0  1

Finally we have to edit the raspberry pi boot configuration file to tell the pi to boot off of /dev/sda1. The file sits under /boot/cmdline.txt and edit the root= entry as well as add rootdelay=5 so the whole entry looks like this:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=deadline rootwait rootdelay=5

Then a shutdown -r now and you should be all set. Also, note to self: what might aid in sd card corruption is the power supply perhaps. Testing out another power supply now and we'll see how long the usb drive lasts.


There aren't any comments here.

Add new comment