一篇比较旧的文章,但是说的还不错。关键还是找台linux机器,读读脚本就一切清楚了。
http://www.techrepublic.com/article/customizing-the-linux-bootup-and-shutdown-processes/1056248
个人总结 -
1.启动时,LILO解压、加载Linux内核,检查硬件,加载关键内核模块,mount根目录。
2.启动init进程,init进程启动时读取它的配置文件 - /etc/inittab,这个文件是对init进程的配置文件,它的配置一直关系到机器起来后init进程的行为,关系到整个系统运行阶段
2.1. init进程启动后,读取配置文件/etc/inittab,做如下几件事情(都在/etc/inittab里面指定):
2.1.1 id:5:initdefault: (系统启动后处于Level 5)
2.1.2 init执行脚本 /etc/rc.d/rc.sysinit (si::sysinit:/etc/rc.d/rc.sysinit)。这个过程重点是系统内核级别的初始化,或者很基础的东西,如配置网络,文件系统,加载模块
2.1.3 init执行/etc/rc.d/rc脚本,参数是当前的Level 5 (l5:5:wait:/etc/rc.d/rc 5)
/etc/rc.d/rc脚本是关系到应用程序的,具体说是“服务”程序。
它启动/etc/rc.d/rc5.d/下所有S开头的脚本
Linux下所有的服务都是放在/etc/rc.d/init.d下,运行命令"service"时会那里找
在/etc/rc.d/rc脚本运行完所有服务后,有最后一个服务是rc.local,即最后运行/etc/rc.d/rc.local,可以把用户自定义的开机服务放到这里
Power on -> kernel unzip & load key modules & initialize hw & mount / -> start init process
As for init process starting up:
init read /etc/inittab for configuration
run the default init (id:5:initdefault:) (note:only for system boot)
run basic initialization - /etc/rc.d/rc.sysinit (hostname, network, filesystem, kernel module loaded) (note: only for system boot)
run /etc/rc.d/rc script to handle services, with the arg of Run Level
- Read /etc/rc.d/rcN.d/, stop services with K* (by checking /var/lock/subsys/*lock*)
- Read /etc/rc.d/rcN.d, start services with S* (by checking /var/lock/subsys/*lock*)
- the last service to start is /etc/rc.local (note: only for system boot)
Other config for the init processing during system run
Note: the above way applies to all the System Run Level once the init process has been configured.