problem mounting from flash [Invalid sectorsize] [g_vfs_done() ?error=22]

Oliver Fromme olli at lurza.secnetix.de
Mon Nov 8 17:49:07 UTC 2010


Monthadar Al Jaberi <monthadar at gmail.com> wrote:
 > I dont know if I am asking on the wrong place. But it has todo with
 > filesystem and onboard flash (16MB) on a RouterStation Pro board.
 > 
 > I am running a FreeBSD Current 201010, with the kernel configuration
 > file specified in /usr/src/sys/mips/conf/AR71XX with device
 > geom_redboot.
 > 
 > but I get this error when I try to mount from flash:
 > mount /dev/redboot/fs /var/fs
 > mount: /dev/redboot/fs Invalid sectorsize 65536 for superblock size
 > 8192: Invalid argument
 > 
 > So I guessed it has todo with the flash configured in 64k sectors
 > according to the boot output.
 > ...
 > mx25l0: <M25Pxx Flash Family> at cs 0 on spibus0
 > mx25l0: mx25ll128, sector 65536 bytes, 256 sectors
 > ...

Historically UFS/FFS supports only 512 bytes per sector.
I think it was patched at some point in the past to support
2048 bytes per sector, too, which is used by some MOD media
and DVD-RAM.  I'm pretty sure it does _not_ support 65536
bytes per sector (someone please correct me if I'm wrong).

 > So I just tried to change SBLOCKSIZE from 8129 to 65536 in
 > /usr/src/sys/ufs/ffs/fs.h, but then I got this error:

That won't work.  The media sector size is a hard limit;
the driver will refuse to read or write anything that is
not aligned to the media sector size.  Changing the size
of the super block (SBLOCKSIZE) won't help much.

 > mount /dev/redboot/fs /mnt/fs
 > g_vfs_done():redboot/fs[READ(offset=8192, length=65536)]error = 22
 > mount: /dev/redboot/fs : Invalid argument

The UFS code tries to read the super block at offset 8192,
which is not aligned correctly (it's not a multiple of the
sector size).

I think UFS is not the right file system to put on a flash
media that has 256 sectors of 65536 bytes.  In theory you
could insert a translation layer that converts 512-byte
access to 65536-byte access (requiring a read-modify-write
operation when writing).  Maybe gnop(8) can do this, it
has a sector size option, but I haven't tried it.  Anyway,
that would be extremely inefficient.

Another possibility is to create a memory device with
mdconfig(8) and use "dd bs=65536" to copy the contents
of the flash device to the memory disk, then you can mount
the memory disk.  When you need to write any modifications
back to the flash device, you have to umount the memory disk
and use dd again (with if= an of= reversed, of course).
Make sure that the size of the memory disk is a multiple
of 65536, too.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Documentation is like sex; when it's good, it's very, very good,
and when it's bad, it's better than nothing."
        -- Dick Brandon


More information about the freebsd-fs mailing list