Bering-uClibc on Compact-Flash

From Bubble

This article describes how to prepare a Compact-Flash for use with Bering-uClibc

It does not replace the Bering-uClibc Installation Guide, but rather a complement.

Contents

Partitioning

The Bering-uClibc system is relatively small: a couple of megabytes is enough for a RéseauCitoyen node; the full list of packages being just a bit more than 10 MB.

The idea is then to partition the Compact-Flash in 3 parts, depending on the size of the CF card.
We have here a 128MB card which is way to much!

  1. An MSDOS partition for the packages. The use of a FAT16 filesystem is dicated by the use of SysLinux for booting the device. 4 MB is more than enough.
  2. A Minix partition for the packages (partial) backup. We want to keep the original packages in the first partition and save the configuration files (partial backups) in the second partition. This way, we can easily upgrade a node by just copying the new packages in the dos partition, without overwriting the configuration files. A couple of megabutes should be sufficient here.
  3. A Minix file system as general purpose filesystem. The rest of the CF can be used to store whatever data we need.

On my huge CF card the partition table looks like:

Disk /dev/hdc: 128 MB, 128188416 bytes
8 heads, 32 sectors/track, 978 cylinders
Units = cylinders of 256 * 512 = 131072 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1         256       32752    6  FAT16
/dev/hdc2             257         512       32768   83  Linux
/dev/hdc3             513         978       59648   83  Linux

Boot partition

Filesystem & syslinux

The first partition will recieve the packages and need to be DOS-formatted for SysLinux:

mkdosfs -n BERING /dev/hdc1

Then we load SysLinux on it

syslinux -s /dev/hdc1

And we also need to copy a MBR on it

dd if=mbr.bin of=/dev/hdc bs=512 count=1

Note that the mbr.bin s part of the SysLinux distribution, but is not in the Debian package... It can be dowloaded from kernel.org

Then you have to put the syslinux.cfg configuration file and the syslinux.dpybanner files in the filesystem. Templates are available in the tools/image directory of the Buildtool (or on the floppy image from the official distribution).

On the soekris, I am using the following syslinux.cfg:

serial 0 19200
display syslinux.dpy
timeout 0 
default linux initrd=initrd.lrp init=/linuxrc rw root=/dev/ram0 LEAFCFG=/dev/hda2:minix
append console=ttyS0,19200 nodma=hda ide=nodma

We will put the leaf configuration file on the second partition. syslinux.cfg is the only system specific file we will have on the first partition;

If the console is on a serial port, it is better to cleanup syslinux.dpy to avoid control characters on the connected terminal.

Linux kernel and packages

The rest of the filesystem is for the Bering-uClibc Linux kernel and packages.

I don't expect space problem on the Compact-Flash card, so we could easily copy all the packages! I am just listing the main ones needed for a node.

System files

  • linux: the Linux kernel, copied from build/kernel/bzimage-2.4.31-upx (or on the floppy image from the official distribution)
  • initrd.lrp: the bootstrap file, copied from initrd_ide.lrp as we boot from Compact-Flash via the IDE adapter
  • root.lrp: System files (basic commands)
    The full root backup will backup 'all files not in other packages!
  • etc.lrp: /etc config files, system startup, ...
    If we use the serial console, /etc/inittab need to be updated, otherwhise there will be no way to access the node! This is only necessary for a fresh install, after that inittab will be saved in the config files.
  • modules.lrp: the drivers needed to run the node
    The drivers loaded by the PCMCIA cardmanager must be in the pcmcia subdirectory, so that the modules can be loaded through insmod as modbrobe is not available.
  • local.lrp: /usr/local files (empty package)
  • log.lrp: /var/log files (empty package)
  • config.lrp: the lrcfg configuration tool

Network files

  • dropbear.lrp: ssh server
  • iptables.lrp: the iptables suite
  • shorewall.lrp: shorewall firewall
  • ulogd.lrp: user space log daemon

Web Interface

  • mhttpd.lrp: lightweight HTTP server
  • webconf.lrp: Web configuration interface
    We need to copy the <package>.lwp configuration plugins
    Note: the password file is not part of the configuration files, and therefore the password is lost when that package is upgraded!

PCMCIA

  • pcmod.lrp: PCMCIA and Cardbus base modules
  • pcmcia.lrp: cardmgr, etc

Wireless stuff

  • wireless.lrp: Jean II wireless tools
  • libm.lrp: dependancy
  • hostapu.lrp: HostAP Config
  • olsrd.lrp: the routing daemon

Other packages

Packages that could be usefull on a node:

  • bridge.lrp: bridge support
  • keyboard.lrp: non-qwerty keyboard support
  • dhcpcd.lrp: dhcp client
  • dnsmasq.lrp: dhcp server & dns cache

Config partition

The second partition will receive a Minix filesystem (the Bering-uClibc kernel only supports msdos and minix filesystems without additional modules).

Initially, this partition will only contains the leaf.cfg configuration file:

VERBOSE=0
LRP="root config etc local modules log iptables dhcpcd shorwall ulogd dnsmasq dropbear pcmod pcmcia libm wireless hostapu mhttpd webconf lrpstat olsrd"
PKGPATH="/dev/hda2:minix,/dev/hda1:msdos"
syst_size=16M
log_size=10M

The important thing is the PKGPATH variable: it took me some time to realize that by default the list is processed backwards when installing the package: we will first get the package files from the hda1 partition, then overlay with the configuration files from the hda2 partition.
An easy way to see this is that the files in the first device take precedence over the others!

Once the system is installed and running, we will backup the configuration files (partial backup) on this partition.

Extra partition

This partition remains available for whatever we need!

Ideally I would have used a jffs2 filesystem, but this module is not compiled by default. So we will use Minix here as well.

Post-install

Once the system is running, the following need to be configured

  • System
    • LRP Config file (date server, ...)
    • Timezone
  • Networking
    • Node name
    • Interface definition
  • Dropbear
    • Generate ssh keys
  • OLSRD
    • Interface
  • Shorewall
  • Webconf
    • Set password