Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:system:init_systems:openrc [2022/10/24 15:20]
throgh [The system can't shutdown correctly]
en:system:init_systems:openrc [2025/03/13 01:05] (current)
throgh [The system can't shutdown correctly]
Line 1: Line 1:
-?!(WIP)!? 
- 
 ====== OpenRC ====== ====== OpenRC ======
-OpenRC is a init system for Operational Systems GNU/Linux, GNU/Hurd and Unix, compatible with [[https://en.wikipedia.org/wiki/POSIX|Posix]]. Created by the Gentoo GNU/Linux developers team. Its purpose is to turn on/off and manage the services of the Operating System. 
  
-OpenRC emerged at the end of 2007 ((for more details go to: [[https://github.com/OpenRC/openrc/blob/master/HISTORY.md#openrc-history|OpenRC History]])), when Roy Marples retired as a Gentoo GNU/Linux developerHowever, he wanted to keep the **baselayout-2** project as an independent project. The Gentoo Project Board has allowed it to continue to maintain itso the project name should be modified, with OpenRC under the BSD license.+OpenRC is an init system for operating systems such as GNU/Linux, GNU/Hurd and Unix. It is a [[https://en.wikipedia.org/wiki/POSIX|POSIX]]-compatible alternative solution to the problematic [[https://wiki.hyperbola.info/doku.php?id=en:philosophy:systemd_denial|systemd]] software-suite. OpenRC was created by the Gentoo GNU/Linux development teamIts purpose is to enabledisable and/or manage the services of the operating system.
  
-In 2010 OpenRC was retained by the developers of Gentoo GNU/Linux, after Roy Marples decided that it would not keep the project. William Hubbs and several other developers took over the OpenRC from this point, with 0.8.x being the first release made by the new team. In 2011 OpenRC returned to stable Gentoo GNU/Linux tree.+OpenRC emerged at the end of 2007, ((for more details go to: [[https://github.com/OpenRC/openrc/blob/master/HISTORY.md#openrc-history|OpenRC History]])) when Roy Marples retired as a Gentoo GNU/Linux developer. However, he wanted to keep the **baselayout-2** project as an independent project. The Gentoo Project Board has allowed it to continue being maintained as an external project, once the project name was modified to OpenRC with the two-clause BSD license. 
 + 
 +In 2010OpenRC was transferred back to the development of Gentoo GNU/Linux, after Roy Marples decided that he would not keep his project. William Hubbs and several other developers took over OpenRC from this point, with 0.8.x being the first release made by the new team. In 2011OpenRC returned to the stable Gentoo GNU/Linux tree
 + 
 +In 2013, the OpenRC team became independent from Gentoo GNU/Linux again and changed the primary development to <color #B90B0B/#FFDDDD>GitHub</color>.
  
-In 2013, the OpenRC team became independent from Gentoo GNU/Linux again and changed the primary development to the <color #B90B0B/#FFDDDD>Github</color>. 
 ===== Features ===== ===== Features =====
 +
 OpenRC provides a number of interesting features: OpenRC provides a number of interesting features:
-  Compatible with //UNIX// philosophy +  Compatible with //UNIX// philosophy 
-  Portable for non-GNU/Linux systems +  Portable to non-GNU/Linux systems 
-  Cgroups support +  Cgroups ([[https://en.wikipedia.org/wiki/Cgroups|control groups]]) support 
-  Parallel service initialization +  Parallel service initialization 
-  Dependency based initialization +  Dependency-based initialization 
-  Automatic dependency calculation +  Automatic dependency calculation 
-  Enables limiting/unlimited resources for each service +  Enables per-service resource limiting and unlimiting 
-  Sections of split configurations**init.d** and **conf.d** +  Sections of split configurations**init.d** and **conf.d** 
-  Well explained and explanatory configuration files +  Well-explained and self-explanatory configuration files 
-  Startup scripts is extensible and customizable +  Startup scripts are extensible and customizable 
-  Designed to be 100% compatible with virtualization environments +  Designed to be 100% compatible with virtualization environments 
-  Modular architecture suitable and separate optional components**Cron**, **syslog**..+  Modular architecture suitable and separate optional components**cron**, **syslog**, etc
-  Expressive and flexible network handlingincluding VPN +  Expressive and flexible network handling (including VPN, bridges, etc.) 
-  Verbose mode to debug service activity+  Verbose mode to debug service activity
  
-===== Configuration ===== 
-Configuring OpenRC is a simple task, this article offers some steps to optimize the use of this initialization system. 
-==== Boot logs ==== 
-Open the configuration file <color #0B71B9/#DDF1FF>/etc/rc.conf</color> and uncomment the reference line <color #0B71B9/#DDF1FF>rc_logger="YES"</color>. The log files will be stored in <color #0B71B9/#DDF1FF>/var/log/rc.log</color>. 
-==== Hostname ==== 
-To add or edit a host name, edit or create the file <color #0B71B9/#DDF1FF>/etc/conf.d/hostname</color> and add: 
-<code bash> 
-hostname="desired_name" 
-</code> 
-==== Keyboard ==== 
-Modify the key map for use in the **console** edit the file <color #0B71B9/#DDF1FF>/etc/conf.d/consolefont</color>. See the full list of all the options available at <color #0B71B9/#DDF1FF>/usr/share/kbd/keymaps</color> 
-<code bash> 
-keymap="en_UK" 
-</code> 
-To configure the keyboard compatible with a **graphic interface** edit the file <color #0B71B9/#DDF1FF>/etc/conf.d/keymaps</color>. See the full list of all the options available at <color #0B71B9/#DDF1FF>/usr/share/kbd/keymaps</color>. 
-<code bash> 
-keymap="en_UK" 
-</code> 
-After editing the files, run the command: 
-<code bash> 
-# rc-service keymaps restart 
-</code> 
-==== Login manager ==== 
-To enable the login manager, edit the <color #0B71B9/#DDF1FF>/etc/conf.d/xdm</color>. In the following example we take the slim as a base. 
-<code bash> 
-DISPLAYMANAGER="slim" 
-</code> 
-Enable the xdm daemon: 
-<code bash> 
-# rc-update add xdm default 
-</code> 
-==== Kernel modules ==== 
-For the automatic loading of any module of the <color #0BB928/#DDFFE3>Kernel Linux-Libre</color> edit the file <color #0B71B9/#DDF1FF>/etc/conf.d/modules</color>. 
-<code bash> 
-modules="module_name" 
-</code> 
-This is only necessary after installation of an application or driver, made by the system administrator, by default all native modules of <color #0BB928/#DDFFE3>Kernel Linux-Libre</color> are loaded automatically. 
-==== Silent boot ==== 
-To hide OpenRC messages during system startup, edit the file <color #0B71B9/#DDF1FF>/etc/inittab</color> and set the option to the OpenRC command: 
-<code bash> 
---quiet 
-</code> 
-For more information: 
-<code bash> 
-$ openrc -h 
-</code> 
 ===== Runlevels ===== ===== Runlevels =====
-OpenRC, as well as sysvinit and init (BSD), has a concept of task execution levels (Runlevels), to define them OpenRC uses names instead of numbers as it is done in the conventional way. There are two types of runlevels: 
  
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+OpenRC, as well as sysvinit and init (BSD), has a concept of task execution levels (i.e., [[https://en.wikipedia.org/wiki/Runlevel|runlevels]]). To define them in the conventional way, OpenRC uses names instead of numbers. This allows, for example, to have a default runlevel with "everything" enabled with a "powersaving" runlevel where some services are disabled.
  
 +The <color #0B71B9/#DDF1FF>rc-status</color> helper command will print all currently active runlevels and the state of services in them:
  
-!?(WIP)!?!?+<code bash> 
 +# rc-status 
 + * Caching service dependencies ... [ ok ] 
 +Runlevel: default 
 + modules                      started 
 + lvm                          started 
 +</code>
  
-====== OpenRC ======+All runlevels are represented as folders in <color #0B71B9/#DDF1FF>/etc/runlevels/</color> with symbolic links to the actual service scripts.
  
-Since Hyperbola has announced the [[https://www.hyperbola.info/news/end-of-systemd-support/|end of systemd support]], migration to OpenRC is required.+Calling ''openrc'' with an argument (e.g., <color #0B71B9/#DDF1FF>openrc default</color>) will switch to that runlevel; this will start and stop services as needed.
  
-===== What is OpenRC? =====+Managing runlevels is usually done through the <color #0B71B9/#DDF1FF>rc-update</color> helper, but it could of course be done by hand if desired. For example, to add **nginx** to the ''default'' runlevel (with the need of root privileges): <color #0B71B9/#DDF1FF>rc-update add nginx default</color>
  
-[[https://wiki.gentoo.org/wiki/OpenRC|OpenRC]] is a dependency based [[https://en.wikipedia.org/wiki/Init|init]] system maintained by the Gentoo developersthat works with the system provided init program, normally SysVinit.+<note important>The command **''rc-update''** will not start nginx! You would still have to trigger rc, run the service script by handor start it with **''rc-service nginx start''**.</note>
  
-===== Warning =====+The default startup uses the runlevels <color #0B71B9/#DDF1FF>sysinit</color>, <color #0B71B9/#DDF1FF>boot</color>, and <color #0B71B9/#DDF1FF>default</color>, in that order. Shutdown uses the <color #0B71B9/#DDF1FF>shutdown</color> runlevel. The defined runlevel <color #0B71B9/#DDF1FF>nonetwork</color> is used only for non-network services.
  
-<note warning>Please read the whole warning</note> +<note warning><color #620BB9/#EEDDFF>netctl</color> required systemd to work; thereforeit will not work anymore beginning with Milky Way v0.2since OpenRC has become the main init system of Hyperbola. You should already have an alternative included with supported versions of Hyperbola; at present, it is [[https://www.hyperbola.info/packages/?q=netifrc|netifrc]].</note>
- +
-<color #620BB9/#EEDDFF>netctl</color> works with systemd only, therefore it will not work anymore from Milky Way v0.2 since OpenRC is the main init system of Hyperbola. We will assume you already have an alternative, in our case, it is [[https://www.hyperbola.info/packages/?q=netifrc|netifrc]].+
  
 ===== Groups ===== ===== Groups =====
  
-Before Arch migrated to systemd, users had to be manually added to some groups in order to be able to access the corresponding devices. Read more about [[https://wiki.archlinux.org/index.php/Users_and_groups#Group_list|here]]+Users have to be manually added to some groups in order to be able to access the corresponding devices. 
- +One problem is that you would not have any sound on your computer if you did not make sure that your user is in the <color #620BB9/#EEDDFF>audio</color> group, like so:
-Make sure your user is on the <color #620BB9/#EEDDFF>audio</color> group, you won't have sound otherwise:+
  
 <code bash> <code bash>
-gpasswd -<your-user> audio+usermod -aG audio <your-user>
 </code> </code>
  
-Same for videoyour games might be laggy otherwise:+Same as above for videoyour games and other graphics output might be slow or lack acceleration without the below:
  
 <code bash> <code bash>
-gpasswd -<your-user> video+usermod -aG video <your-user>
 </code> </code>
  
Line 113: Line 71:
  
 <code bash> <code bash>
-gpasswd -<your-user> network+usermod -aG network <your-user>
 </code> </code>
  
Line 119: Line 77:
  
 <code bash> <code bash>
-gpasswd -<your-user> optical+usermod -aG optical <your-user>
 </code> </code>
  
Line 125: Line 83:
  
 <code bash> <code bash>
-gpasswd -<your-user> storage+usermod -aG storage <your-user>
 </code> </code>
  
 <code bash> <code bash>
-gpasswd -<your-user> disk+usermod -aG disk <your-user>
 </code> </code>
  
Line 135: Line 93:
  
 <code bash> <code bash>
-gpasswd -<your-user> sys+usermod -aG sys <your-user>
 </code> </code>
- 
-<note>First try these features before adding your user to these groups, for example, in some cases adding your user to the <color #620BB9/#EEDDFF>optical</color> group may not be necessary.</note> 
  
 ===== Migration ===== ===== Migration =====
  
-Since OpenRC is included by default and systemd is blacklisted by [[https://www.hyperbola.info/packages/?q=your-freedom|your-freedom]], one may get messages on migrating like: +<note important> Be aware that since the release of version 0.we do not recommend any kind of migration from another system based onto Arch GNU/Linux. Since Hyperbola has included many changes and therefore differences it would be better to install the system from scratch with all changes you wish.</note>
- +
-<code bash> +
-run 'rc-update add cronie default' +
-run 'rc-update add haveged default' +
-</code> +
- +
-Running these command(s) adds the service(s) to the specified runlevels. For example on running: +
- +
-<code bash> +
-# rc-update add cronie default +
-</code> +
- +
-The cronie service would be added to the default runlevel and would automatically be started at boot. +
- +
-cronie (for cron) and haveged (for entropy harvesting) are some common services that can be enabled. +
- +
-Also you need to install [[https://www.hyperbola.info/packages/?q=polkit|polkit]] to gain enough desktop privileges for operations like shutdown, mounting usb device: +
- +
-<code bash> +
-# pacman -S polkit +
-</code> +
- +
-<note important> Currently, [[https://www.hyperbola.info/packages/?q=networkmanager|NetworkManager]] and any display manager such as [[https://www.hyperbola.info/packages/?q=gdm|GDM]] or [[https://www.hyperbola.info/packages/?q=lightdm|LightDM]] runs the elogind service in Hyperbola automatically, however if you will use the [[https://www.hyperbola.info/packages/?q=xorg-xinit|xinit program]] to start the [[https://www.hyperbola.info/packages/?q=xorg-server|X Window System server]] or [[https://www.hyperbola.info/packages/?q=weston|Weston]]/[[https://www.hyperbola.info/packages/?q=sway|Sway]] to start [[https://www.hyperbola.info/packages/?q=wayland|Wayland]] and use [[https://www.hyperbola.info/packages/?q=netifrc|netifrc]] instead of [[https://www.hyperbola.info/packages/?q=networkmanager|NetworkManager]], you need add the elogind service to a runlevel (eg. default) to be started at boot automatically.</note> +
- +
-<note important> For security reasons, we have plans to use [[https://www.hyperbola.info/todo/consolekit-migration/|ConsoleKit as elogind replacement]]. Since it requires a hard transition, it will be made for the next version, aka Milky Way v0.4. We will make an announcement when it is ready.</note>+
  
 ===== Configuration ===== ===== Configuration =====
Line 173: Line 104:
 ==== Services often required ==== ==== Services often required ====
  
-Once you migrate to OpenRC, you might need to add <color #620BB9/#EEDDFF>lvm2</color> etc.+Here with OpenRC, you might need to add services to support <color #620BB9/#EEDDFF>lvm2</color>etc.
  
-There is the procedure for [[https://www.hyperbola.info/packages/?q=lvm2|lvm2]]:+Here is the procedure for [[https://www.hyperbola.info/packages/?q=lvm2|lvm2]]:
  
 <code bash> <code bash>
Line 199: Line 130:
 </code> </code>
  
-On each package containing an OpenRC service, you will have have this message :+On each package containing an OpenRC service, you will have this message:
  
 <code bash> <code bash>
       ==> rc 'rc-update add ... default'       ==> rc 'rc-update add ... default'
 </code> </code>
 +
 +==== Boot logs ====
 +
 +Open the configuration file <color #0B71B9/#DDF1FF>/etc/rc.conf</color>, and uncomment the reference line <color #0B71B9/#DDF1FF>rc_logger="YES"</color>.\\
 +The log files for the entire **rc** process will be stored in <color #0B71B9/#DDF1FF>/var/log/rc.log</color>.
 +
 ==== Hostname ==== ==== Hostname ====
  
-OpenRC has its configuration in <color #0B71B9/#DDF1FF>/etc/conf.d/</color>, in order to have your hostname, edit <color #0B71B9/#DDF1FF>/etc/conf.d/hostname</color>:+OpenRC has its configuration files under the directory <color #0B71B9/#DDF1FF>/etc/conf.d/</color>
 + 
 +In order to set your hostname, edit <color #0B71B9/#DDF1FF>/etc/conf.d/hostname</color>:
  
 <code bash> <code bash>
-# nano -w /etc/conf.d/hostname+# nano /etc/conf.d/hostname
 </code> </code>
  
-And replace <color #0B71B9/#DDF1FF>localhost</color> with the name that you want:+And redefine <color #0B71B9/#DDF1FF>localhost</color> with the name that you want. (Ideally, do not simply leave it as "localhost".)
  
 <code> <code>
Line 218: Line 157:
 hostname="localhost" hostname="localhost"
 </code> </code>
 +
 +==== Keyboard and Keymap ====
 +
 +To modify the key map for use in the **console**: edit the file ''<color #0B71B9/#DDF1FF>/etc/conf.d/consolefont</color>''. See the full list of all the options available under ''<color #0B71B9/#DDF1FF>/usr/share/kbd/keymaps/</color>''. The below setting is just one example for US-English keyboard maps.
 +
 +<code bash>
 +keymap="us"
 +</code>
 +
 +To configure the keyboard for use with a **graphical interface**, edit the file ''<color #0B71B9/#DDF1FF>/etc/conf.d/keymaps</color>''. Again, the full list of options is available under ''<color #0B71B9/#DDF1FF>/usr/share/kbd/keymaps/</color>''. The following example is for US-English keyboard maps:
 +
 +<code bash>
 +keymap="us"
 +</code>
 +
 +After editing the files, run the command:
 +
 +<code bash>
 +# rc-service keymaps restart
 +</code>
 +
 +<note>This only applies for CLI. If you are using X11, this won't affect your graphical environment.</note>
  
 ==== Network settings ==== ==== Network settings ====
Line 227: Line 188:
 </code> </code>
  
-==== Kepmap ==== 
  
-As the hostname, you need to setup the keymap in the file <color #0B71B9/#DDF1FF>/etc/conf.d/keymaps</color>:  
  
-<code> +==== Login manager ==== 
-keymap="us"+ 
 +**xorg-xdm** 
 + 
 +To enable the login manager, edit <color #0B71B9/#DDF1FF>/etc/conf.d/xdm</color>
 + 
 +If that file does not already exist, then first make sure to install the package **xorg-xdm**: 
 +<code bash
 +pacman -S xorg-xdm
 </code> </code>
  
-If you have an advanced usage of your keymapyou can watch the other functionalities, documented in the comments. You can find all the available keymaps in <color #0B71B9/#DDF1FF>/usr/share/kbd/keymaps</color>. Then run:+As an exampleto use **slim** as the graphical login manager (//with the precondition to install the package **slim**//), replace with the line: 
 +<code bash> 
 +DISPLAYMANAGER="slim" 
 +</code>
  
 +In order for changes to take effect, make sure to enable the xdm daemon, like so:
 <code bash> <code bash>
-# rc-service keymaps restart+# rc-update add xdm default
 </code> </code>
  
-<note>This only applies for CLI, is you are using X11, this won't affect your graphical environment.</note>+**slim**
  
-==== Login display manager ====+The alternative would be to use **slim** direct. So first make sure to install the package **slim**: 
 +<code bash> 
 +pacman -S slim 
 +</code>
  
-Unlike another distros with OpenRC support, the DM is launched directly.+You can add the service direct at the corresponding runlevel: 
 +<code bash> 
 +# rc-update add slim default 
 +</code>
  
-For example, with <color #620BB9/#EEDDFF>wdm</color>, you just need enable the service.+==== Kernel modules ==== 
 + 
 +For the automatic loading of any module of the <color #0BB928/#DDFFE3>Kernel Linux-Libre</color> edit the file <color #0B71B9/#DDF1FF>/etc/conf.d/modules</color>.
  
 <code bash> <code bash>
-# rc-update add wdm default+modules="module_name"
 </code> </code>
 +
 +This is only necessary after installation of an application or driver, made by the system administrator, by default all native modules of <color #0BB928/#DDFFE3>Kernel Linux-Libre</color> are loaded automatically.
 +
  
 ===== Adaptation between systemctl and rc-update ===== ===== Adaptation between systemctl and rc-update =====
Line 263: Line 244:
 </code> </code>
  
-And delete it as follow:+You also can delete a service as follows:
  
 <code bash> <code bash>
Line 277: Line 258:
 </code> </code>
  
-==== Stop/Start/Restart a service ====+==== Stop / Start / Restart a service ====
  
 To restart a service, you need to use <color #620BB9/#EEDDFF>rc-service</color>: To restart a service, you need to use <color #620BB9/#EEDDFF>rc-service</color>:
Line 319: Line 300:
 ==== Swap isn't enabled ==== ==== Swap isn't enabled ====
  
-Systemd used to mount the swap automatically, you need to manually add the swap in <color #0B71B9/#DDF1FF>/etc/fstab</color> as follow:+You need to manually add the swap partition in <color #0B71B9/#DDF1FF>/etc/fstab</color> as follows:
  
 <code bash> <code bash>
Line 328: Line 309:
 ==== tmpfs isn't present ==== ==== tmpfs isn't present ====
  
-As the swap, systemd automatically mounts the tmpfs. Add it manually in <color #0B71B9/#DDF1FF>/etc/fstab</color>:+Add it in <color #0B71B9/#DDF1FF>/etc/fstab</color>:
  
 <code bash> <code bash>
Line 336: Line 317:
 ==== The system can't shutdown correctly ==== ==== The system can't shutdown correctly ====
  
-Begin with OpenRC 0.28 SysVinit is replaced with openrc-init, shutdown is replaced with openrc-shutdown. If you use <color #620BB9/#EEDDFF>startx</color> to start your desktop, you also need to modify <color #0B71B9/#DDF1FF>~/.xinitrc</colorwhen you have issues with your window-manager starting correctly.+Please add your user to the group <color #620BB9/#EEDDFF>power</color>
 + 
 +<code bash> 
 +# usermod -aG power <your-user> 
 +</code> 
 + 
 +Afterwards you should be able to use the command as follows: 
 + 
 +<code bash> 
 +doas poweroff 
 +</code>
  
-===== Acknowledgement ===== 
  
-This wiki article is based on **[[https://wiki.parabola.nu/|ParabolaWiki]]**.