Discussion:
[uClinux-dev] mount cramfs on loopback?
Steve deRosier
2013-02-18 20:08:19 UTC
Permalink
OK, this is driving me crazy, I can't figure out how to get a cramfs
file to mount via loopback on my Coldfire target. I'm sure I'm missing
something simple, but I'm not seeing it. Can anyone help?

* cramfs is enabled in my kernel
* loopback is enabled in my kernel
* using busybox's mount command
* busybox's losetup is enabled

I'm able to create an ext2 filesystem and mount that in my target via
loopback using (so seems loopback support works OK):
# losetup /dev/loop0 /tmp/mye2fs.img
# mount -t ext2 /dev/loop0 /mnt

Trying the same with cramfs:
# losetup /dev/loop0 /tmp/mycramfs.img
# mount -t cramfs /dev/loop0 /mnt
mount: mounting /dev/loop0 on /mnt failed: Invalid argument

Same result if I give `mount -t cramfs -o loop /dev/loop0 /mnt`. I get
"Block device required" if I don't use losetup and try:
# mount -t cramfs -o loop=/dev/loop0 mycramfs.img /mnt

I've built the cramfs with both big and little endian (just to try).
If I build it with little, I get the following message in dmesg:
cramfs: bad root offset 1048576

No messages what so ever if I build big endian.

If I try building the stand-alone mount, that fails with a missing
header <gnu/types.h>. By a few searches, looks like that mount is no
longer maintained?

Is there a problem where busyboxes mount doesn't support cramfs?

Ideas?

Thanks,
- Steve
Lennart Sorensen
2013-02-19 16:40:30 UTC
Permalink
Post by Steve deRosier
OK, this is driving me crazy, I can't figure out how to get a cramfs
file to mount via loopback on my Coldfire target. I'm sure I'm missing
something simple, but I'm not seeing it. Can anyone help?
* cramfs is enabled in my kernel
* loopback is enabled in my kernel
* using busybox's mount command
* busybox's losetup is enabled
I'm able to create an ext2 filesystem and mount that in my target via
# losetup /dev/loop0 /tmp/mye2fs.img
# mount -t ext2 /dev/loop0 /mnt
# losetup /dev/loop0 /tmp/mycramfs.img
# mount -t cramfs /dev/loop0 /mnt
mount: mounting /dev/loop0 on /mnt failed: Invalid argument
Same result if I give `mount -t cramfs -o loop /dev/loop0 /mnt`. I get
# mount -t cramfs -o loop=/dev/loop0 mycramfs.img /mnt
The syntax from what I recall is:

mount -t cramfs -o loop /path/imagefile /mountpoint
Post by Steve deRosier
I've built the cramfs with both big and little endian (just to try).
cramfs: bad root offset 1048576
No messages what so ever if I build big endian.
If I try building the stand-alone mount, that fails with a missing
header <gnu/types.h>. By a few searches, looks like that mount is no
longer maintained?
Is there a problem where busyboxes mount doesn't support cramfs?
Ideas?
Not really. I haven't used cramfs for years. I use cpio archives these
days with initramfs's tmpfs. Not quite the same thing though in terms
of memory usage though.
--
Len Sorensen
Steve deRosier
2013-02-19 18:04:41 UTC
Permalink
Hi Lennart,

On Tue, Feb 19, 2013 at 8:40 AM, Lennart Sorensen
Post by Lennart Sorensen
mount -t cramfs -o loop /path/imagefile /mountpoint
Yes, but that results in a "Block device required" error with
uClinux's Busybox mount command.
Post by Lennart Sorensen
Not really. I haven't used cramfs for years. I use cpio archives these
days with initramfs's tmpfs. Not quite the same thing though in terms
of memory usage though.
Unfortunately, not the same thing at all. And of course I'm not doing
this for the initial root filesystem. I'm trying to mount a filesystem
from a file after boot. Footprint on flash is important.

Thanks,
- Steve
Lennart Sorensen
2013-02-19 19:59:05 UTC
Permalink
Post by Steve deRosier
Hi Lennart,
On Tue, Feb 19, 2013 at 8:40 AM, Lennart Sorensen
Post by Lennart Sorensen
mount -t cramfs -o loop /path/imagefile /mountpoint
Yes, but that results in a "Block device required" error with
uClinux's Busybox mount command.
Post by Lennart Sorensen
Not really. I haven't used cramfs for years. I use cpio archives these
days with initramfs's tmpfs. Not quite the same thing though in terms
of memory usage though.
Unfortunately, not the same thing at all. And of course I'm not doing
this for the initial root filesystem. I'm trying to mount a filesystem
from a file after boot. Footprint on flash is important.
Is your busybox built with BB_FEATURE_MOUNT_LOOP enabled?

Is your mountpoint in a location that permits mounts (apparently you can
forbid further mounts under a filesystem in some cases and this can make
mount return weird errors that don't point at the actual problem).
--
Len Sorensen
Steve deRosier
2013-02-20 15:33:59 UTC
Permalink
On Tue, Feb 19, 2013 at 11:59 AM, Lennart Sorensen
Post by Lennart Sorensen
Is your busybox built with BB_FEATURE_MOUNT_LOOP enabled?
No, it wasn't, but since I was manually doing the losetup command,
that wouldn't matter. However, I've enabled the config and can now do
a loopback mount in one-shot which is nice. Thanks for the suggestion.
Post by Lennart Sorensen
Is your mountpoint in a location that permits mounts (apparently you can
Yes.

Update: I've managed to get it working, kind-of. Since I had a problem
with cramfs, but ext2 worked, I decided to try squashfs. This worked
for me on the first try. I had to install the tools for squashfs on my
dev machine manually, but my client is just going to have another tool
requirement. squashfs also gives me better compression, so thats a
positive.

I don't know what's up with cramfs. If I had to suspect, there's
something with the PAGE_SIZE thing. Coldfire uses an 8k page size, and
I found a note in cramfs's README that it only works on targets with
4k page sizes. But as I saw that you can manually change the block
size via a parameter to mkfs.cramfs, I was hoping that was an old
limitation. Seems odd to me that they'd limit a filesystem to be so
dependent on certain processors. And if that's the case, the kernel
shouldn't let me enable cramfs if it can't be used on my platform. But
since I've got squashfs working, it's not my problem anymore.

Time to finish up and move on to my next stumbling block.

Thanks for helping,
- Steve

Loading...