Misplaced Pages

Init: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 19:58, 26 May 2015 edit203.161.15.18 (talk) It is more accurate to state "influential" instead of "many"← Previous edit Revision as of 20:05, 27 May 2015 edit undoTim@ (talk | contribs)Extended confirmed users1,504 edits Debian, Fedora, etc now use systemd which don't use runlevels as such.Next edit →
Line 39: Line 39:
| ] | ]
| 2 | 2
|-
| ]
| 3 (console/server) or 5 (graphical/desktop)<ref name=runlevel>{{cite web |title=SysV Init Runlevels |url=http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-sysv.html |accessdate=22 September 2012}}</ref>
|-
| ]
| 2<ref name="drl">{{cite web |url=http://www.debianadmin.com/debian-and-ubuntu-linux-run-levels.html |title=Debian and Ubuntu Linux Run Levels |publisher=Debianadmin.com |date=2009-04-02 |accessdate=2011-06-13}}</ref>
|- |-
| ] | ]
Line 54: Line 48:
| ] | ]
| 3 | 3
|-
| ]
| 3 (console/server) or 5 (graphical/desktop)
|-
| ] / ]
| 3 (console/server) or 5 (graphical/desktop)<ref name=runlevel />
|- |-
| ] | ]
Line 66: Line 54:
| ] | ]
| 3<ref>{{cite web |url=http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5ru |title=Oracle Documentation |publisher=Docs.sun.com |date=2010-09-07 |accessdate=2011-06-13}}</ref> | 3<ref>{{cite web |url=http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5ru |title=Oracle Documentation |publisher=Docs.sun.com |date=2010-09-07 |accessdate=2011-06-13}}</ref>
|-
| ]
| 3 (console/server) or 5 (graphical/desktop)<ref>{{cite web |url=https://www.suse.com/documentation/sles11/book_sle_admin/data/sec_boot_init.html |title=SUSE Documentation: The init Process |publisher=suse.com |date=2014-04-25 |accessdate=2014-05-04}}</ref>
|-
| ]
| 2<ref name="drl" />
|- |-
| ] Releases 3.x, 4.x | ] Releases 3.x, 4.x

Revision as of 20:05, 27 May 2015

This article is about the Unix process. For other uses, see INIT (disambiguation).
Version 7 Unix: /etc listing, showing init and rc
Version 7 Unix: contents of an /etc/rc Bourne shell script

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.

In Unix systems such as System III and System V, the design of init has diverged from the functionality provided by the init in Research Unix and its BSD derivatives. The usage in most Linux distributions employing a traditional init rather than a recent variant such as systemd is somewhat compatible with System V, while some distributions such as Slackware use BSD-style startup scripts, and others such as Gentoo have their own customized versions.

Several replacement init implementations have been created, attempting to address design limitations in the standard versions. These include launchd, the Service Management Facility, systemd and Upstart; as of March 2015, systemd has been adopted by major Linux distributions although it remains controversial.

Research Unix-style/BSD-style

Research Unix init ran the initialization shell script located in /etc/rc, then launched getty on terminals under the control of /etc/ttys. 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; in 4.3BSD, it added support for running a windowing system such as X on graphical terminals under the control of /etc/ttys. 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. 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, 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

Further information: Runlevel

The runlevels in System V describe certain states of a machine, characterized by the processes and daemons running in each of them. In general, there are eight runlevels, out of which three runlevels are considered "standard" as they are essential to the operation of a system:

0. Halt
1. Single user mode (also known as S or s)
6. Reboot

Aside from these standard ones, Unix and Unix-like systems treat runlevels somewhat differently. The common denominator, the /etc/inittab file, defines what each configured runlevel does in a given system.

Default runlevels

Operating system Default runlevel
AIX 2
Gentoo Linux 3
HP-UX 3 (console/server/multiuser) or 4 (graphical)
Mac OS X 3
Slackware Linux 3
Solaris 3
UNIX System V Releases 3.x, 4.x 2
UnixWare 7.x 3

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, all users can check the current runlevel with either the runlevel or who -r command. 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). 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:

See also

References

  1. init(8) – Version 7 Unix Programmer's Manual
  2. ttys(5) – Version 7 Unix Programmer's Manual
  3. init(8) – 4.2BSD System Manager's Manual
  4. ttys(5) – 4.2BSD File Formats Manual
  5. init(8) – 4.3BSD System Manager's Manual
  6. ttys(5) – 4.3BSD File Formats Manual
  7. Andrew Smallshaw (7 December 2009). "Unix and Linux startup scripts, Part 2".
  8. "Initscripts". Gentoo Linux Documentation. Gentoo.org. 2011-03-02. Retrieved 2011-06-13.
  9. "Oracle Documentation". Docs.sun.com. 2010-09-07. Retrieved 2011-06-13.
  10. "UNIX man pages : runlevel (8)". Unixhelp.ed.ac.uk. 1997-05-27. Retrieved 2014-07-12.
  11. "eINIT git repository XML module directory".
  12. "Epoch Init System Homepage".
  13. Gürer Özen, Görkem Çetin. "Speeding Up Linux: One Step Further With Pardus Pardus". Pardus.org.tr. Retrieved 2011-06-13.
  14. "s6 - skarnet's small supervision suite".

External links

Service management in Unix-like systems
Portable implementations
Operating-system-specific
Process supervision tools
Category: