This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinittab.man
218 lines (218 loc) · 9.08 KB
/
inittab.man
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.TH inittab 5
'''
.SH NAME
{/etc/inittab} - \fBinit\fR(8) configuration file.
'''
.SH DESCRIPTION
Inittab is a list of commands init should run.
.P
Each relevant line in inittab describes a single process (an entry)
to be run by init. Init records the ids of the processes it spawns
and tracks them until processes die.
.P
At any point, init is in one of runlevels 0, 1, ... 9, with zero or more
sublevels a, b, ..., f activated. Each entry has its own runlevel mask,
with zero or more runlevels and zero or more sublevels.
.P
Init decides whether an entry should be running or not using current
runlevel and entry's runlevel mask. Subsequently the entry is either
spawned, killed or skipped. Entries are always started in top-to-bottom
order, and killed bottom-to-top.
.P
In case a tracked process dies, init attempts to respawn the relevant entry
unless the entry is explicitly marked as run-once. A typical configuration
would include run-once system initialization commands and respawn entries
for various system services (daemons).
.P
Along with the entries itself, inittab may also contain environment
variables to be passed to the spawned processes via \fBexecve\fR(2).
'''
.SH SYNTAX
Inittab is a text file parsed in line wise manner.
.IP "# \fIcomment\fR" 4
Lines starting with # are ignored by init
.IP "\fIvariable\fR=\fIvalue\fR" 4
Add \fIvariable\fR to the environment to be passed to processes started
by init.
.IP "\fIname\fR \fImode\fR \fIcommand\fR" 4
Define an entry. The fields (name, mode and command) may be separated
with spaces or tabs. See below for the meaning of each of the three fields.
.P
Init parses and later spawns the entries in top-to-bottom order.
Depending on flags and current runlevel, some entries may be skipped,
but not reordered.
.P
The relative order of environment and process lines is irrelevant.
All spawned processes will get exactly the same environment.
Comments and empty lines are ignored.
'''
.SS Naming entries
\fIname\fR is a string used to identify this entry, in particular when
stopping/starting processes with \fBtelinit\fR(8), as well as in syslog
messages. To make a unnamed entry, start a line with any whitespace character.
Non-empty names should be unique.
.P
During reconfiguration, init matches entries with the same name, and transfers
process ids from the old configuration. For un-named entries, and in case names
do not match, the old process gets killed and the new one started.
This is mostly relevant for respawning entries.
'''
.SS Entry mode
The second field, \fImode\fR, describes how the entry should be handled by init.
Its format is \fIM\fB[\fI123\fB][\fI*\fB]\fR, with \fIM\fR (mode) determining
how the entry should be (re)started, and \fI123*\fR setting runlevel mask.
Possible modes are:
.IP "\fBS\fR" 4
Service (foreground daemon). The entry will be respawned, unless it respawns
too fast, in which case it will be disabled. Use for processes which are not
expected to exit during normal operation.
.IP "\fBF\fR" 4
Fast-respawning entry. Same as \fBS\fR, except the entry is allowed
to respawn fast as long as it keeps exiting with 0 exit code.
Use for processes that do respawn during normal operation (gettys and such).
.IP "\fBR\fR" 4
Run once. Do not respawn the process. Use this flag for independent system
initialization entries, like sysctl or non-root mounts or early network setup.
.IP "\fBW\fR" 4
Run once and wait for this process. Do not restart it, and do not proceed
further until it dies. Use this for critical initialization entries, like
mounting root. \fBW\fR-process will not be started until all preceding
\fBR\fR-entries have exited, and no subsequent entries will be started until
it exits.
.IP "\fBX\fR" 4
Run once when entering any runlevel not matching the mask.
Should be used for wakeup scripts.
.IP "\fBL\fR" 4
Like \fBS\fR, but wait for other processes die before stopping this one.
This may be useful for syslogd and klogd.
.IP "\fBT\fR" 4
Fast-respawning \fBgetty\fR(1)-like entry. SIGABRT is used to kill it,
as gettys tend to ignore SIGTERM, and abnormal exits are never logged.
.P
Runlevel mask is any subset of \fB0123456789\fR characters.
The entry will be started only if current runlevel is in entry's runlevel
mask (except for \fBX\fR-entries, which do the opposite). The \fB*\fR sign
extends the last runlevell all the way to \fB9\fR, so \fB3*\fR is the same
as \fB3456789\fR.
.P
Runlevel mask may also include a subset of secondary runlevels, \fBabcdef\fR.
If it does, it will only be started if current primary runlevel is in its
mask and all its secondary runlevels are active. Example: \fBS3ac\fR entry
will be started on runlevel \fB3\fR only if both \fBa\fR and \fBc\fR sublevels
are active. See \fBtelinit\fR(8) on how to activate or deactivate sublevels.
.P
Leaving out runlevels completely is the same as using \fB23456789\fR.
'''
.SS Commands
The last field, \fIcommand\fR, is the command to run. The field is parsed and
passed as the second argument to \fBexecve\fR(2) call.
.P
Wherever necessary, init calls /bin/sh -c to execute the command.
.P
.EX
# Regular command, execve("/sbin/agetty", ...) will be used
tty1 F /sbin/agetty --noclear -8 -s 38400 tty1 linux
# Shell command, execve("/bin/sh", "-c", "echo 1 > /proc/...")
R echo 1 > /proc/sys/net/ipv4/ip_forward
.EE
'''
.SH USAGE
The primary role of inittab is listing commands needed to bring the system up
after booting the kernel. Typically this involves run-once entries performing
runtime kernel configuration (file systems, network) and respawning entries
for system daemons and user interface.
.P
Transition to other system states (reboot, shutdown, sleep) may be described
if appropriate, using run-once entries to alter kernel state and runlevel
masks to start or stop certain system services.
'''
.SS Runlevel designation
Certain runlevels have particular meaning assigned to them:
.IP "\fB0\fR" 4
System shutdown (reset, halt or poweroff).
.IP "\fB1\fR" 4
Single-user mode, or recovery mode.
.IP "\fB3\fR" 4
Default runlevel, common or multi-user mode
.IP "\fB7\fR, \fB8\fR, \fB9\fR" 4
Slippery runlevels intended for sleep modes.
.P
Runlevels other than \fB0\fR and \fB789\fR are general-purpose.
Runlevel \fB0\fR is hard-coded to initiate \fBreboot\fR(2) call
and may not be used for anything else.
'''
.SS System startup and shutdown
Commands to run during system startup should be placed at the start
of inittab either \fBW\fR-entries or \fBR\fR-entries; \fBW\fR should
be used commands that affect common environment like mount root while
\fBR\fR is enough for independent commands.
.P
Most startup commands should have empty runlevel mask, which translates
to \fB23456789\fR. Commands common for normal and recovery startup, if any,
need single \fB*\fR. Recovery-only commands should be \fBR1\fR or \fBW1\fR.
.P
Shutdown commands should be \fBR0\fR or \fBW0\fR.
.P
.EX
# System initialization
mount W /sbin/mount -o remount,rw /
hwclock R /sbin/hwclock -s
umount X /sbin/umount -a
.EE
'''
.SS Foreground daemons
Any process doing \fBdaemon\fR(3) style startup will confuse init if configured
as an \fBS\fR-type entry, since init has no way to track the daemonized child
process and will attemp to take action immediately after the parent exits.
.P
Whenever possible, processes must be instructed to run in foreground mode.
Most daemons allow this; check relevant man pages.
.P
.EX
# Start some foreground services
syslogd L /usr/sbin/syslogd -n
ntpd S /usr/sbin/ntpd -g -n
vsftpd S /usr/bin/vsftpd /etc/vsftpd.conf -obackground=NO
.EE
.P
In case \fBinitdir\fR(5) is used, most \fBS\fR-type entries should
go there and not to inittab. Any ordered entries, including \fBL\fR-type
services, must remain in inittab.
'''
.SS Slippery runlevels
Reaching any of runlevels \fB7\fR, \fB8\fR, \fB9\fR initiates immediate
switch back to the original non-slippery runlevel.
For instance, running \fBtelinit 8\fR while on runlevel \fB3\fR makes
init switch \fB3\fR to \fB8\fR and back to \fB3\fR.
.P
To implement a sleep state using a slippery runlevel, make all pre-sleep
preparation \fBR\fR-entries, put the sleep command itself as a \fBW\fR-entry,
and make post-sleep recovery \fBX\fR-entries:
.P
.EX
# Suspend-to-ram implemented as runlevel 7:
R7 /sbin/network down
sleep W7 /bin/echo mem > /sys/power/state
X7 /sbin/network up
.EE
.P
In case respawning processes that should be stopped when entering sleep mode,
remove relevant runlevels from their respective masks (\fBS3456\fR instead
of \fBS3*\fR).
'''
.SH COMPATIBILITY
This page describes inittab format for \fB{INIT}\fR package.
It is not compatible with the traditional System V init format.
.P
Most features of System V style inittab features translate easily into those
understood by sninit. However, SysV-compatible implementations tend
to use initscripts system instead of \fBinitdir\fR(5), making automated
translation between two formats pointless.
Shutdown/reboot handling differs as well, and sleep modes are not typically
supported.
.P
Because of this, translating traditional inittab for use with {INIT}
rarely makes sense.
'''
.SH SEE ALSO
\fBinit\fR(8), \fBtelinit\fR(8)