SIMPLEINIT(8) Linux System Administrator's Manual SIMPLEINIT(8)
NAME
simpleinit, init - process control initialization
SYNOPSIS
init [ boot_program ] [ boot_program_args ]
DESCRIPTION
init is usually invoked by the kernel as the last step in(1,8) the Linux
boot sequence. It is also possible to start an instance of init manu-
ally in(1,8) user space which is useful for debugging boot scripts and init
itself (see USER SPACE EXECUTION below). Init is responsible for
starting the boot script(s) that initialize the system and start a
variety of services (e.g. HTTP daemon). It is also responsible for
starting getty(8)s or similar processes that allow users(1,5) to log in.
Init's behaviour is controlled through the file(1,n) /etc/inittab (see init-
tab(8)).
Init begins its work by starting a boot program, usually a shell
script, that would normally use initctl(8) to start services. By
default, the boot program is /etc/rc but it may be overridden by
putting a bootprog entry into inittab which in(1,8) turn is overridden if(3,n) a
boot_program parameter is passed to init on the command line. To pass
arguments to the instance of init started by the kernel, pass the argu-
ments to the kernel via your boot loader. Arguments not recognized by
the kernel are passed on to init.
The boot program will always get 'start' passed as its 1st argument.
Further arguments to pass it can be appended to the bootprog line in(1,8)
inittab or passed to init as boot_program_args. Note that you may
leave out the boot_program argument if(3,n) none of the boot_program_args
coincides with the name of an executeable in(1,8) the directory specified
through fileprefix in(1,8) inittab. The boot program will not be overridden
but any default arguments from inittab are. This is useful for instance
to tell your boot program to boot a certain runlevel different from the
default.
Note that the argument single that causes other versions of init to
boot into a special single user mode is not treated specially by this
version. You may either create a boot program called single and place
it into the fileprefix directory, or you could make your default boot
program recognize single as an argument to achieve whatever behaviour
you want.
Once the boot program has finished its work, init writes a boot time(1,2,n)
record to wtmp(5), cleans up /var/run/utmp (see utmp(5) ) and then
spawns processes (usually getty(8)s ) as specified in(1,8) /etc/inittab. As
last step it will run the finalprog program specified in(1,8) inittab with
the argument 'start'.
USER SPACE EXECUTION
While normally init is started by the kernel, you can manually start
init as a normal user. In that case, init will interpret all file(1,n) loca-
tions that can not be configured in(1,8) inittab (like the location of init-
tab itself) relative to the environment variable INIT_ROOT. If
INIT_ROOT is not set(7,n,1 builtins), init will set(7,n,1 builtins) it to the current working directory
and export it to the programs it executes. File locations that can be
configured in(1,8) inittab will be kept unchanged with the exception of
fileprefix which will be prefixed with the value of INIT_ROOT.
The above preparations make it possible to test init itself and the
boot scripts, without changing the main installation. A user space
init will not spawn getty(8)s and will never call reboot(2) when it is
sent a SIGINT signal(2,7) (it may call reboot(8) if(3,n) the ctrlaltdel entry in(1,8)
inittab tells it to). The signals SIGTSTP, SIGTERM and SIGQUIT will
terminate the program. You should make sure that at least
$INIT_ROOT/dev/ and $INIT_ROOT/etc/inittab exist when starting a user
space init. The former is needed to create a FIFO for initctl(8) and
for creating a file(1,n) $INIT_ROOT/dev/init.pid to store the pid of the
user space init. A user space init will set(7,n,1 builtins) the USERSPACE_INIT envi-
ronment variable to identify itself. This can be used in(1,8) boot scripts
to take special precautions.
SIGNALS
simpleinit(8) responds to signals in(1,8) a variety of ways:
SIGHUP The /etc/inittab configuration file(1,n) will be read(2,n,1 builtins) again.
SIGTSTP
This flips a toggle, which controls whether more processes will
be spawned. Tip: You can have the boot program you use for sin-
gle user mode send(2,n) SIGTSTP to init to prevent spawning of get-
tys, execution of finalprog and writing of utmp/wtmp.
SIGTERM
Kills the (getty (8)) processes that have been spawned by init.
SIGINT Under Linux, it is possible to configure the Ctrl-Alt-Del
sequence to send(2,n) this signal(2,7) to the init process instead of
rebooting the system and simpleinit(8) makes use of this feature
by default. If /etc/inittab does not specify a ctrlaltdel pro-
gram simpleinit(8) will sync(1,2,8)(2) a few times, and try to start
reboot(8). Failing this, it will execute the reboot(2) system
call. You can override this behaviour by specifying a ctrlalt-
del program in(1,8) /etc/inittab. This program will be executed
instead of reboot(8). Specifying this program will also disable
the fallback to reboot(2). Because the latter does not shut down
the system properly which may cause data loss, it is advisable
to always specify a ctrlaltdel program.
SIGQUIT
The shutdown(2,8)(8) program is executed to replace simpleinit(8) in(1,8)
memory. This allows shutdown(2,8)(8) to cleanly remount (read-only)
the root filesystem, even if(3,n) the old inode for the init process
was unlinked.
FILES
/etc/inittab
/etc/TZ
/etc/rc
/dev/initctl
$INIT_ROOT/dev/initctl
$INIT_ROOT/dev/init.pid
/var/run/utmp
/var/log/wtmp
NOTES
This manual page documents simpleinit-msb which has been forked off
simpleinit as found in(1,8) the util-linux package. It supports the same
basic features, most notably dependency management, but adds some addi-
tional functionality such as user space execution. Other functionality
that I found obscure such as running boot scripts in(1,8) parallel has been
removed.
The program is called simpleinit to distinguish it from the System V
compatible versions of init. simpleinit should be linked to, or made
identical with, init for correct functionality.
The finalprog program is executed without stdout/stdin/stderr. This
means that unless it opens them itself it can not do output or input.
However, doing console(4,n) I/O in(1,8) finalprog would be a bad idea anyway,
because finalprog is started after the getty processes and would clut-
ter the login(1,3,5) prompt.
See initctl(8) for more issues.
AUTHOR
Peter Orbaek (poe@daimi.aau.dk)
Version 1.20, with patches for singleuser mode by Werner Almesberger
Richard Gooch <rgooch@atnf.csiro.au>
Dependency support
Matthias Benkmann <m.s.b@gmx.net>
Numerous changes, see comments in(1,8) source code
This version(1,3,5) is currently maintained by Matthias Benkmann
<m.s.b@gmx.net> and all comments, questions and bug reports regarding
this version(1,3,5) should be directed to me. Do not bother the original
authors.
Turn to http://www.winterdrache.de/linux/index.html
for updates.
SEE ALSO
initctl(8), inittab(5), telinit(8), shutdown(2,8)(8), ctrlaltdel(8)
reboot(8), getty(8), agetty(8), need(8), display-services(8), utmp(5),
provide(8), reboot(3), termcap(5)
8 September 2001 SIMPLEINIT(8)