HOWTO — Running familiar Linux from CF/SD/MMC
This howto covers one way of running familiar Linux from your CF, SD, or MMC card.
OK, it doesn’t actually boot from SD, but uses a snazzy Linux trick called pivot_root. Which switches over one root with another. This, IMHO, is probably the best way of doing it apart from actually directly booting from SD. Although, I’ve only tried this on a 38xx based iPAQ it should work for all handhelds based on familiar. Heck, it should work for anything really.
Preface
The general idea is to boot up Linux from the internal flash of the iPAQ to just before it runs the environment. Check the SD slot for a loopfs file, if one is there, then mount it up, switch roots, and continue to boot.
Why?
There’s several benefits to doing it this way:
- Backups — Since you have a copy of the root filesystem on SD, you can back it up very easily. Every PC these days has a SD slot. Just whack it in and copy the file across, you don’t even need Linux to do it either.
- Choices — You can startup either environment GPE or OPIE, just by changing SD cards. (Further updates to setMMCroot will allow selecting environment by buttons.
- Saving files — regardless of what environment you run, you can still save the files directly to the SD card. If you need them elsewhere, turn off the iPAQ, pop the SD card out and chuck it into a PC and read them. Easy!
- Dead SD — If your SD card dies, you can still run with a basic environment that is already loaded up on your iPAQ. With other methods, if your SD dies that’s it. Things start going wierdo.
Pre-requisites
You’re going to need several things to do this:
- Linux based PC, any dist will do.
- An iPAQ — with familiar Linux already loaded up on to it, (doesn’t matter what environment).
- A copy of familiar Linux , with either the GPE or OPIE will do. I used version 0.8.4 for this HOWTO. You will need the tarballs from here and not the jffs files, (IE either of the *.rootfs.tar.bz2 files).
- Any SD, MMC, or CF card formatted with FAT16, (if you just bought it you don’t need to do anything as all flash cards are formatted these days).
Step 1 — Create root filesystem.
First we’ll need to create the filesystem that gets mounted up I’m creating a 1G filesystem, because I tend to load up a lot of applications onto my iPAQs. Since I also have a 2G SD card, I will be able to store both the GPE and OPIE environments on it.
dd if=/dev/zero of=loopfs-gpe bs=1024 count=991680
Note the size is just under 1G? This is because a 1G filesystem on an SD card will consume slightly more than 1G. So, I’ve allowed for that. I can fit two filesystems on that card this way. Adjust the “count” to whatever size you want or care for.
Now, you’ll need to setup the filesystem.
mkfs.ext2 loopfs-gpe
This will create a Linux ext2 filesystem. You can really use any filesystem, but you don’t want to use a journelling filesystem like ext3, reiserfs, xfs, as flash memory can’t stand too many writes to it. Journelling filesystem tend to write a lot of data even when not being used, (from a flash point of view).
Mount up the filesystem on your Linux box, (requires root).
mkdir loopfs-gpe.mount mount -o rw,loop loopfs-gpe loopfs-gpe.mount
Extract the environment tarball into the loopback mount point.
cd loopfs-gpe.mount tar jxf ../gpe-image-v0.8.4-h3600.rootfs.tar.bz2
You will need to edit /etc/passwd and change the root password to something sensible if you want to login, the following entry will set the password to ‘root’.
root:dquXGWQyEH.uI:0:0:root:/home/root:/bin/sh
Unmount the loopfs filesystem.
umount loopfs-gpe.mount
You now have a brand spanking new filesystem that will be used on your iPAQ.
Step 2 — Prepare your SD.
There are a number of files that need to be created and copied over to your SD card. These are all required.
- Your root filesystem that you just created, ensure it is called either loopfs-opie or loopfs-gpe.
- The setMMCroot script , which does all the work.
- Create a file called loopfs.boot on the SD card with the full path of the loopfs file you created. For example: /media/card/loopfs-gpe, or /media/card/loopfs-opie, or /media/card/i.like/it.here
Remove the SD card and plonk it into your iPAQ.
Step 3 — Prepare your iPAQ.
Fire up your favourite serial port communication program, (I use minicom), to connect to your iPAQ, which should be connected to your PC by now. If you can’t do this, or don’t want to, then you can run these commands from within a console on your iPAQ, (under the Applications tab). The preferred option is to run the ppp daemon from your Linux box and ‘ssh 20.0.0.1′ into your iPAQ, using the following command, (needs root on your PC):
/usr/sbin/pppd /dev/ttyS0 230400 20.0.0.5:20.0.0.1 nodetach local noauth nocrtscts lock user ppp connect "/usr/sbin/chat -v -t3 ogin--ogin: ppp"
Run the following commands in a shell on your iPAQ.
ln -s /etc/init.d/setMMCroot /etc/rc5.d/S01setMMCroot ln -s /etc/init.d/setMMCroot etc/rc2.d/S01setMMCroot cp /media/card/setMMCroot /etc/init.d/setMMCroot
I had suggested using the ppp daemon because then the next part becomes easy. You ned to install the extra packages on your iPAQ. e2fsprogs, e2fsprogs-e2fsck, kernel-module-loop-2.4, and kernel-module-ext2-2.4. Run this on your iPAQ, or use the package manager to do it.
ipkg install e2fsprogs e2fsprogs-e2fsck kernel-module-loop-2.4 kernel-module-ext2-2.4
Holy toledo batman! You’re almost there!
Step 4 — Reboot your iPAQ.
Reboot your iPAQ, via Start -> Settings -> Shutdown.
When you reboot you should see the following appear just underneath the Linux penguin logo.
#### 1. Checking MMC: # Found MMC! Using loopfs: /media/card/loopfs-gpe #### 2. FSCK filesystem: /media/card/loopfs-gpe has gone 48850 days without being checked, check forced. /media/card/loopfs-gpe: 2817/124160 files (0.1% non-contiguous), 12110/247900 blocks #### 3. Setting up loopback FS: Using /lib/modules/2.4.19-rmk6-pxa1-hh42/kernel/drivers/block/loop.o #### 4. Mounting: #### 5. Ballet: #### 6. Tidying up: killall: Xfbdev: no process killed #### 7. Handover:
The script will wait for 16 seconds for an SD card to be inserted, (a hash will appear every second), else it will just boot up straight from the internal flash. This allows you to just run with whatever is there already, if need be.
Depending on what environment you have running will change some of the messages between each stage. I’ll see if I can take a photo of the bootup stage and chuck it on here. (EDIT: I’ve put up some bloody horrible images of the iPAQ booting, taken with my mobile.)
Boot loader screen.

FSCKing the filesystem.

Ballet school

From there onwards, it’s just the normal boot procedure.
Step 5 — Final install.
Because this is a ‘fresh’ install you will be asked all the questions you would have been asked when you did the initial install of familiar on your iPAQ. If you get to this stage you’ve done it! Congratulations!
Once you have gone through the final install procedure, if you open up a console session and type ‘df’ , you’ll see what the setMMCroot script does. /mnt/realroot points to your iPAQ flash filesystem, and / is the SD filesystem. Cool eh?!
root@h3600:~# df Filesystem 1k-blocks Used Available Use% Mounted on /dev/root 976056 387164 539308 42% / tmpfs 31676 40 31636 0% /mnt/realroot/var tmpfs 31676 0 31676 0% /mnt/realroot/media/ram /dev/mmc/part1 1983360 991712 991648 50% /mnt/realroot/media/card /dev/loop/0 976056 387164 539308 42% /
No related posts.
