Table of Contents

This is not a reference document, it's an old design document that, at least in part, led to procd

Boot/Init Requirements

This article attempts to state what the initscripts must and should do for the new init system being developed for OpenWrt. The goal is to deal with the race conditions that currently can occur, without losing current functionality.

Boot/Preinit

The Boot process currently consists of the kernel bootstrap (not discussed here), preinit, and init. Preinit takes care of things that init can't function without, while init is responsible for starting up the rest of the system.

On a Debian desktop system there is an analogue to preinit, which uses initramfs to bring up the system enough to the point init can operate. Unfortunately initramfs is not an option on openwrt because it wastes too much space. The binaries and scripts in an initramfs cannot be retained for use in the booted system, unless they are copied to RAM (tmpfs) (if anyone know otherwise and can point out how, please contact the devs), which is why preinit exists.

Preinit looks to linux like the final boot stage to init on the rootfs. Preinit then mounts the root file system, does pivot_root to the rootfs, and then use the real init to replace itself. Basically it transforms intself into the 'real' init and rootfs.

Goals

Notes

Must-do's

  1. Allow failsafe
  2. If initramfs, do initramfs, skip rest of this list
  3. For Squashfs: Mount jffs2 (if already formatted)
  4. For External Block: Mount swap (so fsck has enough memory)1) if present
  5. For External Block: Mount rootfs (checking first if fsck available) or tmpfs (if no rootfs yet)
  6. For External Block: Mount marked fses before init (e.g. for deployments where /opt contains packages/script that need to run early in init)
  7. Start init or kexec

0) Before failsafe

1) Allow Failsafe

Configuration at Compile-time not Run-time

2) Mount swap and 3) Mount rootfs

2) Mount swap

3) Mount rootfs

4) Mount marked fses other rootfs

5) Start Init or Kexec

Init

Goals

Wants

1)
Roughly 1 MB of RAM for every 1 GB of disk to successfully fsck the disk. Source.