| INITTAB(5) | Formatos de Ficheiro | INITTAB(5) |
NOME¶
inittab - formato do ficheiro inittab usando pelo processo init compatível com sysv
DESCRIÇÃO¶
O ficheiro inittab descreve quais processos são iniciados no arranque e durante a operação normal (ex. /etc/init.d/boot, /etc/init.d/rc, gettys...). O init(8) distingue múltiplos runlevels, cada um dos quais pode ter o seu próprio conjunto de processos que é arrancado. Os runlevels válidos são 0-6 mais A, B, e C para entradas ondemand. Uma entrada no ficheiro inittab tem o seguinte formato:
id:runlevels:action:process
- 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
- lista os runlevels para os quais a acção especificada deve ser tomada.
- action
- descreve qual a acção que deve ser tomada.
- 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 length of this
field is limited to 253 characters. Anything beyond 253 will result in a
log warning and the process command line being skipped/ignored.
Please note that including certain characters in the process field will result in init attempting to launch a shell to interpret the command contained in the process field. The characters which will trigger a shell are: ~`!$^&*()=|}[];"'<>?
Em sistemas que não tenham uma shell para ser lançada ou quais não se deseja usar uma shell para interpretar o campo do processo, o campo de processo pode ser prefixado com o símbolo @. O @ irá ser ignorado e tudo o que se segue será tratado como o comando a ser lançado, literalmente, pelo serviço init.
Em casos que ambos sinais + e @ vão ser usados (para desligar os relatórios e interpretação da shell) coloque o sinal + antes do símbolo @. Ambas bandeiras irão ser lidadas e depois tudo o que se segue ao @ irá ser lidado pelo init
O campo runlevels pode conter vários caracteres para diferentes runlevels. Por exemplo, 123 especifica que o processo deve ser iniciado nos runlevels 1, 2, e 3. Os runlevels para entradas ondemand podem conter um A, B, ou C. O campo runlevels das entradas sysinit, boot, e bootwait é ignorado.
Quando o runlevel do sistema é mudado, quaisquer processos a correr que não estão especificados para o novo runlevel são mortos, primeiro com SIGTERM, e depois com SIGKILL.
As acções válidas para o campo action são:
- respawn
- O processo será reiniciado sempre que termine (ex. getty).
- wait
- O processo irá ser iniciado assim que se entra no runlevel especificado e o init irá esperar pelo seu término.
- once
- O processo irá ser executado uma vez quando se entra no runlevel especificado.
- boot
- O processo será executado durante o arranque do sistema. O campo runlevels é ignorado.
- bootwait
- O processo será executado durante o arranque do sistema, enquanto init espera pelo seu término (ex. /etc/rc). O campo runlevels é ignorado.
- off
- Isto não faz nada.
- ondemand
- Um processo marcado com um runlevel ondemand será executado sempre que o runlevel ondemand especificado é chamado. No entanto, nenhuma mudança de runlevel irá ocorrer (os runlevels ondemand são `a', `b', e `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
- Como para powerwait, excepto que o init não espera pelo final do processo.
- powerokwait
- Este processo será executado assim que o init é informado que a energia foi restaurada.
- powerfailnow
- Este processo será executado quando é dito ao init que a bateria da UPS externa está quase vazia e a energia está a falhar (desde que a UPS externa e o processo de monitorização sejam capazes de detectar esta condição).
- 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
- O processo será executado quando o init receber um sinal a
partir do manipulador do teclado que uma combinação especial
de teclas foi pressionada no teclado da consola.
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
Note: In environments where the directory /etc/inittab.d/ exists, init will read the contents of this directory and open any files with the ".tab" extension. These .tab files can introduce additional lines and settings with the same format as inittab. The .tab files are optional and provide a install-specific method for adding extra options or functionality.
EXEMPLOS¶
Isto é um exemplo de uma inittab que é semelhante à inittab antiga do Linux:
# 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
Uma inittab mais elaborada com diferentes runlevels (veja os comentários no interior):
# Nível para onde correr id:2:initdefault: # Script de configuração/inicialização do sistema durante o arranque. si::sysinit:/etc/init.d/rcS # O que fazer em modo de único-utilizador. ~: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 # O que fazer na "saudação dos 3 dedos". 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
FICHEIROS¶
/etc/inittab
AUTOR¶
init foi escrito por Miquel van Smoorenburg. Este manual foi escrito por Sebastian Lederer e modificado por Michael Haardt.
VEJA TAMBÉM¶
| 4 Dezembro, 2001 | sysvinit |