Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
docs:techref:init.detail.cc [2018/03/04 11:42] – ↷ Links adapted because of a move operation docs:techref:init.detail.cc [2018/03/04 11:46] (current) – ↷ Links adapted because of a move operation
Line 31: Line 31:
  
   - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l71|main(int argc, char **argv)]]'' in /sbin/init, line 71\\ User space life begins here. OpenWrt calls this phase "preinit".   - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l71|main(int argc, char **argv)]]'' in /sbin/init, line 71\\ User space life begins here. OpenWrt calls this phase "preinit".
-    - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l81|early()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/early.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l92|(definition)]]\\ Mount filesystems: ''/proc'', ''/sys'', ''/sys/fs/cgroup'', ''/dev'' (a tmpfs), ''/dev/pts''\\ Populate ''/dev'' with entries from ''/sys/dev/{char;block}''\\ Open ''/dev/console'' as STDIN/STDOUT/STDERR\\ Make directories ''/tmp'' (optionally on zram), ''/tmp/run'', ''tmp/lock'', ''/tmp/state''\\ \\ This accounts for most of the filesystem layout, observed that ''/etc/fstab'' is a [[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/Makefile;hb=483dac821788b457d349233e770329186a0aa860#l161|broken symlink, line 161]], with the following additions:\\ - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=plug/coldplug.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l40|procd_coldplug()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l105|invoked at hotplug setup time]] will recreate ''/dev'' from scratch.\\ - ''[[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/files/etc/init.d/boot;hb=483dac821788b457d349233e770329186a0aa860#l20|/etc/rc.d/S10boot]]'' will invoke ''mount_root'' to setup a writable filesystem based on extroot or jffs2 overlay or a tmpfs backed [[/inbox/snapshot|snapshot capable]] overlay, add some directories and files, and mount debugfs.+    - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l81|early()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/early.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l92|(definition)]]\\ Mount filesystems: ''/proc'', ''/sys'', ''/sys/fs/cgroup'', ''/dev'' (a tmpfs), ''/dev/pts''\\ Populate ''/dev'' with entries from ''/sys/dev/{char;block}''\\ Open ''/dev/console'' as STDIN/STDOUT/STDERR\\ Make directories ''/tmp'' (optionally on zram), ''/tmp/run'', ''tmp/lock'', ''/tmp/state''\\ \\ This accounts for most of the filesystem layout, observed that ''/etc/fstab'' is a [[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/Makefile;hb=483dac821788b457d349233e770329186a0aa860#l161|broken symlink, line 161]], with the following additions:\\ - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=plug/coldplug.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l40|procd_coldplug()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l105|invoked at hotplug setup time]] will recreate ''/dev'' from scratch.\\ - ''[[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/files/etc/init.d/boot;hb=483dac821788b457d349233e770329186a0aa860#l20|/etc/rc.d/S10boot]]'' will invoke ''mount_root'' to setup a writable filesystem based on extroot or jffs2 overlay or a tmpfs backed [[docs:guide-user:installation:snapshot|snapshot capable]] overlay, add some directories and files, and mount debugfs.
     - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|cmdline()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l56|(definition)]]\\ Check kernel cmdline for boot parameter "''init_debug={1,2,3,4}''".     - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|cmdline()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l56|(definition)]]\\ Check kernel cmdline for boot parameter "''init_debug={1,2,3,4}''".
     - Fork ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l87|/sbin/kmodloader (/rom)/etc/modules-boot.d/]]'' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l830|kmodloader source]]\\ Wait up to 120 seconds for ''/sbin/kmodloader'' to probe the kernel modules declared in ''(/rom)/etc/modules-boot.d/''\\ At this point in the boot sequence, '/etc/modules-boot.d' is the one from the rom image (''/rom/etc/...'' when boot is done). The overlay filesystem is mounted later.\\ \\ kmodloader is a multicall binary, invoked as\\ ''   kmodloader''\\ does \\ ''  [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l732|main_loader()]]''\\ which reads files in ''(/rom)/etc/modules-boot.d/'', looking for lines starting with the name of a module to load, optionally followed by a space and module parameters. There appear to be [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l788|special treatment for files with names beginning with a number]]: the modules they list are immediately loaded, then modules from files with name beginning with an ascii char greater than "9" are loaded all together in a final load_modprobe call.     - Fork ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l87|/sbin/kmodloader (/rom)/etc/modules-boot.d/]]'' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l830|kmodloader source]]\\ Wait up to 120 seconds for ''/sbin/kmodloader'' to probe the kernel modules declared in ''(/rom)/etc/modules-boot.d/''\\ At this point in the boot sequence, '/etc/modules-boot.d' is the one from the rom image (''/rom/etc/...'' when boot is done). The overlay filesystem is mounted later.\\ \\ kmodloader is a multicall binary, invoked as\\ ''   kmodloader''\\ does \\ ''  [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l732|main_loader()]]''\\ which reads files in ''(/rom)/etc/modules-boot.d/'', looking for lines starting with the name of a module to load, optionally followed by a space and module parameters. There appear to be [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l788|special treatment for files with names beginning with a number]]: the modules they list are immediately loaded, then modules from files with name beginning with an ascii char greater than "9" are loaded all together in a final load_modprobe call.
  • Last modified: 2018/03/04 11:42
  • by