¡Esta es una revisión vieja del documento!
Tabla de Contenidos
OpenRC
OpenRC es un sistema de gestión de servicios basado en dependencias. Funciona con el programa de inicio provisto por el sistema, normalmente /sbin/init .
Características
OpenRC proporciona una serie de características como la ejecución de initscript iniciada por hardware y la compatibilidad con cgroups, sin requerir grandes cambios de diseño.
Instalación
Dos Slackbuilds están disponibles, openrc, que contiene el sistema de inicio OpenRC, y openrc-services, que contiene varios servicios para usar con OpenRC.
Después de la Instalación
Después de la instalación, se necesitan algunos pasos para arrancar con OpenRC.
Configurar los servicios de agetty
# main tty ln -s /etc/openrc/init.d/agetty /etc/openrc/init.d/agetty.tty1 /sbin/rc-update add agetty.tty1 default cp /etc/openrc/conf.d/agetty /etc/openrc/conf.d/agetty.tty1 echo 'agetty_options="--noclear"' >> /etc/openrc/conf.d/agetty.tty1 # additional ttys for i in {2..6}; do ln -s /etc/openrc/init.d/agetty /etc/openrc/init.d/agetty.tty${i} /sbin/rc-update add agetty.tty${i} default done # serial tty (for servers) ln -s /etc/openrc/init.d/agetty /etc/openrc/init.d/agetty.ttyS0 /sbin/rc-update add agetty.ttyS0 default cp /etc/openrc/conf.d/agetty /etc/openrc/conf.d/agetty.ttyS0 echo 'agetty_options="--noclear"' >> /etc/openrc/conf.d/agetty.ttyS0
Actualizar los parámetros de arranque
Agregue lo siguiente a sus parámetros de arranque (a través de /etc/lilo.conf para lilo o /etc/default/grub para grub):
init =/sbin/openrc-init
Vuelva a generar la configuración de inicio ('lilo -v' o 'grub-mkconfig -o /boot/grub/grub.cfg').
Habilitar el registro de arranque
El archivo de configuración principal para OpenRC es /etc/openrc/rc.conf, y contiene varias opciones.
Una opción común que podría cambiarse es habilitar el registro de inicio configurando rc_logger = “YES”
, de esta manera, cualquier error encontrado durante el inicio podría registrarse y examinarse más tarde (la ubicación predeterminada del registro es /var/log/rc.log).
Reinicio
Al reiniciar,arranca en línea de comandos con solo el mínimo de servicios habilitados.
Puede mostrar una advertencia sobre el soporte en desuso para /etc/mtab como un archivo, y cómo corregirlo:
# cp /etc/mtab /etc/mtab.bkp # ln -snf /proc/self/mounts /etc/mtab
También puede reclamar de que falta el archivo /etc/sysctl.conf que se puede crear como:
# touch /etc/sysctl.conf
Habilitando algunos servicios
Los servicios se pueden habilitar como:
# rc-service add <service> <runlevel>
Pueden ser desactivados como:
# rc-service del <service> <runlevel>
Algunos servicios comunes que podrían ser habilitados:
# rc-update add dbus default # rc-update add sysklogd default # rc-update add dcron default # rc-update add alsasound default # for desktop # rc-update add consolekit default # for desktop # rc-update add sshd default # for server
Los servicios habilitados en el nivel de ejecución actual se pueden consultar con:
$ rc-status
Los servicios habilitados en todos los niveles de ejecución se pueden consultar con:
$ rc-update
Algunos servicios que están habilitados de forma predeterminada para el nivel de ejecución sysinit incluyen udev y udev-postmount.
Los usuarios que usan dmcrypt, lvm o mdraid podrían agregar los siguientes servicios respectivamente al nivel de arranque boot :
# rc-update add dmcrypt boot # dmcrypt # rc-update add device-mapper boot # lvm # rc-update add lvm boot # lvm # rc-update add mdraid boot # mdraid
Red
Si usa Ethernet a través de DHCP, el servicio dhcpcd podría estar habilitado:
# rc-update add dhcpcd default
Si usa wifi con computadoras portátiles, el servicio NetworkManager o wicd podría estar habilitado. La combinación de dhcpcd y wpa_supplicant (junto con una interfaz como wpa_gui o wpa_cli) también podría usarse como una alternativa ligera.
Se puede configurar una red estática editando /etc/openrc/conf.d/network.
Gestor de visualización
Para iniciar desde un administrador de pantalla gráfico, /etc/openrc/conf.d/xdm se puede editar para especificar el administrador de pantalla, y el servicio xdm se podría habilitar:
# rc-update add xdm default
Si usa una computadora portátil, el servicio acpid también podría habilitarse.
Migración de servicios habilitados existentes
Para verificar los servicios habilitados existentes, se podría usar el siguiente código:
for file in /etc/rc.d/*; do if [ -x "${file}" ]; then echo "enabled ${file}" fi done
Para estos servicios, se podrían habilitar los servicios OpenRC correspondientes, por ejemplo:
# rc-update add acpid default # rc-update add cgmanager default # rc-update add gpm default ...
Todos los servicios presentes se pueden consultar a través de:
$ rc-update -v
Configuration
OpenRC services are present in the /etc/openrc/init.d folder, and corresponding configuration files are present in /etc/openrc/conf.d
Some common configuration files include:
/etc/openrc/conf.d/modules # modules to be loaded at boot /etc/openrc/conf.d/hostname # hostname of the system /etc/openrc/conf.d/keymaps # console keymap
Service management
Services can be started/stopped/restarted as:
# rc-service <service> <action>
For example,
# rc-service sshd start
Shutdown/reboot
To shutdown or reboot, one will need to use openrc-shutdown. To shutdown from a desktop environment using ConsoleKit2, check out this PR.
Troubleshooting
At the moment only a subset of the included services have been tested, so some of them may not run correctly.
If some service does not work, try the system provided one in /etc/rc.d (if available).
mysqld
Try adding the following lines to /etc/my.cnf
[mysqld] user = mysql basedir = /usr datadir = /var/lib/mysql pid-file = /run/mysql/mysql.pid socket = /var/run/mysql/mysql.sock
Dealing with crashed services
Sometimes openrc reports a service's status as “crashed”. The process may have died or its pid file disappeared/changed.
If one tries to start a crashed service, `rc-service` reports:
- WARNING: <service> has already been started
So one tries to stop it before starting again.
However in some situations, the service does not stop. This leads to a deadlock where one can neither stop the service nor start it. For such cases:
# rc-service <service> zap * Manually resetting <service> to stopped state
zap resets the service state, allowing us to start it again.
openrc-init
Since version 0.25, openrc provides openrc-init which can be used to boot the system.
This allows switching between OpenRC and other init systems, for example sysvinit, just by changing boot parameters.
For more info, check out the Gentoo wiki.
Migrating from /etc/init.d to /etc/openrc/init.d
OpenRC 0.39+, as shipped via SBo, changes the service and configuration directory to /etc/openrc instead of /etc.
This is being done to maintain greater compatibility with a vanilla Slackware install.
Existing services will need to be migrated, details below on how it can be done.
1. Install openrc-0.39.2 and openrc-services-20181107
These packages ship the configuration and service files in /etc/openrc.
2. Migrate existing services
This involves 4 steps:
# migrate existing services for service in /etc/init.d/*; do svcname=$(basename "$service") if [ ! -e "/etc/openrc/init.d/${svcname}" ]; then if [ -f "/etc/init.d/${svcname}" ] && grep -q openrc "/etc/init.d/${svcname}"; then cp -v "/etc/init.d/${svcname}" "/etc/openrc/init.d/${svcname}" elif [ -L "/etc/init.d/${svcname}" ]; then # check if symlink is of a service service_target=$(readlink -f "$service") service_target_name=$(basename "$service_target") if [ $(dirname "$service_target") = "/etc/init.d" ]; then ln -sv "/etc/openrc/init.d/${service_target_name}" "/etc/openrc/init.d/${svcname}" fi fi fi done # enable existing services for runlevel in /etc/runlevels/*; do for service in ${runlevel}/*; do svcname=$(basename "$service") rvlname=$(basename "$runlevel") if [ ! -e /etc/openrc/runlevels/${rvlname}/${svcname} ] && [ -e /etc/openrc/init.d/${svcname} ]; then ln -sv /etc/openrc/init.d/${svcname} /etc/openrc/runlevels/${rvlname}/${svcname} fi done done # check config changes for file in /etc/conf.d/*; do filename=$(basename "$file") extension="${filename##*.}" if [ "$extension" = orig ] || [ "$extension" == new ]; then continue # dont need to check extra fi if [ -e "/etc/conf.d/${filename}" ] && [ -e "/etc/openrc/conf.d/${filename}" ]; then diff -Nupr "/etc/conf.d/${filename}" "/etc/openrc/conf.d/${filename}" fi done # main config file diff -Nupr /etc/rc.conf /etc/openrc/rc.conf # check local.d changes for file in /etc/local.d/*; do filename=$(basename "$file") if [ ! -e "/etc/openrc/local.d/${filename}" ]; then cp -v "/etc/local.d/${filename}" "/etc/openrc/local.d/${filename}" elif [ -e "/etc/local.d/${filename}" ] && [ -e "/etc/openrc/local.d/${filename}" ]; then # show changes diff -Nupr "/etc/local.d/${filename}" "/etc/openrc/local.d/${filename}" fi done
Config changes found above can be updated by hand or copy pasted in new location.
3. Check and reboot
Verify if rc-status
is showing all services (it may show them as stopped).
Reboot and check whether things are working expected, make changes as necessary.
The old files and folders can be renamed (or removed).
mv /etc/init.d /etc/init.d-openrc-bkp mv /etc/conf.d /etc/conf.d-openrc-bkp mv /etc/local.d /etc/local.d-openrc-bkp mv /etc/runlevels /etc/runlevels-openrc-bkp mv /etc/rc.conf /etc/rc.conf-openrc.bkp
Finally, any changes done to the default Slackware system can be reverted:
mv /etc/init.d-bkp /etc/init.d
See Also
Sources
* Originally written by Aaditya