Problems with Ext2fs on a CF card.

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi.
I use a Compact Flash card (SanDisk) to hold an ext2 Linux File System
on an embedded system, running 2.6 Linux.
The CF is connected in true IDE mode.
I have numerous problems  running a File System from the CF: mkfs does
not work on partitions, fsck reports errors after booting from the CF
etc. and the FS gets corrupted over time.
Below is the procedure I follow to put the FS on the CF.
Please advise if you recognize any faults in the procedure or have any
idea what else I can check - any help is most welcome.

Here is what I do:
------------------------
Boot over NFS
mkfs.ext2 /dev/hda
mount -t ext2 /dev/hda /mnt/hda/
cd /mnt/hda
tar -xvjf /my_file_system.tar.bz2
Boot over CF.

Notes and Problems I see:
------------------------
1. cannot mkfs partition
if I use fdisk to create partitions (i.e. hda1, hda2), mkfs fails.
That's why I run it straight on /dev/hda.
fdisk:
Disk /dev/hda: 512 MB, 512483328 bytes
16 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1         497      250456+  83  Linux
/dev/hda2             498         993      249984   83  Linux

mkfs.ext2 /dev/hda1
mke2fs 1.38 (30-Jun-2005)
mkfs.ext2: No such file or directory while trying to determine
filesystem size


2. fsck complains right after untar
fsck -t ext2 /dev/hda
fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)
/dev/hda was not cleanly unmounted, check forced.

3. After booting from CF, and rebooting over NFS to run fsck:
3. After reboot from CF, another reset:
fsck -t ext2 /dev/hda
fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)
/dev/hda was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 85069, i_blocks is 16, should be 2.  Fix<y>? yes
Free blocks count wrong for group #23 (768, counted76%9).
Fix<y>? yes...


Thanks for your help,
                                   Michael


Re: Problems with Ext2fs on a CF card.
Quoted text here. Click to load it


no. first you do an fdisk and setup the partition(s), even if it is only
one partition. After you have setup the partion(s), then you use mkfs
to make the kind of file system you want on each partition e.g.

 mkfs -t ext2 /dev/hda1

If you can't fdisk it then something is up.

When you've made your partitions in fdisk you have done the 'w' command to
write the partition table to disk?



Quoted text here. Click to load it










Re: Problems with Ext2fs on a CF card.

Quoted text here. Click to load it

Why? Linux is quite capable of using a drive without that silly partition
nonsense.

Re: Problems with Ext2fs on a CF card.

Quoted text here. Click to load it


Just because some thing can be done, doesn't mean to say you should do it!

Re: Problems with Ext2fs on a CF card.

Quoted text here. Click to load it

Doesn't mean you shouldn't either.

Re: Problems with Ext2fs on a CF card.
Quoted text here. Click to load it


My reply to that is "I tried that and it kinda works".
Back when I was using PD Optical platters (block addressable read/write media)
I used "mkfs /dev/sdx" to use the entire device
without forfeiting a few k for the partition table.

It's not worth it since the partition table "adds value"
by giving the partition's size and type
which is used by bootloaders, automounters and such.
It's then easier to tell what disks were formatted-and-in-use
even to systems that don't understand the underlying file system format.
--

-- mejeep deMeep ferret!

Re: Problems with Ext2fs on a CF card.

| I use a Compact Flash card (SanDisk) to hold an ext2 Linux File System
| on an embedded system, running 2.6 Linux.
| The CF is connected in true IDE mode.
| I have numerous problems  running a File System from the CF: mkfs does
| not work on partitions, fsck reports errors after booting from the CF
| etc. and the FS gets corrupted over time.
| Below is the procedure I follow to put the FS on the CF.
| Please advise if you recognize any faults in the procedure or have any
| idea what else I can check - any help is most welcome.
|
| Here is what I do:
| ------------------------
| Boot over NFS
| mkfs.ext2 /dev/hda
| mount -t ext2 /dev/hda /mnt/hda/
| cd /mnt/hda
| tar -xvjf /my_file_system.tar.bz2
| Boot over CF.
|
| Notes and Problems I see:
| ------------------------
| 1. cannot mkfs partition
| if I use fdisk to create partitions (i.e. hda1, hda2), mkfs fails.

This issue should be addressed.  CF looks like IDE, so this should
appear to the userspace as a device name for an IDE device.  The
kernel shouldn't even see a difference other than soem manufacturer
ID info and a small size.


| That's why I run it straight on /dev/hda.

Which should also work.


| fdisk:
| Disk /dev/hda: 512 MB, 512483328 bytes
| 16 heads, 63 sectors/track, 993 cylinders
| Units = cylinders of 1008 * 512 = 516096 bytes
|
|   Device Boot      Start         End      Blocks   Id  System
| /dev/hda1               1         497      250456+  83  Linux
| /dev/hda2             498         993      249984   83  Linux
|
| mkfs.ext2 /dev/hda1
| mke2fs 1.38 (30-Jun-2005)
| mkfs.ext2: No such file or directory while trying to determine
| filesystem size

Have you rebooted since fdisk stored the partition table?  There is an
ioctl() to update the kernel's idea of what partitions are present,
but there are times when that can fail.


| 2. fsck complains right after untar
| fsck -t ext2 /dev/hda
| fsck 1.38 (30-Jun-2005)
| e2fsck 1.38 (30-Jun-2005)
| /dev/hda was not cleanly unmounted, check forced.

Something else must be writing on there.

|
| 3. After booting from CF, and rebooting over NFS to run fsck:
| 3. After reboot from CF, another reset:
| fsck -t ext2 /dev/hda
| fsck 1.38 (30-Jun-2005)
| e2fsck 1.38 (30-Jun-2005)
| /dev/hda was not cleanly unmounted, check forced.
| Pass 1: Checking inodes, blocks, and sizes
| Inode 85069, i_blocks is 16, should be 2.  Fix<y>? yes
| Free blocks count wrong for group #23 (768, counted76%9).
| Fix<y>? yes...
|
|
| Thanks for your help,

Try wiping the whole CF clean to zero, then partition it with fdisk, save
the partition table, verify it is saved with "fdisk -l /dev/hda", and
reboot (with NFS, still) again.  Now verify again with "fdisk -l /dev/hda"
and with "dmesg | grep hda".  At this point "mkfs.ext2 /dev/hda1" should
work.  Or maybe try "mke2fs /dev/hda1".  If they fail still, add the -F
option (and be careful you are really typing right).  Verify that your
node is created correctly, too:

root@varuna:/root 1# ls -ld /dev/hda
brw-rw---- 1 root disk 3, 0 2002-06-09 14:27 /dev/hda
root@varuna:/root 2#

If you don't see 3 and 0 in there, something is wrong with the node.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org)  /  Do not send to the address below |
We've slightly trimmed the long signature. Click to see the full one.
Re: Problems with Ext2fs on a CF card.
Quoted text here. Click to load it

Hi.
First, thanks for the help.
I still have the problem, but maybe now I can add some more info:
12E% I followed the recomendation:
12E%1.wipe everything out -
     dd if3D%/dev/zero of3D%/dev/hda
12E%2 fdisk, fdisk -l -
     fdisk -l /dev/hda

Disk /dev/hda: 512 MB, 512483328 bytes
16 heads, 63 sectors/track, 993 cylinders
Units 3D% cylinders of 1008 * 512 3D% 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1         497      250456+  83  Linux
Still, the mkfs does not work:

12E%3 mke2fs -F /dev/hda1
mke2fs 1.38 (30-Jun-2005)
mke2fs: No such file or directory while trying to determine filesystem
size

I also bought a card reader and created the partition and a filesystem
successfully from the Linux host PC:

22E%1 fdisk -l /dev/sdd

Disk /dev/sdd: 512 MB, 512483328 bytes
16 heads, 62 sectors/track, 1009 cylinders
Units 3D% cylinders of 992 * 512 3D% 507904 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         505      250449   83  Linux

22E%2 mke2fs /dev/sdd1
mke2fs 1.35 (28-Feb-2004)
Filesystem label3D%
OS type: Linux
Block size3D%1024 (log3D%0) ....

I then booted over NFS on the embedded.
the fdisk -l successfully read the partition table, but mke2fs failed.

BTW -
I noticed fdisk read the disk info differently:
On the embedded:
16 heads, 63 sectors/track, 993 cylinders
On the host PC:
16 heads, 62 sectors/track, 1009 cylinders

Why can it be?
Can it be the cause of the problems?

Also, the versions I used were:
on the host PC:
mke2fs 1.35, fdisk 2.12a
on the embedded:
mke2fs 1.38
fdisk 2.12

Thanks again,
                       Michael





Re: Problems with Ext2fs on a CF card.

| Hi.
| First, thanks for the help.
| I still have the problem, but maybe now I can add some more info:
| 1. I followed the recomendation:
| 1.1.wipe everything out -
|     dd if=/dev/zero of=/dev/hda
| 1.2 fdisk, fdisk -l -
|     fdisk -l /dev/hda
|
| Disk /dev/hda: 512 MB, 512483328 bytes
| 16 heads, 63 sectors/track, 993 cylinders
| Units = cylinders of 1008 * 512 = 516096 bytes
|
|   Device Boot      Start         End      Blocks   Id  System
| /dev/hda1               1         497      250456+  83  Linux
| Still, the mkfs does not work:

Commands needed:

    cat /proc/partitions

If you do not see "hda1" in the output, then reboot and try again.
If still not after reboot, try this:

    dmesg | fgrep hda

Also do:

    ls -ld /dev/hda1

That should look similar to (and the "3,1" part is important):

brw-rw---- 1 root disk 3, 1 2002-06-09 14:27 /dev/hda1


| 1.3 mke2fs -F /dev/hda1
| mke2fs 1.38 (30-Jun-2005)
| mke2fs: No such file or directory while trying to determine filesystem
| size
|
| I also bought a card reader and created the partition and a filesystem
| successfully from the Linux host PC:
|
| 2.1 fdisk -l /dev/sdd
|
| Disk /dev/sdd: 512 MB, 512483328 bytes
| 16 heads, 62 sectors/track, 1009 cylinders
| Units = cylinders of 992 * 512 = 507904 bytes
|
|   Device Boot      Start         End      Blocks   Id  System
| /dev/sdd1               1         505      250449   83  Linux
|
| 2.2 mke2fs /dev/sdd1
| mke2fs 1.35 (28-Feb-2004)
| Filesystem label=
| OS type: Linux
| Block size10%24 (log=0) ....
|
| I then booted over NFS on the embedded.
| the fdisk -l successfully read the partition table, but mke2fs failed.
|
| BTW -
| I noticed fdisk read the disk info differently:
| On the embedded:
| 16 heads, 63 sectors/track, 993 cylinders
| On the host PC:
| 16 heads, 62 sectors/track, 1009 cylinders
|
| Why can it be?
| Can it be the cause of the problems?

It is probably weird PC BIOS.  It would not cause the /dev/hda1 problem.


| Also, the versions I used were:
| on the host PC:
| mke2fs 1.35, fdisk 2.12a
| on the embedded:
| mke2fs 1.38
| fdisk 2.12

A possible problem is your kernel does not have compiled in the support
for PC style partitions.  Embedded devices rarely have such partition
types, so it may be omitted by default for your embedded architecture.
Did you build your own kernel?  Got the .config file from the kernel
build tree?

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org)  /  Do not send to the address below |
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline