inittab 中文man页面

系统
inittab 文件描述在系统引导及通常的操作期间, 都启动哪些进程 (比如 /etc/init.d/boot, /etc/init.d/rc, getty 等等). Init(8) 讨论有关 runlevels (运行级) 的概念, 每一个运行级都有它自己启动进程的集合. 有效的运行级为 0-6 加上用于 ondemand 条目的 A, B 和 C. inittab 文件中的每一个条目有如下的格式

NAME

inittab - 与 sysv 兼容的 init 进程使用的初始化文件格式  

描述

inittab 文件描述在系统引导及通常的操作期间, 都启动哪些进程 (比如 /etc/init.d/boot, /etc/init.d/rc, getty 等等). Init(8) 讨论有关 runlevels (运行级) 的概念, 每一个运行级都有它自己启动进程的集合. 有效的运行级为 0-6 加上用于 ondemand 条目的 A, BC. inittab 文件中的每一个条目有如下的格式:

id:runlevels:action:process

以 `#' 开头的行被忽略.

id
inittab 文件中条目的唯一标识, 限于 1-4 个字符 (如果是用版本号小于 5.2.18 或 a.out 的库编译生成的 sysvinit 程序, 则仅限于 2 个字符).

注意: 对于 getty 或其它的注册进程, id 必须是响应的终端线路的 tty 后缀, 如 1 响应 tty1, 否则, 注册过程不能正常的工作.

runlevels
列出发生指定动作的运行级.
action
描述要发生的动作.
process
要执行的进程. 如果 process 域以一个 `+' 开头, init 不会在 utmp 和 wtmp 文件中为此进程记帐. 这是由于 getty 自己主持 utmp/wtmp 记帐的需要, 同时这也是一个历史遗留的漏洞.

runlevels 域可以包含表示不同运行级的多个字符, 例如 123 表示本进程在运行级为 1, 2 和 3 时都要启动. 用于 ondemand 条目的 runlevels 域可以包含 A, B, 或 C. 用于 sysinit, boot, 和 bootwait 条目的 runlevels 域被忽略.

当改变运行级时, 在新运行级中没有给出的那些正在运行的进程被杀死, 先使用 SIGTERM 信号, 然后是 SIGKILL.

action 域可以使用的动作有:

respawn
该进程只要终止就立即重新启动 (如 getty).
wait
只要进入指定的运行级就启动本进程, 并且 init 等待该进程的结束.
once
只要进入指定的运行级就启动一次本进程.
boot
在系统引导期间执行本进程. runlevels 域被忽略.
bootwait
在系统引导期间执行本进程. 并且 init 等待该进程的结束 (如 /etc/rc). runlevels 域被忽略.
off
什么也不做.
ondemand
在进入 ondemand 运行级时才会执行标记为 ondemand 的那些进程. 无论怎样, 实际上没有改变运行级 (ondemand 运行级就是 `a', `b', 和 `c').
initdefault
initdefault 条目给出系统引导完成后进入的运行级, 如果不存在这样的条目, init 就会在控制台询问要进入的运行级. process 域被忽略.
sysinit
系统引导期间执行此进程. 本进程会在 bootbootwait 条目之前得到执行. runlevels 域被忽略.
powerwait
本进程在电源不足时执行. 通常在有进程把 UPS 和计算机相连时通知 init 进程, Init 在继续其它工作之前要等待此进程结束.
powerfail
类似 powerwait, 但是init 不等待此进程完成.
powerokwait
init 收到电源已经恢复的通知后立即执行此进程.
powerfailnow
本进程在 init 被告知 UPS 电源快耗尽同时外部电源失败 (无效) 时被执行. (假设 UPS 和监视进程能够发现这样的情况).
ctrlaltdel
init 收到 SIGINT 信号时执行此进程. 这意味着有人在控制台按下了 CTRL-ALT-DEL 组合键, 典型地, 可能是想执行类似 shutdown 然后进入单用户模式或重新引导机器.
kbrequest
本进程在 init 收到一个从控制台键盘产生的特殊组合按键信号时执行.

对于此功能本文档尚未完成; 可以在 kbd-x.xx 包中找到更多信息 (在写作本文档时***的是 kbd-0.94). 当然你可能想为某些 "KeyboardSignal" 行为映射组合键, 如为了映射 (Alt-上箭头) 可以在键盘映射文件中 使用如下的方式:

alt keycode 103 = KeyboardSignal

举例

这是一个与老的 Linux 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

本文件在引导时执行 /etc/rc 并且在 ty1-tty4 上启动 getty 进程.

一个更详尽的 inittab 会有不同的运行级 (参考本身的注释):

# 进入默认的运行级
id:2:initdefault:

# 在进行其它工作之前先完成系统初始化.
si::sysinit:/etc/rc.d/bcheckrc

# 运行级 0 挂起系统, 6 重新引导, 1 单用户模式.
l0:0:wait:/etc/rc.d/rc.halt
l1:1:wait:/etc/rc.d/rc.single
l2:2345:wait:/etc/rc.d/rc.multi
l6:6:wait:/etc/rc.d/rc.reboot

# "3 个键" 按下时要做的工作.
ca::ctrlaltdel:/sbin/shutdown -t5 -rf now

# 运行级2和3: 在控制台生成 getty 进程, 运行级为3时在 modem 上生成 getty.
1:23:respawn:/sbin/getty tty1 VC linux
2:23:respawn:/sbin/getty tty2 VC linux
3:23:respawn:/sbin/getty tty3 VC linux
4:23:respawn:/sbin/getty tty4 VC linux
S2:3:respawn:/sbin/uugetty ttyS2 M19200

文件

/etc/inittab  

作者

Init 由 Miquel van Smoorenburg (miquels@cistron.nl) 所写. 本手册页由 Sebastian Lederer (lederer@francium.informatik.uni-bonn.de) 所写, 由 Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de) 修改.  

参考

init(8), telinit(8)

#p#

NAME

inittab - format of the inittab file used by the sysv-compatible init process  

DESCRIPTION

The inittab file describes which processes are started at bootup and during normal operation (e.g. /etc/init.d/boot, /etc/init.d/rc, gettys...). Init(8) distinguishes multiple runlevels, each of which can have its own set of processes that are started. Valid runlevels are 0-6 plus A, B, and C for ondemand entries. An entry in the inittab file has the following format:

id:runlevels:action:process

Lines beginning with `#' are ignored.

id
is a unique sequence of 1-4 characters which identifies an entry in inittab (for versions of sysvinit compiled with the old libc5 (< 5.2.18) or a.out libraries the limit is 2 characters).

Note: traditionally, for getty and other login processes, the value of the id field is kept the same as the suffix of the corresponding tty, e.g. 1 for tty1. Some ancient login accounting programs might expect this, though I can't think of any.

runlevels
lists the runlevels for which the specified action should be taken.
action
describes which action should be taken.
process
specifies the process to be executed. If the process field starts with a `+' character, init will not do utmp and wtmp accounting for that process. This is needed for gettys that insist on doing their own utmp/wtmp housekeeping. This is also a historic bug.

The runlevels field may contain multiple characters for different runlevels. For example, 123 specifies that the process should be started in runlevels 1, 2, and 3. The runlevels for ondemand entries may contain an A, B, or C. The runlevels field of sysinit, boot, and bootwait entries are ignored.

When the system runlevel is changed, any running processes that are not specified for the new runlevel are killed, first with SIGTERM, then with SIGKILL.

Valid actions for the action field are:

respawn
The process will be restarted whenever it terminates (e.g. getty).
wait
The process will be started once when the specified runlevel is entered and init will wait for its termination.
once
The process will be executed once when the specified runlevel is entered.
boot
The process will be executed during system boot. The runlevels field is ignored.
bootwait
The process will be executed during system boot, while init waits for its termination (e.g. /etc/rc). The runlevels field is ignored.
off
This does nothing.
ondemand
A process marked with an ondemand runlevel will be executed whenever the specified ondemand runlevel is called. However, no runlevel change will occur (ondemand runlevels are `a', `b', and `c').
initdefault
An initdefault entry specifies the runlevel which should be entered after system boot. If none exists, init will ask for a runlevel on the console. The process field is ignored.
sysinit
The process will be executed during system boot. It will be executed before any boot or bootwait entries. The runlevels field is ignored.
powerwait
The process will be executed when the power goes down. Init is usually informed about this by a process talking to a UPS connected to the computer. Init will wait for the process to finish before continuing.
powerfail
As for powerwait, except that init does not wait for the process's completion.
powerokwait
This process will be executed as soon as init is informormed that the power has been restored.
powerfailnow
This process will be executed when init is told that the battery of the external UPS is almost empty and the power is failing (provided that the external UPS and the monitoring process are able to detect this condition).
ctrlaltdel
The process will be executed when init receives the SIGINT signal. This means that someone on the system console has pressed the CTRL-ALT-DEL key combination. Typically one wants to execute some sort of shutdown either to get into single-user level or to reboot the machine.
kbrequest
The process will be executed when init receives a signal from the keyboard handler that a special key combination was pressed on the console keyboard.

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

EXAMPLES

This is an example of a inittab which resembles the old Linux 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

This inittab file executes /etc/rc during boot and starts gettys on tty1-tty4.

A more elaborate inittab with different runlevels (see the comments inside):

# Level to run in
id:2:initdefault:

# Boot-time system configuration/initialization script.
si::sysinit:/etc/init.d/rcS

# 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/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6

# What to do at the "3 finger salute".
ca::ctrlaltdel:/sbin/shutdown -t1 -h now

# Runlevel 2,3: getty on virtual consoles
# Runlevel   3: getty on terminal (ttyS0) and modem (ttyS1)
1:23:respawn:/sbin/getty tty1 VC linux
2:23:respawn:/sbin/getty tty2 VC linux
3:23:respawn:/sbin/getty tty3 VC linux
4:23:respawn:/sbin/getty tty4 VC linux
S0:3:respawn:/sbin/getty -L 9600 ttyS0 vt320
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).  

SEE ALSO

init(8), telinit(8)

责任编辑:韩亚珊 来源: Yin Huaming
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-24 17:19:00

raw中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man

2011-08-18 19:15:25

group中文man

2011-08-23 10:17:54

bdflush中文man
点赞
收藏

51CTO技术栈公众号