[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
howtos:general_admin:openrc [2018/11/07 07:24 (UTC)] – [openrc-init] split into sections and add more info aadityahowtos:general_admin:openrc [2020/04/12 15:08 (UTC)] – [Note] remove extra word aaditya
Line 4: Line 4:
 OpenRC is a dependency based service management system. It works with the system provided init program, normally ///sbin/init//. OpenRC is a dependency based service management system. It works with the system provided init program, normally ///sbin/init//.
  
-====== Features ======+===== Features =====
  
 OpenRC provides a number of features like hardware initiated initscript run and cgroups support, without requiring large layout changes. OpenRC provides a number of features like hardware initiated initscript run and cgroups support, without requiring large layout changes.
Line 10: Line 10:
 ====== Installation ====== ====== Installation ======
  
-===== Pre installation =====+Two [[slackware:slackbuild_scripts|Slackbuilds]] are available, [[http://slackbuilds.org/repository/14.2/system/openrc/|openrc]], which contains the OpenRC init system, and [[http://slackbuilds.org/repository/14.2/system/openrc-services/|openrc-services]], which contains various services for use with OpenRC.
  
-The /etc/init.d directory (a symlink to ///etc/rc.d/init.d//) will need to be moved: +===== Post installation =====
-  # mv /etc/init.d /etc/init.d-bkp+
  
-===== Installing =====+After installation, some steps are needed to boot with OpenRC.
  
-Two [[slackware:slackbuild_scripts|Slackbuilds]] are available, [[http://slackbuilds.org/repository/14.2/system/openrc/|openrc]], which contains the OpenRC init system, and [[http://slackbuilds.org/repository/14.2/system/openrc-services/|openrc-services]], which contains various services for use with OpenRC.+=== Setup the agetty services ===
  
-===== Post installation =====+  # 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 
 + 
 +=== Update boot parameters === 
 + 
 +Add the following to your boot parameters (via ///etc/lilo.conf// for lilo or ///etc/default/grub// for grub): 
 +  init=/sbin/openrc-init 
 + 
 +Regenerate boot configuration ('lilo -v' or 'grub-mkconfig -o /boot/grub/grub.cfg').
  
-After installing, ///etc/inittab// will need to be replaced. The old one can be backed up: +=== Enable boot logging ===
-  # cp /etc/inittab /etc/inittab.sysvinit +
-  # mv /etc/inittab.new /etc/inittab+
  
-The main configuration file for OpenRC is ///etc/rc.conf//, and contains various options.+The main configuration file for OpenRC is ///etc/openrc/rc.conf//, and contains various options.
  
 A common option that could be changed is to enable boot logging by setting ''rc_logger="YES"'', this way any errors encountered via booting could be logged and examined later (default log location is ///var/log/rc.log//). A common option that could be changed is to enable boot logging by setting ''rc_logger="YES"'', this way any errors encountered via booting could be logged and examined later (default log location is ///var/log/rc.log//).
Line 31: Line 53:
 ===== On reboot ===== ===== On reboot =====
  
-After installing openrc and openrc-services, on rebooting one is booted to a command line with only the bare minimum of services enabled.+On rebootingone is booted to a command line with only the bare minimum of services enabled.
  
 It may show a warning about deprecated support for ///etc/mtab// as a file, and how to correct it: It may show a warning about deprecated support for ///etc/mtab// as a file, and how to correct it:
-  # cp /etc/mtab /etc/mtab.bak+  # cp /etc/mtab /etc/mtab.bkp
   # ln -snf /proc/self/mounts /etc/mtab   # ln -snf /proc/self/mounts /etc/mtab
      
Line 56: Line 78:
   # rc-update add sysklogd default   # rc-update add sysklogd default
   # rc-update add dcron default   # rc-update add dcron default
-  # rc-update add alsasound default  # for desktop+  # rc-update add alsasound boot  # for desktop
   # rc-update add consolekit default  # for desktop   # rc-update add consolekit default  # for desktop
   # rc-update add sshd default  # for server   # rc-update add sshd default  # for server
Line 82: Line 104:
 If using wifi with laptops the **NetworkManager** or **wicd** service could be enabled. The combination of dhcpcd and wpa_supplicant (along with a frontend like wpa_gui or wpa_cli) could also be used as a lightweight alternative. If using wifi with laptops the **NetworkManager** or **wicd** service could be enabled. The combination of dhcpcd and wpa_supplicant (along with a frontend like wpa_gui or wpa_cli) could also be used as a lightweight alternative.
  
-A static network can be configured by editing ///etc/conf.d/network//.+A static network can be configured by editing ///etc/openrc/conf.d/network//.
  
 === Display manager === === Display manager ===
  
-To boot to a graphical display manager, ///etc/conf.d/xdm// can be edited to specify the display manager, and the xdm service could be enabled:+To boot to a graphical display manager, ///etc/openrc/conf.d/xdm// can be edited to specify the display manager, and the xdm service could be enabled:
  
   # rc-update add xdm default   # rc-update add xdm default
Line 116: Line 138:
 ====== Configuration ====== ====== Configuration ======
  
-OpenRC services are present in the ///etc/init.d// folder, and corresponding configuration files are present in ///etc/conf.d//+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: Some common configuration files include:
  
-  /etc/conf.d/modules    # modules to be loaded at boot +  /etc/openrc/conf.d/modules    # modules to be loaded at boot 
-  /etc/conf.d/hostname   # hostname of the system +  /etc/openrc/conf.d/hostname   # hostname of the system 
-  /etc/conf.d/keymaps    # console keymap+  /etc/openrc/conf.d/keymaps    # console keymap
  
-===== Services =====+===== Service management =====
  
 Services can be started/stopped/restarted as: Services can be started/stopped/restarted as:
Line 134: Line 156:
   # rc-service sshd start   # rc-service sshd start
  
-====== openrc-init ======+   
 +===== Shutdown/reboot =====
  
-Since version **0.25**, openrc provides //openrc-init// which can be used to boot the system.+To shutdown or reboot, one will need to use **openrc-shutdown**. To shutdown from a desktop environment using ConsoleKit2check out this [[https://github.com/ConsoleKit2/ConsoleKit2/pull/113|PR]].
  
-This allows switching between OpenRC and other init systems, for example sysvinit, just by changing boot parameters.+==== Note ====
  
-To use it,+The **ck-system-stop** and **ck-system-restart** files in the [[https://github.com/ConsoleKit2/ConsoleKit2/pull/113|PR]] can be saved to ///usr/local/sbin/poweroff// and ///usr/local/sbin/reboot// respectively. This allows using the **poweroff** and **reboot** commands like before.
  
-=== Revert inittab changes done ===+====== Troubleshooting ======
  
-  cp /etc/inittab /etc/inittab-openrc.bkp +At the moment only a subset of the included services have been tested, so some of them may not run correctly.
-  mv /etc/inittab.sysvinit /etc/inittab +
-   +
-=== Setup the agetty services ===+
  
-  # main tty +If some service does not work, try the system provided one in ///etc/rc.d// (if available).
-  ln -s /etc/init.d/agetty /etc/init.d/agetty.tty1 +
-  /sbin/rc-update add agetty.tty1 default +
-     +
-  cp /etc/conf.d/agetty /etc/conf.d/agetty.tty1 +
-  echo 'agetty_options="--noclear"' >> /etc/conf.d/agetty.tty1 +
-   +
-  # additional ttys +
-  for i in {2..6}; do +
-    ln -s /etc/init.d/agetty /etc/init.d/agetty.tty${i} +
-    /sbin/rc-update add agetty.tty${i} default +
-  done +
-   +
-  # serial tty (for servers) +
-  ln -s /etc/init.d/agetty /etc/init.d/agetty.ttyS0 +
-  /sbin/rc-update add agetty.ttyS0 default +
-   +
-  cp /etc/conf.d/agetty /etc/conf.d/agetty.ttyS0 +
-  echo 'agetty_options="--noclear"' >> /etc/conf.d/agetty.ttyS0+
  
-=== Update boot parameters ===+==== mysqld ====
  
-Add the following to your boot parameters (via ///etc/lilo.conf// for lilo or ///etc/default/grub// for grub): +Try adding the following lines to ///etc/my.cnf//
-  init=/sbin/openrc-init+
  
-=== Shutdown/reboot ===+  [mysqld] 
 +  user mysql 
 +  basedir /usr 
 +  datadir = /var/lib/mysql 
 +  pid-file /run/mysql/mysql.pid 
 +  socket /var/run/mysql/mysql.sock
  
-To shutdown or reboot, one will need to use **openrc-shutdown**. To shutdown from a desktop environment using ConsoleKit2check out this [[https://github.com/ConsoleKit2/ConsoleKit2/pull/113|PR]].+==== 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 [[https://wiki.gentoo.org/wiki/OpenRC#openrc-init|Gentoo wiki]]. For more info, check out the [[https://wiki.gentoo.org/wiki/OpenRC#openrc-init|Gentoo wiki]].
  
-====== Migrating from /etc/init.d to /etc/openrc/init.d ======+===== Migrating from /etc/init.d to /etc/openrc/init.d =====
  
-OpenRC 0.39+, as //**planned**// to shipped via SBo, changes the service and configuration directory to ///etc/openrc// instead of ///etc//.+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. This is being done to maintain greater compatibility with a vanilla Slackware install.
Line 194: Line 221:
 === 2. Migrate existing services === === 2. Migrate existing services ===
  
-This involves steps:+This involves steps:
  
   # migrate existing services   # migrate existing services
Line 233: Line 260:
     if [ -e "/etc/conf.d/${filename}" ] && [ -e "/etc/openrc/conf.d/${filename}" ]; then     if [ -e "/etc/conf.d/${filename}" ] && [ -e "/etc/openrc/conf.d/${filename}" ]; then
       diff -Nupr "/etc/conf.d/${filename}" "/etc/openrc/conf.d/${filename}"       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     fi
   done   done
Line 238: Line 278:
 Config changes found above can be updated by hand or copy pasted in new location. Config changes found above can be updated by hand or copy pasted in new location.
  
-=== 3. Reboot and check ===+=== 3. Check and reboot ===
  
-After rebooting and checking whether things are working expected, old files and folders can be renamed (or removed).+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/init.d /etc/init.d-openrc-bkp
   mv /etc/conf.d /etc/conf.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   mv /etc/rc.conf /etc/rc.conf-openrc.bkp
  
Line 249: Line 295:
  
   mv /etc/init.d-bkp /etc/init.d   mv /etc/init.d-bkp /etc/init.d
- 
-====== 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. 
- 
-==== Errors while booting ==== 
- 
-After installing or updating the **openrc-services** packages, one may get errors like: 
- 
-   * checkpath: owner `netdata:netdata' not found 
- 
-This is because **openrc-services** contains services for some packages not found in the base Slackware install, but present on SBo. 
- 
-These usually go away on their own after the openrc cache is updated. 
  
 ====== See Also ====== ====== See Also ======
 howtos:general_admin:openrc ()