data corruption & Raspberry Pi
Posted: Fri Feb 13, 2015 10:59 am
Hi everyone,
I use my pi to play music 24x7. It connects to internet every day to download new songs if its playlist has been updated. After a couple of months struggling with my pi freezing (ACT green solid) I realised that sometimes the new songs contained one or more corrupted blocks and once there are no backup blocks for corrupt blocks the drive is considered to be "falling"...
I tried to implement a fix to detect such cases, and remove corrupted files before they can cause any problem. This is how:
- All songs are in a second partition /dev/mmcblk0p3
- At boot, before the partition with the songs is mounted I run the following script.
well, the code works just fine, but the problem is that even checking the filesystem on boot, before it is mounted will cause the system to crash, and I haven't been able to find any work around.
Any suggestions??
I use my pi to play music 24x7. It connects to internet every day to download new songs if its playlist has been updated. After a couple of months struggling with my pi freezing (ACT green solid) I realised that sometimes the new songs contained one or more corrupted blocks and once there are no backup blocks for corrupt blocks the drive is considered to be "falling"...
I tried to implement a fix to detect such cases, and remove corrupted files before they can cause any problem. This is how:
- All songs are in a second partition /dev/mmcblk0p3
- At boot, before the partition with the songs is mounted I run the following script.
Code: Select all
// loops each song file and $line will contain the name of the i-th song
debugfs -R "ls -p /var/www/music" /dev/mmcblk0p3 | cut -d / -f 6 | while read line
// returns start and end block for $line song file
blocks = $(debugfs -R "ls /var/www/music/$line" /dev/mmcblk0p3 | sed -n 13p | grep -Po '(?<=:).*')
block_start=${blocks%%-*}
block_end=${blocks##*-}
badblocks -b 4096 -nsv /dev/mmcblk0p3 $block_end $block_start
if [ $? -ne 0 ] ; then
//remove song
fi
done
Any suggestions??