1. Overview
The main process from bootloader to Init program is as follows
++++++++++++++ ++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++| | Kernel_entry () | | Start_kernel (), Rest_init (), Kernel_init () |==============, ==================, =================== ===============================| BootLoader | | MIPS | Kernel |++++++++++++++ ++++++++++++++++++
Kernel_init () first attempts to execute the command arguments passed from bootloader rdinit=, init=
If it fails, it will attempt to execute/sbin/init,/etc/init,/bin/init,/bin/sh,
The following is a command-line instance passed from Uboot
such as console=ttys0,115200 Root=/dev/ram RW INIT=/LINUXRC
2. BusyBox
In an embedded system, the INIT program is usually the BusyBox
And LINUXRC is a symbolic link to busybox.
BusyBox's init program, the Init_main function
Init_main (), Parse_inittab (), Run_actions (Sysinit)
3. Inittab
File/etc/inittab is a very important file for Linux startup
Reference </etc/inittab file analysis > or <linux/etc/inittab file >
Here's a look at the following action-Sysinit lines
The script specified by the line will complete the system initialization process
In Ttylinux, the behavior
:: Sysinit:/etc/rc.d/rc.sysinit
The work done by Rc.sysinit is mainly
Set environment variables, load file system ...
One notable concern is the start-up service
~~~~~~~~~~~~~ part of/etc/rc.d/rc.sysinit ~~~~~~~~~~~~~# ********************************* # Start the services.# *********************************************** for P in /etc/rc.d/rc.startup/* ; do [[-X ${p}]] && ${p} startdone; unset p~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And the Rc.startup directory contains the following script
$ ls-al/etc/rc.d/rc.startuptotal 8drwxr-xr-x 2 root root 4096 Jul 07:33. drwx R-xr-x 5 root root 4096 Jul 29 07:33.. lrwxrwxrwx 1 (root root) 07:33 00.random. /init.d/randomlrwxrwxrwx 1 (root root) 07:33 01.firewall. /init.d/firewalllrwxrwxrwx 1 (root root) 07:33 05.syslog. /init.d/sysloglrwxrwxrwx 1 (root root) 07:33 10.network. /init.d/networklrwxrwxrwx 1, root root 07:33 20.sshd. /init.d/sshdlrwxrwxrwx 1, root root 07:33 30.inetd. /init.d/inetdlrwxrwxrwx 1 root root 07:33 85.gpm. /init.d/gpmlrwxrwxrwx 1, root root 07:33 90.crond. /init.d/crond
You can see that Ttylinux started the service specified in the script in turn
Linux Startup Simple Analysis