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
描述應採取哪種行爲。
指定要執行的進程,如果該域以'+' 符號開頭,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 運行等級被調用時,進程會被執行。但是不會發生運行等級的改變。(ondemand 運行等級爲'a','b','c')initdefault
initdefault 入口指定了系統啓動後需要進入的運行等級。如果不存在,init 進程會在命令行中詢問一個運行等級。進程域被忽略。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 。
A more elaborate inittab with different runlevels (see the comments inside):
以下是一個更加精細的 inittab :
# Level to run in
id:2:initdefault:
# 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 ([email protected]). This manual page was written by Sebastian Lederer ([email protected]) and modified by Michael Haardt ([email protected]).