inittab 中文man頁面
NAME
inittab - 與 sysv 兼容的 init 進(jìn)程使用的初始化文件格式
描述
inittab 文件描述在系統(tǒng)引導(dǎo)及通常的操作期間, 都啟動(dòng)哪些進(jìn)程 (比如 /etc/init.d/boot, /etc/init.d/rc, getty 等等). Init(8) 討論有關(guān) runlevels (運(yùn)行級(jí)) 的概念, 每一個(gè)運(yùn)行級(jí)都有它自己啟動(dòng)進(jìn)程的集合. 有效的運(yùn)行級(jí)為 0-6 加上用于 ondemand 條目的 A, B 和 C. inittab 文件中的每一個(gè)條目有如下的格式:
-
id:runlevels:action:process
以 `#' 開頭的行被忽略.
- id
- inittab 文件中條目的唯一標(biāo)識(shí), 限于 1-4 個(gè)字符 (如果是用版本號(hào)小于 5.2.18 或 a.out 的庫編譯生成的 sysvinit 程序, 則僅限于 2 個(gè)字符).
注意: 對(duì)于 getty 或其它的注冊進(jìn)程, id 必須是響應(yīng)的終端線路的 tty 后綴, 如 1 響應(yīng) tty1, 否則, 注冊過程不能正常的工作.
- runlevels
- 列出發(fā)生指定動(dòng)作的運(yùn)行級(jí).
- action
- 描述要發(fā)生的動(dòng)作.
- process
- 要執(zhí)行的進(jìn)程. 如果 process 域以一個(gè) `+' 開頭, init 不會(huì)在 utmp 和 wtmp 文件中為此進(jìn)程記帳. 這是由于 getty 自己主持 utmp/wtmp 記帳的需要, 同時(shí)這也是一個(gè)歷史遺留的漏洞.
runlevels 域可以包含表示不同運(yùn)行級(jí)的多個(gè)字符, 例如 123 表示本進(jìn)程在運(yùn)行級(jí)為 1, 2 和 3 時(shí)都要啟動(dòng). 用于 ondemand 條目的 runlevels 域可以包含 A, B, 或 C. 用于 sysinit, boot, 和 bootwait 條目的 runlevels 域被忽略.
當(dāng)改變運(yùn)行級(jí)時(shí), 在新運(yùn)行級(jí)中沒有給出的那些正在運(yùn)行的進(jìn)程被殺死, 先使用 SIGTERM 信號(hào), 然后是 SIGKILL.
action 域可以使用的動(dòng)作有:
- respawn
- 該進(jìn)程只要終止就立即重新啟動(dòng) (如 getty).
- wait
- 只要進(jìn)入指定的運(yùn)行級(jí)就啟動(dòng)本進(jìn)程, 并且 init 等待該進(jìn)程的結(jié)束.
- once
- 只要進(jìn)入指定的運(yùn)行級(jí)就啟動(dòng)一次本進(jìn)程.
- boot
- 在系統(tǒng)引導(dǎo)期間執(zhí)行本進(jìn)程. runlevels 域被忽略.
- bootwait
- 在系統(tǒng)引導(dǎo)期間執(zhí)行本進(jìn)程. 并且 init 等待該進(jìn)程的結(jié)束 (如 /etc/rc). runlevels 域被忽略.
- off
- 什么也不做.
- ondemand
- 在進(jìn)入 ondemand 運(yùn)行級(jí)時(shí)才會(huì)執(zhí)行標(biāo)記為 ondemand 的那些進(jìn)程. 無論怎樣, 實(shí)際上沒有改變運(yùn)行級(jí) (ondemand 運(yùn)行級(jí)就是 `a', `b', 和 `c').
- initdefault
- initdefault 條目給出系統(tǒng)引導(dǎo)完成后進(jìn)入的運(yùn)行級(jí), 如果不存在這樣的條目, init 就會(huì)在控制臺(tái)詢問要進(jìn)入的運(yùn)行級(jí). process 域被忽略.
- sysinit
- 系統(tǒng)引導(dǎo)期間執(zhí)行此進(jìn)程. 本進(jìn)程會(huì)在 boot 或 bootwait 條目之前得到執(zhí)行. runlevels 域被忽略.
- powerwait
- 本進(jìn)程在電源不足時(shí)執(zhí)行. 通常在有進(jìn)程把 UPS 和計(jì)算機(jī)相連時(shí)通知 init 進(jìn)程, Init 在繼續(xù)其它工作之前要等待此進(jìn)程結(jié)束.
- powerfail
- 類似 powerwait, 但是init 不等待此進(jìn)程完成.
- powerokwait
- 在 init 收到電源已經(jīng)恢復(fù)的通知后立即執(zhí)行此進(jìn)程.
- powerfailnow
- 本進(jìn)程在 init 被告知 UPS 電源快耗盡同時(shí)外部電源失敗 (無效) 時(shí)被執(zhí)行. (假設(shè) UPS 和監(jiān)視進(jìn)程能夠發(fā)現(xiàn)這樣的情況).
- ctrlaltdel
- 在 init 收到 SIGINT 信號(hào)時(shí)執(zhí)行此進(jìn)程. 這意味著有人在控制臺(tái)按下了 CTRL-ALT-DEL 組合鍵, 典型地, 可能是想執(zhí)行類似 shutdown 然后進(jìn)入單用戶模式或重新引導(dǎo)機(jī)器.
- kbrequest
- 本進(jìn)程在 init 收到一個(gè)從控制臺(tái)鍵盤產(chǎn)生的特殊組合按鍵信號(hào)時(shí)執(zhí)行.
對(duì)于此功能本文檔尚未完成; 可以在 kbd-x.xx 包中找到更多信息 (在寫作本文檔時(shí)***的是 kbd-0.94). 當(dāng)然你可能想為某些 "KeyboardSignal" 行為映射組合鍵, 如為了映射 (Alt-上箭頭) 可以在鍵盤映射文件中 使用如下的方式:
-
alt keycode 103 = KeyboardSignal
-
舉例
這是一個(gè)與老的 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
本文件在引導(dǎo)時(shí)執(zhí)行 /etc/rc 并且在 ty1-tty4 上啟動(dòng) getty 進(jìn)程.
一個(gè)更詳盡的 inittab 會(huì)有不同的運(yùn)行級(jí) (參考本身的注釋):
-
# 進(jìn)入默認(rèn)的運(yùn)行級(jí) id:2:initdefault: # 在進(jìn)行其它工作之前先完成系統(tǒng)初始化. si::sysinit:/etc/rc.d/bcheckrc # 運(yùn)行級(jí) 0 掛起系統(tǒng), 6 重新引導(dǎo), 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 個(gè)鍵" 按下時(shí)要做的工作. ca::ctrlaltdel:/sbin/shutdown -t5 -rf now # 運(yùn)行級(jí)2和3: 在控制臺(tái)生成 getty 進(jìn)程, 運(yùn)行級(jí)為3時(shí)在 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)