Init - ArchWiki

# Init

Related articles

- Arch boot process
- Init Rosetta

Warning: Arch Linux only has official support for systemd. [1] When using a different init system, please mention so in support requests.

Init is the first process started during system boot. It is a a daemon process that continues running until the system is shut down. Init is the direct or indirect ancestor of all other processes, and automatically adopts all orphaned processes. It is started by the kernel using a hard-coded filename; if the kernel is unable to start it, panic will result. Init is typically assigned process identifier 1.

The init scripts (or rc) are launched by the init process to guarantee basic functionality on system start and shutdown. This includes (un)mounting of file systems and launching of daemons. A service manager takes this one step further by providing active control over launched processes, or process supervision. An example is to monitor for crashes and restart processes accordingly.

These components combine to the init system. Some inits include the service manager in the init process, or have init scripts in close relation to them. These inits are below referred to as integrated, though entries in different categories may explicitly depend on each other.

## Inits (integrated)

This article or section is out of date.

Reason: A more updated list of init components is available at: [2] (Discuss in Talk:Init#)

- systemd — Dependency-based init system with aggressive parallelization, process supervision using cgroups, and the ability to depend on a given mount point or dbus service.

  http://freedesktop.org/wiki/Software/systemd/ || systemd

- Upstart — Event-based init system which handles starting, stopping and supervising of tasks and services.

  http://upstart.ubuntu.com/ || upstartAUR[broken link: archived in aur-mirror]

- initng — Dependency-based init system with parallelization and asynchronous start.

  http://initng.sourceforge.net/trac || initng-gitAUR[broken link: archived in aur-mirror]

- Epoch — Single-threaded init system designed for minimal footprint, compatibility and unified configuration.

  http://universe2.us/epoch.html || epoch-init-systemAUR[broken link: archived in aur-mirror]

- finit — Fast and extensible init, originally based on EeePC fastinit.

  https://github.com/troglobit/finit || finit-arcAUR[broken link: archived in aur-mirror] / finit-arc-gitAUR[broken link: archived in aur-mirror]

## Inits

- BusyBox — Utilities for rescue and embedded systems.

  http://busybox.net/ || busybox

- SysVinit — Traditional System V init.

  http://savannah.nongnu.org/projects/sysvinit || sysvinitAUR

- ninit — Fork from minit

  http://riemann.fmi.uni-sofia.bg/ninit/ || ninitAUR

- sinit — Simple init initially based on Rich Felker’s minimal init.

  http://core.suckless.org/sinit || sinitAUR

## Init scripts

- initscripts-fork — Maintained fork of SysVinit scripts in Arch Linux.

  https://bitbucket.org/TZ86/initscripts-fork/overview || initscripts-forkAUR

- minirc — Minimal init script designed for BusyBox.

  https://github.com/hut/minirc/ || minirc-gitAUR

- OpenRC Arch services — OpenRC service scripts compatible to Arch Linux.

  https://github.com/andrewgregory/openrc-arch-services || openrc-arch-services-gitAUR

- spark-rc — A simple rc script to kickstart your system.

  https://gitlab.com/fbt/spark-rc || spark-rcAUR

- watchman-sm-services — Examples of services for watchman.

  https://gitlab.com/fbt/watchman-services || watchman-sm-services-gitAUR

## Service managers

- daemontools — Collection of tools for managing UNIX services.

  http://cr.yp.to/daemontools.html || daemontoolsAUR

- Monit — Monit is a process supervision tool for Unix and Linux. With monit, system status can be viewed directly from the command line, or via the native HTTP(S) web server.

  http://mmonit.com/monit/ || monit

- OpenRC — Dependency-based rc system that works with the system-provided init, normally SysVinit.

  http://www.gentoo.org/proj/en/base/openrc/ || openrcAUR

- perp — Persistent process (service) supervisor and managment framework for UNIX.

  http://b0llix.net/perp/ || perpAUR

- runit — UNIX init scheme with service supervision, a replacement for SysVinit, and other init schemes.

  http://smarden.org/runit/ || runitAUR

- s6 — Small suite of programs for UNIX, designed to allow service supervision in the line of daemontools and runit.

  http://skarnet.org/software/s6/ || s6AUR

- watchman — A not-so-simple service manager for Linux.

  https://gitlab.com/fbt/watchman || watchman-smAUR

## Configuration

### Migrate running daemons

To run daemons under the new init, save a list of running daemons:

    $ systemctl list-units --state=running "*.service" > daemons.list

then configure the #Init scripts accordingly. See also [3].

Temporary files (systemd-tmpfiles), kernel modules and sysctl may also need configuration.

### logind

logind requires systemd to be the init process. [4] As such, local sessions and other functionality is not available.

Tip: A standalone version of logind is available as elogind-gitAUR [5]

#### Device permissions

Add users to the correct groups for device access, and reboot. Current group membership should first be checked with `id user`. For example:

    # usermod -a -G video,audio,power,disk,storage,optical,lp,scanner user

See Policykit#Bypass password prompt to create group rules for use with Policykit.

#### Rootless X (1.16)

As `Xorg.wrap` does not check if logind is active [6], root rights for Xorg need be enabled manually:

    /etc/X11/Xwrapper.config

    needs_root_rights = yes

#### Power management

See pm-utils and acpid to replace Power management with systemd.

### Scheduled tasks

Arch uses timer files instead of cron by default. See archlinux-cronjobs for basic cron jobs.

### Dbus

User instances of dbus-daemon are launched by systemd/User. [7] When requring IPC between desktop applications, restore `30-dbus.sh`:

    /etc/X11/xinit/xinitrc.d/30-dbus.sh

    #!/bin/bash

    # launches a session dbus instance
    if [ -z "${DBUS_SESSION_BUS_ADDRESS-}" ] && type dbus-launch >/dev/null; then
      eval $(dbus-launch --sh-syntax --exit-with-session)
    fi

## Tips and tricks

### systemd-nspawn

systemd-nspawn is a tool for systemd systems. Since Linux 2.6.19 it is however possible to run systemd on a non-systemd system by using PID namespace. For it, the kernel needs to be configured with `CONFIG_PID_NS` and `CONFIG_NAMESPACES`).

The PID namespace creates a new hierarchy of processes starting with PID 1. In addition to this, systemd requires a chrooted root filesystem to be mounted. Hence, you have to at least make a bind mount, because otherwise some services will fail with

    "Failed at step NAMESPACE spawning" due to "Invalid operation"

as systemd tries to remount the root with `private` option.

To setup a chroot with a new PID namespace you can use jchroot.[8] [9]. Make sure not to mount `/proc` inside the new root before chrooting, otherwise systemd will detect the chroot environment. You can mount it later once systemd is running.

## See also

- Debian init system debate
- How to run s6-svscan as process 1
- Replace systemd with busybox + minirc
- Experiments of Manjaro
- Init vs. runsv
- Demystifying the init system
- A history of modern init systems (1992-2015)

Category:

- Boot process

Hidden categories:

- Pages or sections flagged with Template:Out of date
- Pages with broken package links