init (Português)

From ArchWiki
Jump to: navigation, search

Tango-preferences-desktop-locale.pngEsse artigo ou seção precisa de tradução.Tango-preferences-desktop-locale.png

Notas: Este artigo está sendo traduzido. (Discuta na Talk:Init (Português)#)
Atenção: O Arch Linux só tem suporte oficial para systemd. [1] Ao usar um sistema init diferente, por favor, mencione isso em solicitações de suporte.

Init é o primeiro processo iniciado durante a inicialização do sistema. É um processo daemon que continua em execução até que o sistema seja encerrado. Init é o ancestral direto ou indireto de todos os outros processos e adota automaticamente todos os processos órfãos. É iniciado pelo kernel usando um nome de arquivo embutido; Se o kernel não puder iniciá-lo, haverá um pânico. Normalmente, a inicialização é atribuída a identificador de processo 1.

Os init scripts (ou rc) são iniciados pelo processo init para garantir a funcionalidade básica no início e no encerramento do sistema. Isso inclui (des)montagem de sistema de arquivos e inicialização de daemons. Um gerenciador de serviços dá um passo além, fornecendo controle ativo sobre processos iniciados, ou supervisão de processos. Um exemplo é monitorar falhas e reiniciar processos de acordo.

Esses componentes combinam-se com o sistema init. Algumas entradas incluem o gerenciador de serviços no processo de inicialização ou possuem scripts de inicialização em relação próxima. Estes inits são abaixo referidos como integrados, embora as entradas em diferentes categorias possam depender explicitamente umas das outras.

Inits (integrados)

  • anopa — Init system built around the s6 supervision suite.
https://jjacky.com/anopa/ || anopaAUR
  • GNU Shepherd — Init system written in Guile.
https://www.gnu.org/software/shepherd/ || shepherdAUR
  • OpenRC — Dependency-based init system.
http://www.gentoo.org/proj/en/base/openrc/ || openrcAUR openrc-arch-services-gitAUR
  • 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

Inits

  • BusyBox — Utilities for rescue and embedded systems.
http://busybox.net/ || busybox
  • 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
http://savannah.nongnu.org/projects/sysvinit || sysvinitAUR

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
  • spark-rc — A simple rc script to kickstart your system.
https://gitlab.com/fbt/spark-rc || spark-rcAUR[link quebrado: package not found]

Gerenciadores de serviços

  • 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
  • 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

Configuração

Migrar serviços em execução

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

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

and configure the #Init scripts accordingly. See also [2].

Note: systemd-tmpfiles(8), kernel modules and sysctl may also need configuration.

logind

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

Tip: A standalone version of logind is available as elogind-gitAUR [4]
Device permissions

Add users to respective groups for device access and reboot. Current group membership should first be checked with id user.

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

See also Users and groups#Pre-systemd groups. To create group rules for use with Polkit, see Polkit#Bypass password prompt.

Rootless X (1.16)

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

/etc/X11/Xwrapper.config
needs_root_rights = yes
Power management

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

Tarefas agendadas

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 [6]. 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

Dicas e truques

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.[7] [8]. 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.

Substituindo udev

Warning: Replacing udev is not required as systemd-udev is functional without systemd as PID 1. Some replacements such as eudev can also not coexist with systemd—ensure an alternative init is booted prior to their installation.
  • eudev — eudev is a fork of udev started by the Gentoo project. It is primarily designed and tested with OpenRC.
https://wiki.gentoo.org/wiki/Eudev || eudevAUR eudev-gitAUR
  • mdev — Device manager for usage in embedded systems.
https://git.busybox.net/busybox/plain/docs/mdev.txt || busybox
  • vdev — A virtual device manager for unix.
https://github.com/jcnelson/vdev.git || vdev-gitAUR[link quebrado: package not found]
  • smdev — smdev is a simple program to manage device nodes. It is mostly compatible with mdev but doesn't have all of its features.
http://git.suckless.org/smdev/ || smdev-gitAUR[link quebrado: package not found]

Veja também