1 .\" $NetBSD: init.8,v 1.56 2009/04/08 14:21:55 joerg Exp $
3 .\" Copyright (c) 1980, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Donn Seeley at Berkeley Software Design, Inc.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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
33 .\" @(#)init.8 8.6 (Berkeley) 5/26/95
40 .Nd process control initialization
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.
50 The following table describes the state machine used by
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
61 If the kernel is in a secure mode,
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
68 Multi-user boot (default operation).
73 If this was the first state entered (as opposed to entering here after
76 will be invoked with its first argument being
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.
87 sysctl node is not equal to
91 process will be run inside a
93 indicated by sysctl with the same error handling as above.
95 If the administrator has not set the security level to \-1
96 to indicate that the kernel should not run multiuser in secure
99 script has not set a higher level of security
102 will put the kernel into securelevel mode 1.
106 .Xr secmodel_securelevel 9
107 for more information.
109 Set up ttys as specified in
111 See below for more information.
112 On completion, continue to state 4.
113 If we did chroot in state 2, each
115 process will be run in the same
117 path as in 2 (that is, the value of
119 sysctl is not re-read).
121 Multi-user operation.
122 Depending upon the signal received, change state appropriately;
133 Clean-up mode; re-read
135 killing off the controlling processes on lines that are now
137 and starting processes that are newly
139 On completion, go to state 4.
142 mode; no new sessions.
143 Signals as per state 4.
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.
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
167 It should be noted that while
169 has the ability to start multi-user operation inside a
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.
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,
190 processes for the terminal ports found in the file
193 reads this file, and executes the command found in the second field.
194 This command is usually
196 it opens and initializes the tty line and executes the
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
209 files of current users and records the logout in the
221 Line status (on, off, secure, getty, or window information)
222 may be changed in the
224 file without a reboot by sending the signal
229 .Dq Li "kill \-s HUP 1" .
230 This is referenced in the table above as state 5.
231 On receipt of this signal,
236 When a line is turned off in
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
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
258 will not do anything at all to that line.
259 However, it will complain that the relationship between lines
262 file and records in the
265 so this practice is not recommended.
268 will terminate multi-user operations and resume single-user mode
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
282 and allow the system to slowly die away, if it is sent a terminal stop
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.
295 is so critical that if it dies, the system will reboot itself
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) .
310 .Dq Li "MAKEDEV -MM init" .
316 to create a memory file system mounted over
318 that contains the standard devices considered necessary to boot the system.
320 .Bl -tag -width /var/log/wtmp{,x} -compact
322 System console device.
324 Terminal ports found in
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.
331 The terminal initialization information file.
333 System startup commands.
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
347 This condition is usually caused by a process that is stuck in a
348 device driver because of a persistent device error condition.
360 .Xr MAKEDEV.local 8 ,
368 .Xr secmodel_bsd44 9 ,
369 .Xr secmodel_securelevel 9