Booting from a flash card

This article covers the steps you need to follow to boot from a flash card. The process is somewhat involved, so some familiarity with the command line is recommended.

Contents

Why would we want to boot from a flash card?

  • For more space to install applications.
  • An easy-to-user bootable backup.
  • To improve performance (note, this is dependent on the quality of your flash card).

Gain root access

First of all you need to be able to gain root access.

Partition your card

Follow the instructions to partition your card.

Install bootmenu

Connect your device to the charger, as running out of battery power during the flashing process could damage the device.

Preparation

First, we need to install wget, so open Xterm and, as root, run:

apt-get install wget

Then run:

mkdir -p /home/user/local/bin
mkdir -p /home/user/bin
cd /home/user/local/bin
wget http://www.nmacleod.com/nokia/bin/nupgrade.sh
wget http://www.nmacleod.com/nokia/bin/tar
chmod +x nupgrade.sh tar
ln tar /home/user/bin

Tar is referenced by location in the script below.

Also note that e2fsprogs are needed to run the nupdate.sh step 0 so:

apt-get install e2fsprogs

may work. (If not then you may download the package from here: http://repository.maemo.org/pool/diablo/free/e/e2fsprogs/)

Now we need to download and install fanoush's initfs flasher, so, as root, run:
(Note, although putting initfs_flasher in the directory given is not required, it cannot be placed on a FAT partition (i.e., one of the cards.))

cd /home/user/local/bin
wget http://fanoush.wz.cz/maemo/initfs_flasher.tgz
tar zxvf initfs_flasher.tgz
cd /home/user/local/bin/initfs_flasher/

Configuration

This is an optional step, but if you want to customize the bootmenu to properly reflect your partitioning setup, change the partition labels, and a number of other options, then you'll need to rename the appropriate bootmenu.conf.device.example file to bootmenu.conf and edit it to your liking. The README included with flasher and the comments in the configuration file should be enough to tell you what everything is.

The flasher will ask you if you want to include your bootmenu.conf file if you renamed it properly.

Flash the initfs

cd /home/user/local/bin/initfs_flasher/
./initfs_flash

Follow the onscreen instructions. You can answer yes to all of these questions if you don't understand what they mean.

Clone to the card

Many thanks to milhouse for writing and maintaining this script.

Now it's time to clone your install over to partition 2 of the internal card. The script works in stages to allow better control and error detection, and should take about 10 minutes to complete:

  • 0 - Create ext2 filesystem on partition 2 of the Internal memory card
  • 1 - Mount partition 2 as /opt
  • 2 - Mount rootfs as /floppy
  • 3 - Perform cloning process
  • 4 - Commit filesystem updates and unmount /floppy and /opt

So, as root, run:

cd /home/user/local/bin
./nupgrade.sh 0
./nupgrade.sh 1
./nupgrade.sh 2
./nupgrade.sh 3
./nupgrade.sh 4
reboot

Your device will reboot when done, and you can select the partition you want to boot from from the bootmenu.

Remove the menu

If you decide you do not wish to see the bootmenu any longer, you can uninstall it by either reflashing the whole OS image, or just flashing the initfs (in Linux and OS X) by running:

sudo ./flasher-3.0 -F <FIASCO image> --flash-only=initfs -R

MultiBoot

The process for setting up a multi-boot is very similar. It's a good idea to makes sure the first partition is a fat/data partition - this keeps things simple.

A sample partition layout on an 8Gb card may be:

  • 2Gb primary vfat data
  • 2Gb primary everyday
  • 2Gb primary debian
  • 512Mb logical test1 (diablo)
  • 512Mb logical test2 (chinook)
  • 512Mb logical test3 (diablo)

Be aware that the kernel/initfs only supports a limited number of partitions; this can easily be extended to 6 but no further. This requires editing /home/user/local/bin/initfs_flasher/initfs.bootmenu.jffs2 to add the dev nodes using mknod (eg: mknod -m600 initfs/dev/mmcblk0p5 b 254 5)

When cloning, you may edit nupgrade.sh to remove the TARGET= line and then run it as follows:

TARGET=/dev/mmcblk0p5 ./nupgrade.sh 1

To create pristine images of Diablo/Chinook, follow the instructions for Modifying the root image, but once you have the rootfs.jffs2 image extracted, you can follow the mount instructions and rsync the rootfs to the tablet.

I used this script (which doesn't work yet)

#!/bin/bash

# This script connects to the tablet and sends the selected rootfs to the selected partition

FLASHER3=/everything/Downloads/Hardware/nokia_n800/flasher-3.0 
F_IMAGE=/everything/Downloads/Hardware/nokia_n800/RX-34_2008SE_2.2007.51-3_PR_COMBINED_MR0_ARM.bin
IMAGE_DIR=chinook_fiasco
PART=/dev/mmcblk0p6

mkdir -p $IMAGE_DIR
cd $IMAGE_DIR

# unpack fiasco
$FLASHER3 -F $F_IMAGE -u

# https://wiki.maemo.org/Modifying_the_root_image
mknod /tmp/mtdblock0 b 31 0
modprobe loop
losetup /dev/loop0 rootfs.jffs2 
modprobe block2mtd
modprobe mtdblock
echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd
modprobe jffs2
mkdir /tmp/jffs2
mount -t jffs2 /tmp/mtdblock0 /tmp/jffs2

# copy files
ssh root@nut insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko \; mkdir /tst \; mount $PART /tst
rsync -av /tmp/jffs2/ root@nut:/tst/
ssh root@nut umount /tst \; rmdir /tst

#clean up
umount /tmp/jffs2
rmmod jffs2
rmmod mtdblock
rmmod block2mtd
losetup -d /dev/loop0
rm -f /tmp/mtdblock0
rmdir /tmp/jffs2