init
init (short for initialization) is a program for Unix-based computer operating systems that spawns all other processes. It runs as a daemon and typically has PID 1. The boot loader starts the kernel and the kernel starts init. If one were to delete init without a replacement, the system would encounter a kernel panic on the next reboot.
The functionality 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 compatible with System V, but some distributions, such as Arch, use a BSD-style and others, such as Gentoo, have their own customized version.
Several replacements for init have been written which attempt to address design limitations such as systemd or Upstart, used by Ubuntu[1][2] and some other Linux distributions.[3][4]
Contents |
[edit] SysV-style
System V init examines the /etc/inittab file for an :initdefault: entry, which tells init whether there is a default runlevel. If there is no default runlevel, then the user is dumped to a system console, where a runlevel must be entered manually.
[edit] Runlevels
The runlevels in System V describe certain states of a machine, characterized by the processes run. There are generally 8 runlevels. These are the runlevels 0 to 6 and S or s, which are aliased to the same runlevel. Of these eight, 3 are so-called "reserved" runlevels:
- 0. Halt
- 1. Single user mode
- 6. Reboot
Aside from runlevels 0, 1, and 6, every Unix and Unix-like system treats runlevels a little differently. The common denominator is the /etc/inittab file, which defines what each runlevel does (if they do anything at all).
[edit] Default runlevels
| Operating System | Default runlevel |
|---|---|
| AIX | 2 |
| Arch Linux | 3 |
| CentOS | 3 or 5 |
| Debian | 2[5] |
| Gentoo Linux | 3[6] |
| HP-UX | 3 |
| Mac OS X | 3 |
| Mandriva Linux | 5 |
| Red Hat Linux / Fedora Core | 3 or 5 |
| Slackware Linux | 3 |
| Solaris | 3[7] |
| SUSE Linux | 5[8] |
| Ubuntu (Server and Desktop) | 2[5] |
On the Linux distributions defaulting to runlevel 5 in the table above, runlevel 5 is a multiuser graphical environment running the X Window System, usually with a display manager. However, in the Solaris operating system, runlevel 5 is typically reserved to shut down and automatically power off the machine.
On most systems users can check the current runlevel with either of the following commands:
$ runlevel$ who -r
The current runlevel is typically changed by root running the telinit or init commands. The default runlevel is set in the /etc/inittab file with the :initdefault: entry.
[edit] BSD-style
BSD init runs the initialization shell script located in /etc/rc, then launches getty on text-based terminals or a windowing system such as X on graphical 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. To mitigate against this, 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.[9] The order in which scripts are executed is determined by the rcorder script based on the requirements stated in these tags.
[edit] Replacements for init
Various efforts have been made to replace the traditional init daemons with something better, including:
- BootScripts in GoboLinux
- DEMONS, a modification of the init start process by KahelOS, where daemons are started only when the DE (desktop environment) started.
- eINIT, a full replacement of init designed to start processes asynchronously, but with the potential of doing it without shell-scripts
- 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.[10]
- OpenRC, the default init system for Gentoo Linux
- runit, a cross-platform full replacement for init with parallel starting of services
- 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, reduced shell overhead and other features, used by Fedora 15.
- 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
[edit] See also
[edit] References
- ^ "Know Thy Ubuntu". Help.ubuntu.com. 2009-08-07. http://help.ubuntu.com/community/KnowThyUbuntu. Retrieved 2011-06-13.
- ^ "since we have no /etc/inittab". Linuxquestions.org. 30 November 2006. http://www.linuxquestions.org/questions/ubuntu-63/since-we-have-no-etcinittab-506281/. Retrieved 2011-06-13.
- ^ "Upstart Plans to Ease Linux Management — Streamlining the init Processes". Reports. LinuxPlanet. 2007-03-08. http://linuxplanet.com/linuxplanet/reports/6366/1/. Retrieved 2011-06-13.
- ^ Remnant, Scott James (2006-08-26). "Upstart in Universe". Netsplit.com. http://www.netsplit.com/2006/08/26/upstart-in-universe/. Retrieved 2011-06-13.
- ^ a b "Debian and Ubuntu Linux Run Levels". Debianadmin.com. 2009-04-02. http://www.debianadmin.com/debian-and-ubuntu-linux-run-levels.html. Retrieved 2011-06-13.
- ^ "Initscripts". Gentoo Linux Documentation. Gentoo.org. 2011-03-02. http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4. Retrieved 2011-06-13.
- ^ "Oracle Documentation". Docs.sun.com. 2010-09-07. http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5ru. Retrieved 2011-06-13.
- ^ [1][dead link]
- ^ Andrew Smallshaw (7 December 2009). "Unix and Linux startup scripts, Part 2". http://aplawrence.com/Basics/unix-startup-scripts-2.html.
- ^ Gürer Özen, Görkem Çetin. "Speeding Up Linux: One Step Further With Pardus Pardus". Pardus.org.tr. http://www.pardus.org.tr/eng/projects/comar/SpeedingUpLinuxWithPardus.html. Retrieved 2011-06-13.