Handhelds.org - Open source for handheld devices

UserPreferences

FamiliarLoopbackHowto


Familiar Loopback Howto

Familiar v0.6.1 Loopback FS howto

This page describes how to set up a loopback filesystem using Familiar v0.6.1. Though it may work in other versions and even entirely different distros, it has only been tested on an iPaq 38xx running Familiar v0.6.1. If you are using a distro with a different kernel version, substitute that version for modules where appropriate.

Why a loopback filesystem?

The main reason you are likely to want to create a loopback filesystem is to allow you to put an ext2 filesystem on something that doesn't support it, such as a CompactFlash (CF) or MultiMediaCard (MMC). Using a loopback filesystem you can create a single file that contains an entire filesystem, then mount it and use it as you would a normal filesystem. This howto only covers creating a loopback device with an ext2 filesystem, but adapting these instructions for ext3 or some other FS should be fairly trivial.

Initial Setup

  1. First, we'll need to make sure you have the needed kernel modules and utilities:

    ipkg install loopback-modules-2.4.18-rmk3 ext2-modules-2.4.18-rmk3 e2fsprogs
    

  2. Next, we need to create the file to store the loopback filesystem and format. Replace x with the number of megabytes in size you want to make your loopback filesystem.

    dd if=/dev/zero of=/mnt/card/loopfs bs=1M count=x
    mkfs.ext2 /mnt/card/loopfs
    
    mkfs.ext2 will ask you if you are sure you want to make a filesystem on a non block device, say yes.

    Here I'm assuming the file for your loopback FS is called /mnt/card/loopfs, modify the path & name to suit your setup.

  3. Now you've created the filesystem, you simply have to mount it, ensuring you have loaded the loopback modules first:

    mkdir /mnt/loop
    insmod loop
    mount /mnt/card/loopfs /mnt/loop -t ext2 -o loop
    

You should now be able to access your new filesystem on /mnt/loop! Naturally, if you have different paths for your loopback FS file or your mount location, you should substitute as appropriate.

Something more permanant

Now that you have created and mounted your loopback filesystem, you may want to make it easier to do so in future. Assuming you'll be mounting it on a regular basis, you'll first want to make sure the loop.o module is installed when you need it:
echo loop >> /etc/modules
You'll also want to make mounting it easier:
echo /mnt/card/loopfs /mnt/loop ext2 loop,noauto 0 0 >> /etc/fstab
You should now be able to mount your loopback filesystem simply by typing "mount /mnt/loop" and unmount it with "umount /mnt/loop".

Notes

If you are putting your loopback filesystem on removable media such as an MMC or CF (and why else would you want a loopback FS?), you should make sure you unmount it before you eject the card. I'm working out how to have cardmon/hotplug automatically mount a loop FS on insertion of a card and unmount them when you shut the card down, and I'll update the page when I know how.

Nick Johnson <arachnid@mad.scientist.com>