xref: /minix3/sbin/init/init.8 (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc.\"	$NetBSD: init.8,v 1.59 2013/10/02 22:07:56 apb Exp $
2a06e2ab3SBen Gras.\"
3a06e2ab3SBen Gras.\" Copyright (c) 1980, 1991, 1993
4a06e2ab3SBen Gras.\"	The Regents of the University of California.  All rights reserved.
5a06e2ab3SBen Gras.\"
6a06e2ab3SBen Gras.\" This code is derived from software contributed to Berkeley by
7a06e2ab3SBen Gras.\" Donn Seeley at Berkeley Software Design, Inc.
8a06e2ab3SBen Gras.\"
9a06e2ab3SBen Gras.\" Redistribution and use in source and binary forms, with or without
10a06e2ab3SBen Gras.\" modification, are permitted provided that the following conditions
11a06e2ab3SBen Gras.\" are met:
12a06e2ab3SBen Gras.\" 1. Redistributions of source code must retain the above copyright
13a06e2ab3SBen Gras.\"    notice, this list of conditions and the following disclaimer.
14a06e2ab3SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
15a06e2ab3SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
16a06e2ab3SBen Gras.\"    documentation and/or other materials provided with the distribution.
17a06e2ab3SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
18a06e2ab3SBen Gras.\"    may be used to endorse or promote products derived from this software
19a06e2ab3SBen Gras.\"    without specific prior written permission.
20a06e2ab3SBen Gras.\"
21a06e2ab3SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22a06e2ab3SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23a06e2ab3SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24a06e2ab3SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25a06e2ab3SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26a06e2ab3SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27a06e2ab3SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28a06e2ab3SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29a06e2ab3SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30a06e2ab3SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31a06e2ab3SBen Gras.\" SUCH DAMAGE.
32a06e2ab3SBen Gras.\"
33a06e2ab3SBen Gras.\"     @(#)init.8	8.6 (Berkeley) 5/26/95
34a06e2ab3SBen Gras.\"
35*84d9c625SLionel Sambuc.Dd October 2, 2013
36a06e2ab3SBen Gras.Dt INIT 8
37a06e2ab3SBen Gras.Os
38a06e2ab3SBen Gras.Sh NAME
39a06e2ab3SBen Gras.Nm init
40a06e2ab3SBen Gras.Nd process control initialization
41a06e2ab3SBen Gras.Sh SYNOPSIS
42a06e2ab3SBen Gras.Nm
43*84d9c625SLionel Sambuc.Op Fl s
44a06e2ab3SBen Gras.Sh DESCRIPTION
45a06e2ab3SBen GrasThe
46a06e2ab3SBen Gras.Nm
47*84d9c625SLionel Sambucprogram is the last stage of the boot process.
48a06e2ab3SBen GrasIt normally begins multi-user operation.
49a06e2ab3SBen Gras.Pp
50*84d9c625SLionel Sambuc.Nm
51*84d9c625SLionel Sambucis executed automatically by the kernel,
52*84d9c625SLionel Sambucafter the kernel has initialised all devices
53*84d9c625SLionel Sambucand mounted the root file system.
54*84d9c625SLionel SambucThe kernel may try multiple possible paths for
55*84d9c625SLionel Sambuc.Nm ,
56*84d9c625SLionel Sambucincluding
57*84d9c625SLionel Sambuc.Pa /sbin/init ,
58*84d9c625SLionel Sambuc.Pa /sbin/oinit ,
59*84d9c625SLionel Sambuc.Pa /sbin/init.bak ,
60*84d9c625SLionel Sambucand
61*84d9c625SLionel Sambuc.Pa /rescue/init .
62*84d9c625SLionel Sambuc.Pp
63a06e2ab3SBen GrasThe following table describes the state machine used by
64a06e2ab3SBen Gras.Nm :
65a06e2ab3SBen Gras.Bl -enum
66a06e2ab3SBen Gras.It
67a06e2ab3SBen GrasSingle user shell.
68*84d9c625SLionel SambucIf the kernel is booted in single user mode (see
69*84d9c625SLionel Sambuc.Xr boothowto 9 ) ,
70*84d9c625SLionel Sambucthen the kernel will pass the
71a06e2ab3SBen Gras.Fl s
72*84d9c625SLionel Sambucoption to
73*84d9c625SLionel Sambuc.Nm
74*84d9c625SLionel Sambucto prevent the system from going multi-user and
75a06e2ab3SBen Grasto instead execute a single user shell without starting the normal
76a06e2ab3SBen Grasdaemons.
77a06e2ab3SBen GrasIf the kernel is in a secure mode,
78a06e2ab3SBen Gras.Nm
79a06e2ab3SBen Graswill downgrade it to securelevel 0 (insecure mode).
80a06e2ab3SBen GrasThe system is then quiescent for maintenance work and may
81a06e2ab3SBen Graslater be made to go to state 2 (multi-user) by exiting the single-user
82a06e2ab3SBen Grasshell (with ^D).
83a06e2ab3SBen Gras.It
84a06e2ab3SBen GrasMulti-user boot (default operation).
85a06e2ab3SBen GrasExecutes
86a06e2ab3SBen Gras.Pa /etc/rc
87a06e2ab3SBen Gras(see
88a06e2ab3SBen Gras.Xr rc 8 ) .
89a06e2ab3SBen GrasIf this was the first state entered (as opposed to entering here after
90a06e2ab3SBen Grasstate 1), then
91a06e2ab3SBen Gras.Pa /etc/rc
92a06e2ab3SBen Graswill be invoked with its first argument being
93a06e2ab3SBen Gras.Sq autoboot .
94a06e2ab3SBen GrasIf
95a06e2ab3SBen Gras.Pa /etc/rc
96a06e2ab3SBen Grasexits with a non-zero (error) exit code, commence single user
97a06e2ab3SBen Grasoperation by giving the super-user a shell on the console by going
98a06e2ab3SBen Grasto state 1 (single user).
99a06e2ab3SBen GrasOtherwise, proceed to state 3.
100a06e2ab3SBen Gras.Pp
101a06e2ab3SBen GrasIf value of the
102a06e2ab3SBen Gras.Dq init.root
103a06e2ab3SBen Grassysctl node is not equal to
104a06e2ab3SBen Gras.Pa /
105a06e2ab3SBen Grasat this point, the
106a06e2ab3SBen Gras.Pa /etc/rc
107a06e2ab3SBen Grasprocess will be run inside a
108a06e2ab3SBen Gras.Xr chroot 2
109a06e2ab3SBen Grasindicated by sysctl with the same error handling as above.
110a06e2ab3SBen Gras.Pp
111a06e2ab3SBen GrasIf the administrator has not set the security level to \-1
112a06e2ab3SBen Grasto indicate that the kernel should not run multiuser in secure
113a06e2ab3SBen Grasmode, and the
114a06e2ab3SBen Gras.Pa /etc/rc
115a06e2ab3SBen Grasscript has not set a higher level of security
116a06e2ab3SBen Grasthan level 1, then
117a06e2ab3SBen Gras.Nm
118a06e2ab3SBen Graswill put the kernel into securelevel mode 1.
119a06e2ab3SBen GrasSee
120a06e2ab3SBen Gras.Xr rc.conf 5
121a06e2ab3SBen Grasand
122a06e2ab3SBen Gras.Xr secmodel_securelevel 9
123a06e2ab3SBen Grasfor more information.
124a06e2ab3SBen Gras.It
125a06e2ab3SBen GrasSet up ttys as specified in
126a06e2ab3SBen Gras.Xr ttys 5 .
127a06e2ab3SBen GrasSee below for more information.
128a06e2ab3SBen GrasOn completion, continue to state 4.
129a06e2ab3SBen GrasIf we did chroot in state 2, each
130a06e2ab3SBen Gras.Xr getty 8
131a06e2ab3SBen Grasprocess will be run in the same
132a06e2ab3SBen Gras.Xr chroot 2
133a06e2ab3SBen Graspath as in 2 (that is, the value of
134a06e2ab3SBen Gras.Dq init.root
135a06e2ab3SBen Grassysctl is not re-read).
136a06e2ab3SBen Gras.It
137a06e2ab3SBen GrasMulti-user operation.
138a06e2ab3SBen GrasDepending upon the signal received, change state appropriately;
139a06e2ab3SBen Grason
140a06e2ab3SBen Gras.Dv SIGTERM ,
141a06e2ab3SBen Grasgo to state 7;
142a06e2ab3SBen Grason
143a06e2ab3SBen Gras.Dv SIGHUP ,
144a06e2ab3SBen Grasgo to state 5;
145a06e2ab3SBen Grason
146a06e2ab3SBen Gras.Dv SIGTSTP ,
147a06e2ab3SBen Grasgo to state 6.
148a06e2ab3SBen Gras.It
149a06e2ab3SBen GrasClean-up mode; re-read
150a06e2ab3SBen Gras.Xr ttys 5 ,
151a06e2ab3SBen Graskilling off the controlling processes on lines that are now
152a06e2ab3SBen Gras.Sq off ,
153a06e2ab3SBen Grasand starting processes that are newly
154a06e2ab3SBen Gras.Sq on .
155a06e2ab3SBen GrasOn completion, go to state 4.
156a06e2ab3SBen Gras.It
157a06e2ab3SBen Gras.Sq Boring
158a06e2ab3SBen Grasmode; no new sessions.
159a06e2ab3SBen GrasSignals as per state 4.
160a06e2ab3SBen Gras.It
161a06e2ab3SBen GrasShutdown mode.
162a06e2ab3SBen GrasSend
163a06e2ab3SBen Gras.Dv SIGHUP
164a06e2ab3SBen Grasto all controlling processes, reap the processes for 30 seconds,
165a06e2ab3SBen Grasand then go to state 1 (single user); warning if not all the processes died.
166a06e2ab3SBen Gras.El
167a06e2ab3SBen Gras.Pp
168a06e2ab3SBen GrasIf the
169a06e2ab3SBen Gras.Sq console
170a06e2ab3SBen Grasentry in the
171a06e2ab3SBen Gras.Xr ttys 5
172a06e2ab3SBen Grasfile is marked
173a06e2ab3SBen Gras.Dq insecure ,
174a06e2ab3SBen Grasthen
175a06e2ab3SBen Gras.Nm
176a06e2ab3SBen Graswill require that the superuser password be
177a06e2ab3SBen Grasentered before the system will start a single-user shell.
178a06e2ab3SBen GrasThe password check is skipped if the
179a06e2ab3SBen Gras.Sq console
180a06e2ab3SBen Grasis marked as
181a06e2ab3SBen Gras.Dq secure .
182a06e2ab3SBen Gras.Pp
183a06e2ab3SBen GrasIt should be noted that while
184a06e2ab3SBen Gras.Nm
185a06e2ab3SBen Grashas the ability to start multi-user operation inside a
186a06e2ab3SBen Gras.Xr chroot 2
187a06e2ab3SBen Grasenvironment, the
188a06e2ab3SBen Gras.Nm
189a06e2ab3SBen Grasprocess itself will always run in the
190a06e2ab3SBen Gras.Dq original root directory .
191a06e2ab3SBen GrasThis also implies that single-user mode is always started in the original
192a06e2ab3SBen Grasroot, giving the possibility to create multi-user sessions in different
193a06e2ab3SBen Grasroot directories over time.
194a06e2ab3SBen GrasThe
195a06e2ab3SBen Gras.Dq init.root
196a06e2ab3SBen Grassysctl node is fabricated by
197a06e2ab3SBen Gras.Nm
198a06e2ab3SBen Grasat startup and re-created any time it's found to be missing.
199a06e2ab3SBen GrasType of the node is string capable of holding full pathname, and
200a06e2ab3SBen Grasis only accessible by the superuser (unless explicitly destroyed
201a06e2ab3SBen Grasand re-created with different specification).
202a06e2ab3SBen Gras.Pp
203a06e2ab3SBen GrasIn multi-user operation,
204a06e2ab3SBen Gras.Nm
205a06e2ab3SBen Grasmaintains
206a06e2ab3SBen Grasprocesses for the terminal ports found in the file
207a06e2ab3SBen Gras.Xr ttys 5 .
208a06e2ab3SBen Gras.Nm
209a06e2ab3SBen Grasreads this file, and executes the command found in the second field.
210a06e2ab3SBen GrasThis command is usually
211a06e2ab3SBen Gras.Xr getty 8 ;
212a06e2ab3SBen Grasit opens and initializes the tty line and executes the
213a06e2ab3SBen Gras.Xr login 1
214a06e2ab3SBen Grasprogram.
215a06e2ab3SBen GrasThe
216a06e2ab3SBen Gras.Xr login 1
217a06e2ab3SBen Grasprogram, when a valid user logs in, executes a shell for that user.
218a06e2ab3SBen GrasWhen this shell dies, either because the user logged out or an
219a06e2ab3SBen Grasabnormal termination occurred (a signal), the
220a06e2ab3SBen Gras.Nm
221a06e2ab3SBen Grasprogram wakes up, deletes the user from the
222a06e2ab3SBen Gras.Xr utmp 5
223a06e2ab3SBen Grasand
224a06e2ab3SBen Gras.Xr utmpx 5
225a06e2ab3SBen Grasfiles of current users and records the logout in the
226a06e2ab3SBen Gras.Xr wtmp 5
227a06e2ab3SBen Grasand
228a06e2ab3SBen Gras.Xr wtmpx 5
229a06e2ab3SBen Grasfiles.
230a06e2ab3SBen GrasThe cycle is
231a06e2ab3SBen Grasthen restarted by
232a06e2ab3SBen Gras.Nm
233a06e2ab3SBen Grasexecuting a new
234a06e2ab3SBen Gras.Xr getty 8
235a06e2ab3SBen Grasfor the line.
236a06e2ab3SBen Gras.Pp
237a06e2ab3SBen GrasLine status (on, off, secure, getty, or window information)
238a06e2ab3SBen Grasmay be changed in the
239a06e2ab3SBen Gras.Xr ttys 5
240a06e2ab3SBen Grasfile without a reboot by sending the signal
241a06e2ab3SBen Gras.Dv SIGHUP
242a06e2ab3SBen Grasto
243a06e2ab3SBen Gras.Nm
244a06e2ab3SBen Graswith the command
245a06e2ab3SBen Gras.Dq Li "kill \-s HUP 1" .
246a06e2ab3SBen GrasThis is referenced in the table above as state 5.
247a06e2ab3SBen GrasOn receipt of this signal,
248a06e2ab3SBen Gras.Nm
249a06e2ab3SBen Grasre-reads the
250a06e2ab3SBen Gras.Xr ttys 5
251a06e2ab3SBen Grasfile.
252a06e2ab3SBen GrasWhen a line is turned off in
253a06e2ab3SBen Gras.Xr ttys 5 ,
254a06e2ab3SBen Gras.Nm
255a06e2ab3SBen Graswill send a
256a06e2ab3SBen Gras.Dv SIGHUP
257a06e2ab3SBen Grassignal to the controlling process
258a06e2ab3SBen Grasfor the session associated with the line.
259a06e2ab3SBen GrasFor any lines that were previously turned off in the
260a06e2ab3SBen Gras.Xr ttys 5
261a06e2ab3SBen Grasfile and are now on,
262a06e2ab3SBen Gras.Nm
263a06e2ab3SBen Grasexecutes a new
264a06e2ab3SBen Gras.Xr getty 8
265a06e2ab3SBen Grasto enable a new login.
266a06e2ab3SBen GrasIf the getty or window field for a line is changed,
267a06e2ab3SBen Grasthe change takes effect at the end of the current
268a06e2ab3SBen Graslogin session (e.g., the next time
269a06e2ab3SBen Gras.Nm
270a06e2ab3SBen Grasstarts a process on the line).
271a06e2ab3SBen GrasIf a line is commented out or deleted from
272a06e2ab3SBen Gras.Xr ttys 5 ,
273a06e2ab3SBen Gras.Nm
274a06e2ab3SBen Graswill not do anything at all to that line.
275a06e2ab3SBen GrasHowever, it will complain that the relationship between lines
276a06e2ab3SBen Grasin the
277a06e2ab3SBen Gras.Xr ttys 5
278a06e2ab3SBen Grasfile and records in the
279a06e2ab3SBen Gras.Xr utmp 5
280a06e2ab3SBen Grasfile is out of sync,
281a06e2ab3SBen Grasso this practice is not recommended.
282a06e2ab3SBen Gras.Pp
283a06e2ab3SBen Gras.Nm
284a06e2ab3SBen Graswill terminate multi-user operations and resume single-user mode
285a06e2ab3SBen Grasif sent a terminate
286a06e2ab3SBen Gras.Pq Dv TERM
287a06e2ab3SBen Grassignal, for example,
288a06e2ab3SBen Gras.Dq Li "kill \-s TERM 1" .
289a06e2ab3SBen GrasIf there are processes outstanding that are deadlocked (because of
290a06e2ab3SBen Grashardware or software failure),
291a06e2ab3SBen Gras.Nm
292a06e2ab3SBen Graswill not wait for them all to die (which might take forever), but
293a06e2ab3SBen Graswill time out after 30 seconds and print a warning message.
294a06e2ab3SBen Gras.Pp
295a06e2ab3SBen Gras.Nm
296a06e2ab3SBen Graswill cease creating new
297a06e2ab3SBen Gras.Xr getty 8 Ns 's
298a06e2ab3SBen Grasand allow the system to slowly die away, if it is sent a terminal stop
299a06e2ab3SBen Gras.Pq Dv TSTP
300a06e2ab3SBen Grassignal, i.e.
301a06e2ab3SBen Gras.Dq Li "kill \-s TSTP 1" .
302a06e2ab3SBen GrasA later hangup will resume full
303a06e2ab3SBen Grasmulti-user operations, or a terminate will start a single user shell.
304a06e2ab3SBen GrasThis hook is used by
305a06e2ab3SBen Gras.Xr reboot 8
306a06e2ab3SBen Grasand
307a06e2ab3SBen Gras.Xr halt 8 .
308a06e2ab3SBen Gras.Pp
309a06e2ab3SBen GrasThe role of
310a06e2ab3SBen Gras.Nm
311a06e2ab3SBen Grasis so critical that if it dies, the system will reboot itself
312a06e2ab3SBen Grasautomatically.
313a06e2ab3SBen GrasIf, at bootstrap time, the
314a06e2ab3SBen Gras.Nm
315a06e2ab3SBen Grasprocess cannot be located, or exits during its initialisation,
316a06e2ab3SBen Grasthe system will panic with the message
317a06e2ab3SBen Gras.Dq panic: init died (signal %d, exit %d) .
318a06e2ab3SBen Gras.Pp
319a06e2ab3SBen GrasIf
320a06e2ab3SBen Gras.Pa /dev/console
321a06e2ab3SBen Grasdoes not exist,
322a06e2ab3SBen Gras.Nm
323a06e2ab3SBen Graswill cd to
324a06e2ab3SBen Gras.Pa /dev
325a06e2ab3SBen Grasand run
326a06e2ab3SBen Gras.Dq Li "MAKEDEV -MM init" .
327a06e2ab3SBen Gras.Xr MAKEDEV 8
328a06e2ab3SBen Graswill use
329a06e2ab3SBen Gras.Xr mount_tmpfs 8
330a06e2ab3SBen Grasor
331a06e2ab3SBen Gras.Xr mount_mfs 8
332a06e2ab3SBen Grasto create a memory file system mounted over
333a06e2ab3SBen Gras.Pa /dev
334a06e2ab3SBen Grasthat contains the standard devices considered necessary to boot the system.
335a06e2ab3SBen Gras.Sh FILES
336a06e2ab3SBen Gras.Bl -tag -width /var/log/wtmp{,x} -compact
337a06e2ab3SBen Gras.It Pa /dev/console
338a06e2ab3SBen GrasSystem console device.
339a06e2ab3SBen Gras.It Pa /dev/tty*
340a06e2ab3SBen GrasTerminal ports found in
341a06e2ab3SBen Gras.Xr ttys 5 .
342a06e2ab3SBen Gras.It Pa /var/run/utmp{,x}
343a06e2ab3SBen GrasRecord of current users on the system.
344a06e2ab3SBen Gras.It Pa /var/log/wtmp{,x}
345a06e2ab3SBen GrasRecord of all logins and logouts.
346a06e2ab3SBen Gras.It Pa /etc/ttys
347a06e2ab3SBen GrasThe terminal initialization information file.
348a06e2ab3SBen Gras.It Pa /etc/rc
349a06e2ab3SBen GrasSystem startup commands.
350a06e2ab3SBen Gras.El
351a06e2ab3SBen Gras.Sh DIAGNOSTICS
352a06e2ab3SBen Gras.Bl -diag
353a06e2ab3SBen Gras.It "getty repeating too quickly on port %s, sleeping"
354a06e2ab3SBen GrasA process being started to service a line is exiting quickly
355a06e2ab3SBen Graseach time it is started.
356a06e2ab3SBen GrasThis is often caused by a ringing or noisy terminal line.
357a06e2ab3SBen Gras.Em "Init will sleep for 10 seconds" ,
358a06e2ab3SBen Gras.Em "then continue trying to start the process" .
359a06e2ab3SBen Gras.Pp
360a06e2ab3SBen Gras.It "some processes would not die; ps axl advised."
361a06e2ab3SBen GrasA process is hung and could not be killed when the system was
362a06e2ab3SBen Grasshutting down.
363a06e2ab3SBen GrasThis condition is usually caused by a process that is stuck in a
364a06e2ab3SBen Grasdevice driver because of a persistent device error condition.
365a06e2ab3SBen Gras.El
366a06e2ab3SBen Gras.Sh SEE ALSO
367a06e2ab3SBen Gras.Xr config 1 ,
368a06e2ab3SBen Gras.Xr kill 1 ,
369a06e2ab3SBen Gras.Xr login 1 ,
370a06e2ab3SBen Gras.Xr sh 1 ,
371a06e2ab3SBen Gras.Xr options 4 ,
372a06e2ab3SBen Gras.Xr ttys 5 ,
373a06e2ab3SBen Gras.Xr getty 8 ,
374a06e2ab3SBen Gras.Xr halt 8 ,
375a06e2ab3SBen Gras.Xr MAKEDEV 8 ,
376a06e2ab3SBen Gras.Xr MAKEDEV.local 8 ,
377a06e2ab3SBen Gras.Xr mount_mfs 8 ,
378a06e2ab3SBen Gras.Xr mount_tmpfs 8 ,
379a06e2ab3SBen Gras.Xr rc 8 ,
380a06e2ab3SBen Gras.Xr reboot 8 ,
381a06e2ab3SBen Gras.Xr rescue 8 ,
382a06e2ab3SBen Gras.Xr shutdown 8 ,
383a06e2ab3SBen Gras.Xr sysctl 8 ,
384a06e2ab3SBen Gras.Xr secmodel_bsd44 9 ,
385a06e2ab3SBen Gras.Xr secmodel_securelevel 9
386a06e2ab3SBen Gras.Sh HISTORY
387a06e2ab3SBen GrasA
388a06e2ab3SBen Gras.Nm
389a06e2ab3SBen Grascommand appeared in
390a06e2ab3SBen Gras.At v6 .
391