1. inittab基本概念
a) init进程:
- Linux在完成核内引导(内核镜像已被载入内存,开始运行,并已初始化所有的设备驱动程序和数据结构等)之后,接着通过启动一个用户级程序init来启动其他用户级的进程或服务.
- init始终是系统的第一个进程,其PID始终为1(ps -aux | less),它是系统所有进程的父进程.
- 内核会查询init所在的位置,在Linux系统中存储在/sbin/init.如果内核找不到init,它就会试着运行/bin/sh,如果运行失败,系统的启动也会失败.(存储位置如下所示):
b) inittab文件:
- init程序需要读取配置文件/etc/inittab来作为进程运行的参数.
- inittab是一个不可执行的文本文件,它有若干行指令所组成.
1 # /etc/inittab: init(8) configuration. 2 # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ 3 4 # The default runlevel. 5 id:5:initdefault: 6 7 # Boot-time system configuration/initialization script. 8 # This is run first except when booting in emergency (-b) mode. 9 si::sysinit:/etc/init.d/rcS 10 11 # What to do in single-user mode. 12 ~~:S:wait:/sbin/sulogin 13 14 # /etc/init.d executes the S and K scripts upon change 15 # of runlevel. 16 # 17 # Runlevel 0 is halt. 18 # Runlevel 1 is single-user. 19 # Runlevels 2-5 are multi-user. 20 # Runlevel 6 is reboot. 21 22 l0:0:wait:/etc/init.d/rc 0 23 l1:1:wait:/etc/init.d/rc 1 24 l2:2:wait:/etc/init.d/rc 2 25 l3:3:wait:/etc/init.d/rc 3 26 l4:4:wait:/etc/init.d/rc 4 27 l5:5:wait:/etc/init.d/rc 5 28 l6:6:wait:/etc/init.d/rc 6 29 # Normally not reached, but fallthrough in case of emergency. 30 z6:6:respawn:/sbin/sulogin 31 #S:2345:respawn:/sbin/getty 115200 ttyO0 32 S:2345:respawn:/sbin/getty 115200 ttyPS0 33 # /sbin/getty invocations for the runlevels. 34 # 35 # The "id" field MUST be the same as the last 36 # characters of the device (after "tty"). 37 # 38 # Format: 39 # <id>:<runlevels>:<action>:<process> 40 # 41 1:2345:respawn:/sbin/getty 38400 tty1