LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-06-2012, 02:15 PM   #1
Lobinho
Member
 
Registered: May 2010
Distribution: Ubuntu
Posts: 72

Rep: Reputation: 18
Corrupted files on SD card - ext3 will solve?


Hi,

I'm working on a data logger project. My system is running over an ARM9 (mini2440), with a custom kernel (version 2.6.32.2) and the file system is yaffs.
The main program was written in c++ and uses a database (sqlite 3.7.8) to store all collected data.

I need to save everything on the database wich is placed on a sd card. The sdcard was formatted with FAT.
Sometimes the files inside it gets corrupted. So I need to run the "chkdsk" windows command to try to recover those files (sometimes I can't, and this is really boring).
Sometimes the equipment is suddenly powered down (I can't avoid it), and I think that's a possible (or the main) reason of the problem.

I decided to change from FAT to EXT3, because EXT3 have the journaling system (I read that journal keeps the information about file operations). I think that journal could help me, but I'm not sure. I'm very noob on linux.

So, I have 2 questions.

1 - Using the EXT3 filesystem, will really help to prevent those corruptions?

2 - Is there another way to prevent that?


Tutorials, books and any links are welcome


Anyway, I was trying to test the EXT3 file system, but i'm stuck on a problem: EXT3-fs: mounted filesystem with writeback data mode.

I used "gparted" to format my sdcard, and then I created an ext3 partition. On my PC (ubuntu 8.04) I can read and write files inside it. But when I try to mount it on ARM, i got the above error.

I'm using the following command line:
Code:
# mount -o async -o noatime -o rw -t ext3 /dev/mmcblk0p5 /sdcard
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with writeback data mode.
The device is 'correctly' mounted. I can cd to /sdcard and ls the files normally, but I can't write anything. It's mounted with read only mode.

Code:
# touch test.txt
touch: test.txt: Read-only file system
df command:
Code:
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               256640     28132    228508  11% /
tmpfs                    29496         0     29496   0% /dev/shm
/dev/mmcblk0p5         1904536     35664   1772888   2% /sdcard
Can someone help me with this too?

Thanks in advance
 
Old 01-06-2012, 08:48 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,020

Rep: Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102Reputation: 4102
That message is informational, not an error. Although I don't like writeback.
Did you try the mkfs on ARM ?.
 
Old 01-09-2012, 05:03 AM   #3
Lobinho
Member
 
Registered: May 2010
Distribution: Ubuntu
Posts: 72

Original Poster
Rep: Reputation: 18
Hi syg00,

I have mkfs on Ubuntu, but i don't have the compiled version for ARM. I'd tried to use the mkfs on PC, just to format the SD card, but I have no success. So I use gparted to format the sd.
 
Old 01-09-2012, 11:03 AM   #4
Lobinho
Member
 
Registered: May 2010
Distribution: Ubuntu
Posts: 72

Original Poster
Rep: Reputation: 18
I discovered that EXT3 have 3 operation modes (http://linux.die.net/man/8/mount):
Quote:
journal - All data is committed into the journal prior to being written into the main filesystem.
ordered (default) - This is the default mode. All data is forced directly out to the main file system prior to its metadata being committed to the journal.
writeback - Data ordering is not preserved - data may be written into the main filesystem after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal filesystem integrity, however it can allow old data to appear in files after a crash and journal recovery.
Journal mode seems to be the safest, but is slower.

About the read only mode, I don't figure out what is wrong, but I changed my command line to:
Code:
mount -o async,noatime,rw -t ext3 -o data=journal,rw /dev/sdcard /sdcard
mount -o remount,rw /sdcard
I think this will prevent any data loss when the supply is cut. There any other suggestions?
 
Old 01-09-2012, 06:10 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Moved: This thread is more suitable in the Linux Embedded forum and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 01-12-2012, 05:01 AM   #6
cnxsoft
Member
 
Registered: Nov 2010
Location: Thailand
Distribution: Fedora 12, Ubuntu 10.10
Posts: 166

Rep: Reputation: 29
If your board is suddenly powered off as data is written to the disk, then corruption is unavoidable, unless your hardware could be changed to include a small battery to turn off the device if the mains are down.

I've had this problem in the past. You can try to minimize the problem by changing your software to decrease the number of writes if possible and flushing the cache (fsync) after each writes to make sure data is written as soon as possible and reduce the odds of corruption.

You could also run e2fsck or dosfsck (depending on FS used) to repair the disk at boot time.

With the FAT file system, the SD card often mounted as Read-Only, with ext2 there were also problems, but e2fsck seemed better than dosfsck to fix the issues.
 
Old 10-15-2012, 10:28 AM   #7
wilsong
LQ Newbie
 
Registered: Oct 2012
Posts: 1

Rep: Reputation: Disabled
Hello There,
SD cards are the foremost medium to save the data and this faces the corruption very often which lead the data to loss. SD card corruption have many reason behind it, this problem is faced by me many times and result of that i have lost files many times.
So after the loss i searched on internet and found the software which was very effective to do corrupted SDHC card recovery. The software can be used to recover the data from all sort of memory cards.

The download link is
[mod removed spam link]
Regards
Wilsong

Last edited by onebuck; 10-16-2012 at 08:26 AM. Reason: mod removed spam link
 
Old 10-16-2012, 08:25 AM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,906
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Moderator Response

Hi,

Welcome to LQ!

Quote:
Originally Posted by wilsong View Post
Hello There,
SD cards are the foremost medium to save the data and this faces the corruption very often which lead the data to loss. SD card corruption have many reason behind it, this problem is faced by me many times and result of that i have lost files many times.
So after the loss i searched on internet and found the software which was very effective to do corrupted SDHC card recovery. The software can be used to recover the data from all sort of memory cards.

The download link is
[mod removed spam link]

Regards
Wilsong
You are correct for the power interruption causing issues for a 'SDHC' memory corruption. Sadly, the link you provided is for a MS & OSX recovery method using those propriety OS. Plus the linked software is crippleware.

OP(Original Post) stated: 'So I need to run the "chkdsk" windows command to try to recover those files (sometimes I can't, and this is really boring)'. so from that quote I see the OP needs a recovery method using Gnu/Linux not MS or OSX.

Please re-read the LQ Rules
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
EXT3-fs: group descriptors corrupted! secretlydead Linux - Hardware 1 01-31-2010 09:34 AM
repair corrupted ext3 filesystem rvijay17 Linux - General 3 06-20-2009 12:35 PM
Can a corrupted ext3 filesystem be saved? erraticassassin Slackware 3 09-16-2005 02:45 PM
Corrupted Ext3 Filesystem pyrosim Linux - General 2 07-23-2005 12:21 PM
Corrupted ext3 Filesystem. How do I fix it? Apollo77 Linux - General 6 02-12-2004 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration