inittab(5) - Linux man page
名字
inittab - 被系统进程所使用的文件格式
描述
inittab 文件描述在系统初始化阶段及普通操作时哪些进程需要被开启 (e.g. /etc/init.d/boot, /etc/init.d/rc, gettys...)。 init(8) 分辨每个运行级别,每个运行级别可以拥有其独自的启动进程集。有效的运行级别包括0-6,同时还有A,B,C三个即时入口。在 inittab 文件中一个入口拥有如下格式:
id:runlevels:action:process
以“#”符号开始的每一行被省略。
id
是一串1到4个字符的字符序列,它用以标识 inittab 入口。
Note: 通常情况下,对于getty 和其他的登录进程而言,该字段的值与相应的tty 的尾数值相同,e.g. tty1 的1。
一些比较老旧的账号登录程序都是这么做的,但是我已想不出太多这样的程序了。
runlevels
列出与特殊行为相关的运行等级。
action
描述应采取哪种行为。
-
process
指定要执行的进程,如果该域以'+' 符号开头,init 将不会为该进程执行utmp 及wtmp。这对于gettys 来说是必要的。这也是个历史性遗留的BUG。
runlevels 域对不同的运行等级会包含多样的字符。例如,123 指定进程会在1,2,3 这三个运行等级下被启动。包含随即入口的运行等级包含A,B,C。运行等级中关于sysinit ,boot ,bootwait 入口的域被忽略。当系统运行等级改变了,任何不被指定在变换后的运行等级下运行的进程会被杀死,首先使用SIGTERM信号,之后使用SIGKILL信号。
有效的 action 域值为:
respawn
进程当被关闭时,会自动重启。
wait
进程会在进入特定的运行等级时被启动一次,init 进程会等待它的结束。
once
进程会在进入特定的运行等级时被执行一次。
boot
进程会在系统启动的时候被执行。运行等级域被忽略。
bootwait
进程会在系统启动的时候被执行,但是 init 进程会等待其结束。运行等级域被忽略。
off
- 当特定的 ondemand 运行等级被调用时,进程会被执行。但是不会发生运行等级的改变。(ondemand 运行等级为'a','b','c')
- initdefault 入口指定了系统启动后需要进入的运行等级。如果不存在,init 进程会在命令行中询问一个运行等级。进程域被忽略。
该项什么都不做。
ondemand
initdefault
sysinit
- 进程会在系统启动期间被执行。它将在任何 boot,bootwait 入口前被执行。运行等级域被忽略。
powerwait
- 进程会在系统失去电源的情况下被执行。init 进程通常是从一个与连接在电脑上的UPS进行沟通的进程得知此事。init 进程会等待该进程结束然后才继续执行。
powerfail
- init 进程不会等待该进程结束。
powerokwait
- init 进程被通知电力恢复时,该进程立刻被执行。
powerfailnow
- init 进程被告知电源几乎快耗尽时,该进程被执行。
ctrlaltdel
- 该进程在 init 进程收到 SIGINT 信号时被执行。这意味着,在系统控制台的某人按下了 CTRL-ALT-DEL 组合键。
kbrequest
- 该进程在 init 进程收到来自键盘控制器的特殊按键组合时被执行。
-
The documentation for this function is not complete yet; more documentation can be found in the kbd-x.xx packages (most recent was kbd-0.94 at the time of this writing). Basically you want to map some keyboard combination to the "KeyboardSignal" action. For example, to map Alt-Uparrow for this purpose use the following in your keymaps file:
- alt keycode 103 = KeyboardSignal
例子
以下是个类似旧 inittab 的 inittab 例子:
-
# inittab for linux
-
id:1:initdefault:
-
rc::bootwait:/etc/rc
-
1:1:respawn:/etc/getty 9600 tty1
-
2:1:respawn:/etc/getty 9600 tty2
-
3:1:respawn:/etc/getty 9600 tty3
-
4:1:respawn:/etc/getty 9600 tty4
-
该 inittab 文件在系统启动阶段执行 /etc/rc ,并开启在 tty1-tty4 上的d getty 。
-
# Level to run in
-
id:2:initdefault:
A more elaborate inittab with different runlevels (see the comments inside):
以下是一个更加精细的 inittab :
# Boot-time system configuration/initialization script.
si::sysinit:/etc/rc.sysinit
# What to do in single-user mode.
~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/rc 0
l1:1:wait:/etc/rc 1
l2:2:wait:/etc/rc 2
l3:3:wait:/etc/rc 3
l4:4:wait:/etc/rc 4
l5:5:wait:/etc/rc 5
l6:6:wait:/etc/rc 6
# What to do at the "3 finger salute".
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# Runlevel 2,3: getty on virtual consoles
# Runlevel 3: mgetty on terminal (ttyS0) and modem (ttyS1)
1:23:respawn:/sbin/mingetty tty1
2:23:respawn:/sbin/mingetty tty2
3:23:respawn:/sbin/mingetty tty3
4:23:respawn:/sbin/mingetty tty4
S0:3:respawn:/sbin/agetty ttyS0 9600 vt100-nav
S1:3:respawn:/sbin/mgetty -x0 -D ttyS1
Files
/etc/inittab
Author
Init was written by Miquel van Smoorenburg (miquels@cistron.nl). This manual page was written by Sebastian Lederer (lederer@francium.informatik.uni-bonn.de) and modified by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de).