Init: Difference between revisions
m Disambiguated: Gentoo → Gentoo Linux |
m fix link |
||
Line 101: | Line 101: | ||
* s6, another [[cross-platform]] full replacement for init, similar to runit<ref>{{cite web|url=http://skarnet.org/software/s6/ | title=s6 - skarnet's small supervision suite}}</ref> |
* s6, another [[cross-platform]] full replacement for init, similar to runit<ref>{{cite web|url=http://skarnet.org/software/s6/ | title=s6 - skarnet's small supervision suite}}</ref> |
||
* [[Service Management Facility]], a complete full replacement/redesign of init from the ground up in [[Solaris Operating System|Solaris]] starting with Solaris 10 |
* [[Service Management Facility]], a complete full replacement/redesign of init from the ground up in [[Solaris Operating System|Solaris]] starting with Solaris 10 |
||
* [[systemd]], a full replacement for init with parallel starting of services and other features, used by [[Systemd# |
* [[systemd]], a full replacement for init with parallel starting of services and other features, used by [[Systemd#Adoption_and_reception|many distributions]]. |
||
* [[SystemStarter]], a process spawner started by the BSD-style init in [[Mac OS X]] prior to [[Mac OS X v10.4]] |
* [[SystemStarter]], a process spawner started by the BSD-style init in [[Mac OS X]] prior to [[Mac OS X v10.4]] |
||
* [[Upstart]], a full replacement of init designed to start processes [[asynchronous]]ly initiated by [[Ubuntu (operating system)|Ubuntu]]. |
* [[Upstart]], a full replacement of init designed to start processes [[asynchronous]]ly initiated by [[Ubuntu (operating system)|Ubuntu]]. |
Revision as of 13:18, 3 February 2015
In Unix-based computer operating systems, init (short for initialization) is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes. Init is started by the kernel using a hard-coded filename; a kernel panic will occur if the kernel is unable to start it. Init is typically assigned process identifier 1.
The design of init has diverged in Unix systems such as System III and System V, from the functionality provided by the init in Research Unix and its BSD derivatives. The usage on most Linux distributions is somewhat compatible with System V, but some distributions, such as Slackware, use a BSD-style and others, such as Gentoo, have their own customized version.
Several replacement init implementations have been written with attempt to address design limitations in the standard versions. These include launchd, the Service Management Facility, systemd and Upstart, the latter being used by Ubuntu[1][2] and some other Linux distributions.[3][4]
Research Unix-style/BSD-style
Research Unix init ran the initialization shell script located in /etc/rc
,[5] then launched getty on terminals under the control of /etc/ttys
.[6] There are no runlevels; the /etc/rc
file determines what programs are run by init. The advantage of this system is that it is simple and easy to edit manually. However, new software added to the system may require changes to existing files that risk producing an unbootable system.
BSD init was, prior to 4.3BSD, the same as Research UNIX's init;[7][8] in 4.3BSD, it added support for running a windowing system such as X on graphical terminals under the control of /etc/ttys
.[9][10] To remove the requirement to edit /etc/rc
, BSD variants have long supported a site-specific /etc/rc.local
file that is run in a sub-shell near the end of the boot sequence.
A fully modular system was introduced with NetBSD 1.5 and ported to FreeBSD 5.0 and successors. This system executes scripts in the /etc/rc.d
directory. Unlike System V's script ordering, which is derived from the filename of each script, this system uses explicit dependency tags placed within each script.[11] The order in which scripts are executed is determined by the rcorder script based on the requirements stated in these tags.
SysV-style
When compared to its predecessors, AT&T's UNIX System III introduced a new style of system startup configuration,[citation needed] which survived (with modifications) into UNIX System V and is therefore called the "SysV-style init". At any moment, a running System V is in one of the predetermined number of states, called runlevels. At least one runlevel is the normal operating state of the system; typically, other runlevels represent single-user mode (used for repairing a faulty system), system shutdown, and various other states. Switching from one runlevel to another causes a per-runlevel set of scripts to be run, which typically mount filesystems, start or stop daemons, start or stop the X Window System, shutdown the machine, etc.
Runlevels
The runlevels in System V describe certain states of a machine, characterized by the processes run. There are generally eight runlevels, three of which are "standard":[clarification needed]
- 0. Halt
- 1. Single user mode (aka. S or s)
- 6. Reboot
Aside from these, every Unix and Unix-like system treats runlevels a little differently. The common denominator, the /etc/inittab
file, defines what each runlevel does (if they do anything at all) in a given system.
Default runlevels
Operating system | Default runlevel |
---|---|
AIX | 2 |
CentOS | 3 (console/server) or 5 (graphical/desktop)[12] |
Debian | 2[13] |
Gentoo Linux | 3[14] |
HP-UX | 3 (console/server/multiuser) or 4 (graphical) |
Mac OS X | 3 |
Mandriva Linux | 3 (console/server) or 5 (graphical/desktop) |
Red Hat Enterprise Linux / Fedora | 3 (console/server) or 5 (graphical/desktop)[12] |
Slackware Linux | 3 |
Solaris | 3[15] |
SUSE Linux Enterprise/openSUSE Linux | 3 (console/server) or 5 (graphical/desktop)[16] |
Ubuntu (Server and Desktop) | 2[13] |
On Linux distributions defaulting to runlevel 5 in the table on the right, runlevel 5 invokes a multiuser graphical environment running the X Window System, usually with a display manager like GDM or KDM. However, the Solaris operating system typically reserves runlevel 5 to shut down and automatically power off the machine.
On most systems users can check the current runlevel with either of the following commands:[17]
$ runlevel
$ who -r
The root typically changes the current runlevel by running the telinit
or init
commands. The /etc/inittab
file sets the default runlevel with the :initdefault:
entry.
On Unix systems, changing the runlevel is achieved by starting only the missing services (as each level defines only those that are started / stopped).[citation needed] For example, changing a system from runlevel 3 to 4 might only start the local X server. Going back to runlevel 3, it would be stopped again.
Replacements for init
Traditionally, one of the major drawbacks of init is that it starts tasks serially, waiting for each to finish loading before moving on to the next. When startup processes end up I/O blocked, this can result in long delays during boot.
Various efforts have been made to replace the traditional init daemons to address this and other design problems, including:
- BootScripts in GoboLinux
- busybox-init, suited embedded operating systems, employed by OpenWrt before it was replaced with procd
- DEMONS, a modification of the init start process by KahelOS, where daemons are started only when the DE (desktop environment) started[citation needed]
- eINIT, a full replacement of init designed to start processes asynchronously, but with the potential of doing it without shell scripts.[18]
- Epoch, a single-threaded Linux init system focused on simplicity and service management[19]
- Initng, a full replacement of init designed to start processes asynchronously
- launchd, a replacement for init introduced in Mac OS X v10.4 (it launches SystemStarter to run old-style 'rc.local' and SystemStarter processes)
- Mudur, an init replacement written in Python and designed to start process asynchronously in use by the Pardus Linux distribution.[20]
- OpenRC, a process spawner that utilizes system-provided init, while providing process isolation, parallelized startup, and service dependency. Used by Gentoo and its derivatives.
- runit, a cross-platform full replacement for init with parallel starting of services
- s6, another cross-platform full replacement for init, similar to runit[21]
- Service Management Facility, a complete full replacement/redesign of init from the ground up in Solaris starting with Solaris 10
- systemd, a full replacement for init with parallel starting of services and other features, used by many distributions.
- SystemStarter, a process spawner started by the BSD-style init in Mac OS X prior to Mac OS X v10.4
- Upstart, a full replacement of init designed to start processes asynchronously initiated by Ubuntu.
References
- ^ "Know Thy Ubuntu". Help.ubuntu.com. 2009-08-07. Retrieved 2011-06-13.
- ^ "since we have no /etc/inittab". Linuxquestions.org. 30 November 2006. Retrieved 2011-06-13.
- ^ "Upstart Plans to Ease Linux Management — Streamlining the init Processes". Reports. LinuxPlanet. 2007-03-08. Retrieved 2011-06-13.
- ^ Remnant, Scott James (2006-08-26). "Upstart in Universe". Netsplit.com. Retrieved 2011-06-13.
- ^ Version 7 Unix Programmer's Manual –
- ^ Version 7 Unix Programmer's Manual –
- ^ 4.2BSD System Manager's Manual –
- ^ 4.2BSD File Formats Manual –
- ^ 4.3BSD System Manager's Manual –
- ^ 4.3BSD File Formats Manual –
- ^ Andrew Smallshaw (7 December 2009). "Unix and Linux startup scripts, Part 2".
- ^ a b "SysV Init Runlevels". Retrieved 22 September 2012.
- ^ a b "Debian and Ubuntu Linux Run Levels". Debianadmin.com. 2009-04-02. Retrieved 2011-06-13.
- ^ "Initscripts". Gentoo Linux Documentation. Gentoo.org. 2011-03-02. Retrieved 2011-06-13.
- ^ "Oracle Documentation". Docs.sun.com. 2010-09-07. Retrieved 2011-06-13.
- ^ "SUSE Documentation: The init Process". suse.com. 2014-04-25. Retrieved 2014-05-04.
- ^ "UNIX man pages : runlevel (8)". Unixhelp.ed.ac.uk. 1997-05-27. Retrieved 2014-07-12.
- ^ "eINIT git repository XML module directory".
- ^ "Epoch Init System Homepage".
- ^ Gürer Özen, Görkem Çetin. "Speeding Up Linux: One Step Further With Pardus Pardus". Pardus.org.tr. Retrieved 2011-06-13.
- ^ "s6 - skarnet's small supervision suite".