1 .\" $NetBSD: init.8,v 1.59 2013/10/02 22:07:56 apb 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
47 program is the last stage of the boot process.
48 It normally begins multi-user operation.
51 is executed automatically by the kernel,
52 after the kernel has initialised all devices
53 and mounted the root file system.
54 The kernel may try multiple possible paths for
63 The following table describes the state machine used by
68 If the kernel is booted in single user mode (see
70 then the kernel will pass the
74 to prevent the system from going multi-user and
75 to instead execute a single user shell without starting the normal
77 If the kernel is in a secure mode,
79 will downgrade it to securelevel 0 (insecure mode).
80 The system is then quiescent for maintenance work and may
81 later be made to go to state 2 (multi-user) by exiting the single-user
84 Multi-user boot (default operation).
89 If this was the first state entered (as opposed to entering here after
92 will be invoked with its first argument being
96 exits with a non-zero (error) exit code, commence single user
97 operation by giving the super-user a shell on the console by going
98 to state 1 (single user).
99 Otherwise, proceed to state 3.
103 sysctl node is not equal to
107 process will be run inside a
109 indicated by sysctl with the same error handling as above.
111 If the administrator has not set the security level to \-1
112 to indicate that the kernel should not run multiuser in secure
115 script has not set a higher level of security
118 will put the kernel into securelevel mode 1.
122 .Xr secmodel_securelevel 9
123 for more information.
125 Set up ttys as specified in
127 See below for more information.
128 On completion, continue to state 4.
129 If we did chroot in state 2, each
131 process will be run in the same
133 path as in 2 (that is, the value of
135 sysctl is not re-read).
137 Multi-user operation.
138 Depending upon the signal received, change state appropriately;
149 Clean-up mode; re-read
151 killing off the controlling processes on lines that are now
153 and starting processes that are newly
155 On completion, go to state 4.
158 mode; no new sessions.
159 Signals as per state 4.
164 to all controlling processes, reap the processes for 30 seconds,
165 and then go to state 1 (single user); warning if not all the processes died.
176 will require that the superuser password be
177 entered before the system will start a single-user shell.
178 The password check is skipped if the
183 It should be noted that while
185 has the ability to start multi-user operation inside a
189 process itself will always run in the
190 .Dq original root directory .
191 This also implies that single-user mode is always started in the original
192 root, giving the possibility to create multi-user sessions in different
193 root directories over time.
196 sysctl node is fabricated by
198 at startup and re-created any time it's found to be missing.
199 Type of the node is string capable of holding full pathname, and
200 is only accessible by the superuser (unless explicitly destroyed
201 and re-created with different specification).
203 In multi-user operation,
206 processes for the terminal ports found in the file
209 reads this file, and executes the command found in the second field.
210 This command is usually
212 it opens and initializes the tty line and executes the
217 program, when a valid user logs in, executes a shell for that user.
218 When this shell dies, either because the user logged out or an
219 abnormal termination occurred (a signal), the
221 program wakes up, deletes the user from the
225 files of current users and records the logout in the
237 Line status (on, off, secure, getty, or window information)
238 may be changed in the
240 file without a reboot by sending the signal
245 .Dq Li "kill \-s HUP 1" .
246 This is referenced in the table above as state 5.
247 On receipt of this signal,
252 When a line is turned off in
257 signal to the controlling process
258 for the session associated with the line.
259 For any lines that were previously turned off in the
265 to enable a new login.
266 If the getty or window field for a line is changed,
267 the change takes effect at the end of the current
268 login session (e.g., the next time
270 starts a process on the line).
271 If a line is commented out or deleted from
274 will not do anything at all to that line.
275 However, it will complain that the relationship between lines
278 file and records in the
281 so this practice is not recommended.
284 will terminate multi-user operations and resume single-user mode
288 .Dq Li "kill \-s TERM 1" .
289 If there are processes outstanding that are deadlocked (because of
290 hardware or software failure),
292 will not wait for them all to die (which might take forever), but
293 will time out after 30 seconds and print a warning message.
296 will cease creating new
298 and allow the system to slowly die away, if it is sent a terminal stop
301 .Dq Li "kill \-s TSTP 1" .
302 A later hangup will resume full
303 multi-user operations, or a terminate will start a single user shell.
311 is so critical that if it dies, the system will reboot itself
313 If, at bootstrap time, the
315 process cannot be located, or exits during its initialisation,
316 the system will panic with the message
317 .Dq panic: init died (signal %d, exit %d) .
326 .Dq Li "MAKEDEV -MM init" .
332 to create a memory file system mounted over
334 that contains the standard devices considered necessary to boot the system.
336 .Bl -tag -width /var/log/wtmp{,x} -compact
338 System console device.
340 Terminal ports found in
342 .It Pa /var/run/utmp{,x}
343 Record of current users on the system.
344 .It Pa /var/log/wtmp{,x}
345 Record of all logins and logouts.
347 The terminal initialization information file.
349 System startup commands.
353 .It "getty repeating too quickly on port %s, sleeping"
354 A process being started to service a line is exiting quickly
355 each time it is started.
356 This is often caused by a ringing or noisy terminal line.
357 .Em "Init will sleep for 10 seconds" ,
358 .Em "then continue trying to start the process" .
360 .It "some processes would not die; ps axl advised."
361 A process is hung and could not be killed when the system was
363 This condition is usually caused by a process that is stuck in a
364 device driver because of a persistent device error condition.
376 .Xr MAKEDEV.local 8 ,
384 .Xr secmodel_bsd44 9 ,
385 .Xr secmodel_securelevel 9