/etc/inittab 分析
2013-03-24 14:22
176 查看
文件格式:
<id>:<runlevels>:<action>:<process>各标号的意思:
标号 | 说明 |
Id | 表示这个进程要使用的控制台,省略默与init进程相同 |
Runlevels | 运行级别 |
Action | Init进程如何控制此进程 |
process | 要执行的程序(可执行程序或脚本) |
Action名称 | 执行条件 | 说明 |
Sysinit | 系统启动后最先执行 | 只执行一次,init进程等待它结束才继续执行其他动作 |
Wait | 系统执行完sysinit进程后,执行 | 只执行一次,init进程等待它结束才继续执行其他动作 |
Once | 系统执行完wait进程后执行 | 只执行一次,init进程不等待它结束 |
Respawn | 启动完once进程后 | Init进程监测发现子进程退出时,重新启动它 |
Askfirst | 启动完respawn进程后 | 与respawn进程类似,不过init进程先输出Please press Enter to active this console,等待用户输入回车键后才启动 |
Shutdown | 当系统关机时 | 即重启、关闭系统时 |
Restart | 当init进程收到SIGHUP(挂断控制终端)信号时 | 先重新读取,解析/etc/inittab文件,在执行restart程序 |
Ctrlatldel | 按下ctrl+alt+del 时 | |
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 ondemandentries. An entry in the inittab file
has the following format:
id:runlevels:action:processLines 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 libraries < 5.2.18 or a.out libraries the limit is 2 characters).
Note: For gettys or other login processes, the id field should be the tty suffix of the corresponding tty, e.g. 1 for tty1. Otherwise, the login accounting might not work correctly.
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, 123specifies that the process should be started in runlevels 1, 2, and 3. The runlevels forondemand entries may contain
an A, B, or C. The runlevels field of sysinit, boot, and bootwaitentries 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 (ondemandrunlevels 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 orbootwait 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: # System initialization before anything else. si::sysinit:/etc/rc.d/bcheckrc # Runlevel 0,6 is halt and reboot, 1 is maintenance mode. 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 # What to do at the "3 finger salute". ca::ctrlaltdel:/sbin/shutdown -t5 -rf now # Runlevel 2&3: getty on console, level 3 also getty on modem port. 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
相关文章推荐
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- 详细分析 /etc/inittab 文件
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- /etc/inittab文件分析
- 系统运行级别 /etc/inittab 分析
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- /etc/inittab文件分析
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- /etc/inittab,/etc/init.d/rcS和/etc/profile分析
- ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析
- aix 下的/etc/inittab注释解析
- etc/inittab的使用
- 修改/etc/inittab后如何保存退出
- MINI2440启动配置文件/etc/init.d/rcS文件分析
- linux(rh7)下/etc/shadow文件分析
- ubuntu中没有/etc/inittab文件探究
- init和/etc/inittab
- 开机自动运行---/etc/init.d/rcS 分析【转】
- 详解 /etc/inittab 文件