snj doesn't like my accent, so use proper English month names.
[netbsd-mini2440.git] / sbin / init / init.8
blobc370f1f3787f894eca77ce761bce1d1b99d115c1
1 .\"     $NetBSD: init.8,v 1.56 2009/04/08 14:21:55 joerg Exp $
2 .\"
3 .\" Copyright (c) 1980, 1991, 1993
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Donn Seeley at Berkeley Software Design, Inc.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\"    may be used to endorse or promote products derived from this software
19 .\"    without specific prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .\"     @(#)init.8      8.6 (Berkeley) 5/26/95
34 .\"
35 .Dd November 10, 2008
36 .Dt INIT 8
37 .Os
38 .Sh NAME
39 .Nm init
40 .Nd process control initialization
41 .Sh SYNOPSIS
42 .Nm
43 .Sh DESCRIPTION
44 The
45 .Nm
46 program is the last stage of the boot process (after the kernel loads
47 and initializes all the devices).
48 It normally begins multi-user operation.
49 .Pp
50 The following table describes the state machine used by
51 .Nm :
52 .Bl -enum
53 .It
54 Single user shell.
55 .Nm
56 may be passed
57 .Fl s
58 from the boot program to prevent the system from going multi-user and
59 to instead execute a single user shell without starting the normal
60 daemons.
61 If the kernel is in a secure mode,
62 .Nm
63 will downgrade it to securelevel 0 (insecure mode).
64 The system is then quiescent for maintenance work and may
65 later be made to go to state 2 (multi-user) by exiting the single-user
66 shell (with ^D).
67 .It
68 Multi-user boot (default operation).
69 Executes
70 .Pa /etc/rc
71 (see
72 .Xr rc 8 ) .
73 If this was the first state entered (as opposed to entering here after
74 state 1), then
75 .Pa /etc/rc
76 will be invoked with its first argument being
77 .Sq autoboot .
79 .Pa /etc/rc
80 exits with a non-zero (error) exit code, commence single user
81 operation by giving the super-user a shell on the console by going
82 to state 1 (single user).
83 Otherwise, proceed to state 3.
84 .Pp
85 If value of the
86 .Dq init.root
87 sysctl node is not equal to
88 .Pa /
89 at this point, the
90 .Pa /etc/rc
91 process will be run inside a
92 .Xr chroot 2
93 indicated by sysctl with the same error handling as above.
94 .Pp
95 If the administrator has not set the security level to \-1
96 to indicate that the kernel should not run multiuser in secure
97 mode, and the
98 .Pa /etc/rc
99 script has not set a higher level of security
100 than level 1, then
102 will put the kernel into securelevel mode 1.
104 .Xr rc.conf 5
106 .Xr secmodel_securelevel 9
107 for more information.
109 Set up ttys as specified in
110 .Xr ttys 5 .
111 See below for more information.
112 On completion, continue to state 4.
113 If we did chroot in state 2, each
114 .Xr getty 8
115 process will be run in the same
116 .Xr chroot 2
117 path as in 2 (that is, the value of
118 .Dq init.root
119 sysctl is not re-read).
121 Multi-user operation.
122 Depending upon the signal received, change state appropriately;
124 .Dv SIGTERM ,
125 go to state 7;
127 .Dv SIGHUP ,
128 go to state 5;
130 .Dv SIGTSTP ,
131 go to state 6.
133 Clean-up mode; re-read
134 .Xr ttys 5 ,
135 killing off the controlling processes on lines that are now
136 .Sq off ,
137 and starting processes that are newly
138 .Sq on .
139 On completion, go to state 4.
141 .Sq Boring
142 mode; no new sessions.
143 Signals as per state 4.
145 Shutdown mode.
146 Send
147 .Dv SIGHUP
148 to all controlling processes, reap the processes for 30 seconds,
149 and then go to state 1 (single user); warning if not all the processes died.
152 If the
153 .Sq console
154 entry in the
155 .Xr ttys 5
156 file is marked
157 .Dq insecure ,
158 then
160 will require that the superuser password be
161 entered before the system will start a single-user shell.
162 The password check is skipped if the
163 .Sq console
164 is marked as
165 .Dq secure .
167 It should be noted that while
169 has the ability to start multi-user operation inside a
170 .Xr chroot 2
171 environment, the
173 process itself will always run in the
174 .Dq original root directory .
175 This also implies that single-user mode is always started in the original
176 root, giving the possibility to create multi-user sessions in different
177 root directories over time.
179 .Dq init.root
180 sysctl node is fabricated by
182 at startup and re-created any time it's found to be missing.
183 Type of the node is string capable of holding full pathname, and
184 is only accessible by the superuser (unless explicitly destroyed
185 and re-created with different specification).
187 In multi-user operation,
189 maintains
190 processes for the terminal ports found in the file
191 .Xr ttys 5 .
193 reads this file, and executes the command found in the second field.
194 This command is usually
195 .Xr getty 8 ;
196 it opens and initializes the tty line and executes the
197 .Xr login 1
198 program.
200 .Xr login 1
201 program, when a valid user logs in, executes a shell for that user.
202 When this shell dies, either because the user logged out or an
203 abnormal termination occurred (a signal), the
205 program wakes up, deletes the user from the
206 .Xr utmp 5
208 .Xr utmpx 5
209 files of current users and records the logout in the
210 .Xr wtmp 5
212 .Xr wtmpx 5
213 files.
214 The cycle is
215 then restarted by
217 executing a new
218 .Xr getty 8
219 for the line.
221 Line status (on, off, secure, getty, or window information)
222 may be changed in the
223 .Xr ttys 5
224 file without a reboot by sending the signal
225 .Dv SIGHUP
228 with the command
229 .Dq Li "kill \-s HUP 1" .
230 This is referenced in the table above as state 5.
231 On receipt of this signal,
233 re-reads the
234 .Xr ttys 5
235 file.
236 When a line is turned off in
237 .Xr ttys 5 ,
239 will send a
240 .Dv SIGHUP
241 signal to the controlling process
242 for the session associated with the line.
243 For any lines that were previously turned off in the
244 .Xr ttys 5
245 file and are now on,
247 executes a new
248 .Xr getty 8
249 to enable a new login.
250 If the getty or window field for a line is changed,
251 the change takes effect at the end of the current
252 login session (e.g., the next time
254 starts a process on the line).
255 If a line is commented out or deleted from
256 .Xr ttys 5 ,
258 will not do anything at all to that line.
259 However, it will complain that the relationship between lines
260 in the
261 .Xr ttys 5
262 file and records in the
263 .Xr utmp 5
264 file is out of sync,
265 so this practice is not recommended.
268 will terminate multi-user operations and resume single-user mode
269 if sent a terminate
270 .Pq Dv TERM
271 signal, for example,
272 .Dq Li "kill \-s TERM 1" .
273 If there are processes outstanding that are deadlocked (because of
274 hardware or software failure),
276 will not wait for them all to die (which might take forever), but
277 will time out after 30 seconds and print a warning message.
280 will cease creating new
281 .Xr getty 8 Ns 's
282 and allow the system to slowly die away, if it is sent a terminal stop
283 .Pq Dv TSTP
284 signal, i.e.
285 .Dq Li "kill \-s TSTP 1" .
286 A later hangup will resume full
287 multi-user operations, or a terminate will start a single user shell.
288 This hook is used by
289 .Xr reboot 8
291 .Xr halt 8 .
293 The role of
295 is so critical that if it dies, the system will reboot itself
296 automatically.
297 If, at bootstrap time, the
299 process cannot be located, or exits during its initialisation,
300 the system will panic with the message
301 .Dq panic: init died (signal %d, exit %d) .
304 .Pa /dev/console
305 does not exist,
307 will cd to
308 .Pa /dev
309 and run
310 .Dq Li "MAKEDEV -MM init" .
311 .Xr MAKEDEV 8
312 will use
313 .Xr mount_tmpfs 8
315 .Xr mount_mfs 8
316 to create a memory file system mounted over
317 .Pa /dev
318 that contains the standard devices considered necessary to boot the system.
319 .Sh FILES
320 .Bl -tag -width /var/log/wtmp{,x} -compact
321 .It Pa /dev/console
322 System console device.
323 .It Pa /dev/tty*
324 Terminal ports found in
325 .Xr ttys 5 .
326 .It Pa /var/run/utmp{,x}
327 Record of current users on the system.
328 .It Pa /var/log/wtmp{,x}
329 Record of all logins and logouts.
330 .It Pa /etc/ttys
331 The terminal initialization information file.
332 .It Pa /etc/rc
333 System startup commands.
335 .Sh DIAGNOSTICS
336 .Bl -diag
337 .It "getty repeating too quickly on port %s, sleeping"
338 A process being started to service a line is exiting quickly
339 each time it is started.
340 This is often caused by a ringing or noisy terminal line.
341 .Em "Init will sleep for 10 seconds" ,
342 .Em "then continue trying to start the process" .
344 .It "some processes would not die; ps axl advised."
345 A process is hung and could not be killed when the system was
346 shutting down.
347 This condition is usually caused by a process that is stuck in a
348 device driver because of a persistent device error condition.
350 .Sh SEE ALSO
351 .Xr config 1 ,
352 .Xr kill 1 ,
353 .Xr login 1 ,
354 .Xr sh 1 ,
355 .Xr options 4 ,
356 .Xr ttys 5 ,
357 .Xr getty 8 ,
358 .Xr halt 8 ,
359 .Xr MAKEDEV 8 ,
360 .Xr MAKEDEV.local 8 ,
361 .Xr mount_mfs 8 ,
362 .Xr mount_tmpfs 8 ,
363 .Xr rc 8 ,
364 .Xr reboot 8 ,
365 .Xr rescue 8 ,
366 .Xr shutdown 8 ,
367 .Xr sysctl 8 ,
368 .Xr secmodel_bsd44 9 ,
369 .Xr secmodel_securelevel 9
370 .Sh HISTORY
373 command appeared in
374 .At v6 .