Fwd: microSD && ext3 file system

Matthias Apitz guru at unixarea.de
Wed Apr 4 05:25:24 UTC 2012


I have some trouble with a microSD card (or with the controler) in my
Linux based cellphone (Openmoko Freerunner). One of the hints I got is
to check the microSD card with a Linux tool badblocks(8)

As I do not have Linux boxes at home, I looked into our ports with no
luck for badblocks... Is there some equivalent in FreeBSD which I could
use to check /dev/da0 (as this the microSD is presented in my laptop)
for bad 'sectors'?

FWIW, I've found as well this very interesting article:
which says for example:

«... In contrast, the more common SD cards and USB flash drives are very
sensitive to specific access patterns and can show very high latencies
for writes unless they are used with the preformatted FAT32 file layout.

As an example, a desktop machine using a 16 GB, 25 MB/s CompactFlash
card to hold an ext3 root filesystem ended up freezing the user
interface for minutes during phases of intensive block I/O, despite
having gigabytes of free RAM available. Similar problems often happen on
small embedded and mobile machines that rely on SD cards for their file
systems. ...» 



----- Forwarded message from Matthias Apitz <guru at unixarea.de> -----

Date: Mon, 2 Apr 2012 19:52:40 +0200
From: Matthias Apitz <guru at unixarea.de>
To: community at lists.openmoko.org
Subject: microSD && ext3 file system


After some hours of testing I'm now totally lost with creating an ext3
file system on a (new) 4GB micro SD card.

Using my FR (running SHR) I created one new partition on the SD with
fdisk(1) and it looks like this:

root at om-gta02 ~ # fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 3953 MB, 3953131520 bytes
4 heads, 16 sectors/track, 120640 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier: 0x0aecb0ac

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1      120640     3860472   83  Linux

Then I created the ext3 file system on it with:

root at om-gta02 ~ # mkfs.ext3 /dev/mmcblk0p1
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
241440 inodes, 965118 blocks
48255 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=989855744
30 block groups
32768 blocks per group, 32768 fragments per group
8048 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

now mounting against the /etc/fstab line failes:

root at om-gta02 ~ # mount /media/card
mount: wrong fs type, bad option, bad superblock on /dev/mmcblk0p1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

mounting with "-t ext3" works and after this as well mounting with the
normal line in fstab(5) works too:

root at om-gta02 ~ # mount -t ext3 /dev/mmcblk0p1 /media/card
root at om-gta02 ~ # umount /media/card
root at om-gta02 ~ # mount /media/card
root at om-gta02 ~ # 

and it is really mounted:

root at om-gta02 ~ # mount
/dev/mmcblk0p1 on /media/card type ext3 (rw,errors=continue,data=ordered)

now I create a dir and copy over some files from the host connected via

root at om-gta02 ~ # mkdir /media/card/dic


$ scp -rp stardict-duden-2.4.2 root at miko:/media/card/dic
duden.ifo                                     100%  155     0.2KB/s   00:00    
duden.idx                                     100% 2360KB 786.7KB/s   00:03    
duden.dict.dz                                 100% 6719KB 559.9KB/s   00:12    
scp: /media/card/dic/stardict-duden-2.4.2/duden.dict.dz: Read-only file system
scp: /media/card/dic/stardict-duden-2.4.2/duden.idx.oft: Read-only file system
scp: /media/card/dic/stardict-duden-2.4.2/duden(2).idx.oft: Read-only file system

the SCP fails and magically now the SD in the FR is mounted read-only:

root at om-gta02 ~ # mount
/dev/mmcblk0p1 on /media/card type ext3 (ro,errors=continue,data=ordered)

What is wrong or what do I wrong with this SD card?

Matthias Apitz
e <guru at unixarea.de> - w http://www.unixarea.de/
UNIX since V7 on PDP-11, UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2, FreeBSD since 2.2.5

Openmoko community mailing list
community at lists.openmoko.org

----- End forwarded message -----

Matthias Apitz
t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211
e <guru at unixarea.de> - w http://www.unixarea.de/
UNIX since V7 on PDP-11 | UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2 | FreeBSD since 2.2.5

More information about the freebsd-questions mailing list