<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=StruanR</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=StruanR"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/StruanR"/>
	<updated>2026-05-09T23:35:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=30896</id>
		<title>OpenRC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=30896"/>
		<updated>2025-09-12T13:07:21Z</updated>

		<summary type="html">&lt;p&gt;StruanR: /* Quickstart */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Alpine Linux uses [https://github.com/OpenRC/ OpenRC] for its [https://en.wikipedia.org/wiki/Init init] system. The init system manages the services, including the boot and shutdown of your system. OpenRC also supports managing [[#User services|services for users]]. &lt;br /&gt;
&lt;br /&gt;
To learn the basics of OpenRC quickly, refer to the [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html working with OpenRC] guide from the Alpine Linux documentation project. &lt;br /&gt;
&lt;br /&gt;
== Quickstart  ==&lt;br /&gt;
&lt;br /&gt;
{|align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;50%&amp;quot; |Action&lt;br /&gt;
|             |Command&lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Managing a service - start,stop and restart&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Start {{ic|ServiceName}} now || {{ic|$ rc-service {{ic|ServiceName}} start}}&lt;br /&gt;
|-&lt;br /&gt;
| Stop {{ic|ServiceName}} now || {{ic|$ rc-service {{ic|ServiceName}} stop}} &lt;br /&gt;
|-&lt;br /&gt;
| Restart {{ic|ServiceName}} now || {{ic|$ rc-service {{ic|ServiceName}} restart}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Adding and removing service from runlevels&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Add {{ic|ServiceName}} to {{ic|runlevel}} || {{ic|$ rc-update add {{ic|ServiceName}} {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| Remove {{ic|ServiceName}} from {{ic|runlevel}} || {{ic|$ rc-update del {{ic|ServiceName}} {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check services in a runlevel and their status&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To check status of {{ic|ServiceName}} || {{ic|$ rc-service {{ic|ServiceName}} status}} &lt;br /&gt;
|-&lt;br /&gt;
| To view services configured at {{ic|runlevel}}  || {{ic|$ rc-update show {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| To view currently active runlevels and state of services  || {{ic|$ rc-status}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check and manage runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view available runlevels || {{ic|$ rc-status -l}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different {{ic|runlevel}} || {{ic|$ openrc {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Stacked runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{ic|$ rc-update add -s {{ic|s-runlevel}}{{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| To remove {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{ic|$ rc-update del -s {{ic|s-runlevel}}  {{ic|runlevel}}}}&lt;br /&gt;
| -&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; |&#039;&#039;&#039;User Services&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view currently active User runlevels and state of User services || {{ic|$ rc-status -U}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different user {{ic|runlevel}} || {{ic|$ openrc -U {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| Add User {{ic|ServiceName}} to user {{ic|runlevel}} || {{ic|$ rc-update -U add {{ic|ServiceName}} {{ic|runlevel}}}}&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}}as a stacked user {{ic|runlevel}} || {{ic|$ rc-update -U add -s {{ic|s-runlevel}} {{ic|runlevel}}}} &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Runlevels ==&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;runlevel&#039;&#039; is basically a collection of services that needs to be started when certain conditions are met. Instead of using runlevel numbers, such as is used traditionally with &#039;&#039;SysV&#039;&#039; init, these are named, and users can create their own, if needed. The default startup uses the &#039;&#039;&#039;sysinit&#039;&#039;&#039;, &#039;&#039;&#039;boot&#039;&#039;&#039;, and &#039;&#039;&#039;default&#039;&#039;&#039; runlevels, in that order. Shutdown uses the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel.&lt;br /&gt;
&lt;br /&gt;
The available runlevels are:&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; - Used if no runlevel is specified. (This is generally the runlevel you want to add services to.)&lt;br /&gt;
* &#039;&#039;&#039;hotplugged&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The special runlevels are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;sysinit&#039;&#039;&#039; - Brings up system specific stuff such as &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; and optionally &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt; for Linux based systems. It also mounts &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; as a ramdisk using tmpfs where available unless &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is mounted rw at boot. &amp;lt;code&amp;gt;&#039;&#039;&#039;rc&#039;&#039;&#039;&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; to hold state information about the services it runs. &#039;&#039;&#039;sysinit&#039;&#039;&#039; always runs when the host first starts and should not be run again.&lt;br /&gt;
* &#039;&#039;&#039;boot&#039;&#039;&#039; - Generally, the only services that one should add to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel are those which deal with the mounting of filesystems, setting the initial state of attached peripherals, and logging. Hotplugged services are added to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel by the system. All services in the &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevels are automatically included in all other runlevels except for those listed here.&lt;br /&gt;
* &#039;&#039;&#039;single&#039;&#039;&#039; - Stops all services except for those in the &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevel.&lt;br /&gt;
* &#039;&#039;&#039;reboot&#039;&#039;&#039; - Changes to the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel, and then reboots the host.&lt;br /&gt;
* &#039;&#039;&#039;shutdown&#039;&#039;&#039; - Changes to the shutdown &#039;&#039;&#039;runlevel&#039;&#039;&#039;, and then halts the host.&lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevels ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Stacked&#039;&#039; runlevels allows for the &amp;quot;inheritance&amp;quot; of services. A few use cases are given below:-&lt;br /&gt;
* [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html#_runlevel_stacking Running an office runlevel with VPN service]&lt;br /&gt;
* [[#Preventing slow services from delaying system startup|Preventing slow services from delaying system startup]]&lt;br /&gt;
For more detailed information, refer [https://wiki.gentoo.org/wiki/OpenRC/Stacked%20runlevel Gentoo wiki].&lt;br /&gt;
&lt;br /&gt;
== Config files == &lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC is {{Path|/etc/rc.conf}}. The OpenRC service scripts for each service can be found at {{Path|/etc/init.d/}} and their respective service configuration files at {{Path|/etc/conf.d/}}.&lt;br /&gt;
&lt;br /&gt;
== Command usage ==&lt;br /&gt;
&lt;br /&gt;
OpenRC provides the following commands:&lt;br /&gt;
* {{ic|rc-update}} &lt;br /&gt;
* {{ic|rc-service}}&lt;br /&gt;
* {{ic|rc-status}}&lt;br /&gt;
* {{ic|openrc}}&lt;br /&gt;
&lt;br /&gt;
To view the command usage for all OpenRC commands, use the &#039;&#039;&#039;--help&#039;&#039;&#039; or &#039;&#039;&#039;-h&#039;&#039;&#039; flag.  For eg:{{ic|$ rc-update &#039;&#039;&#039;--help&#039;&#039;&#039;}} or {{ic|$ rc-update &#039;&#039;&#039;-h&#039;&#039;&#039;}} will show usage information for {{ic|rc-update}}.&lt;br /&gt;
&lt;br /&gt;
To {{ic|start}}, {{ic|stop}} or {{ic|restart}} a service {{ic|ServiceName}} immediately at the current runlevel:&lt;br /&gt;
{{cmd|$ doas rc-service {{ic|ServiceName}} start}}&lt;br /&gt;
{{cmd|$ doas rc-service {{ic|ServiceName}} stop}}&lt;br /&gt;
&lt;br /&gt;
To {{ic|add}} or {{ic|delete}} a service to/from the sequence of services that need to start automatically in future sessions at the {{ic|boot}} runlevel: &lt;br /&gt;
{{cmd|$ doas rc-update add {{ic|ServiceName}} boot}}&lt;br /&gt;
Note that the {{ic|&#039;&#039;&#039;default&#039;&#039;&#039;}} runlevel is assumed, so it does not need to be stated explicitly:&lt;br /&gt;
{{cmd|$ doas rc-update add {{ic|ServiceName}}}}&lt;br /&gt;
{{cmd|$ doas rc-update del {{ic|ServiceName}}}}&lt;br /&gt;
&lt;br /&gt;
List the current status of all services; to display the status of all &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{cmd|$ rc-status}}&lt;br /&gt;
List the assigned runlevels of all services; to display the runlevels of &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{cmd|$ rc-update}}&lt;br /&gt;
&lt;br /&gt;
Refer to the [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user guide] for more detailed information.&lt;br /&gt;
&lt;br /&gt;
== Cgroups ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports [https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html cgroups v2] in the default configuration. To enable hybrid cgroups, edit the file {{Path|/etc/rc.conf}} and change the setting for {{ic|rc_cgroup_mode}} as follows:{{Cat|/etc/rc.conf|rc_cgroup_mode{{=}}&amp;quot;hybrid&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Then, one should run {{Cmd|# rc-service cgroups start}}&lt;br /&gt;
to take effect and {{Cmd|# rc-update add cgroups}}&lt;br /&gt;
to auto mount the cgroup filesystem on boot.&lt;br /&gt;
&lt;br /&gt;
== Local service ==&lt;br /&gt;
&lt;br /&gt;
Use the {{Path|/etc/local.d/}} directory to place programs or scripts which are to be run when the {{ic|local}} service is started or stopped.&lt;br /&gt;
&lt;br /&gt;
If a file in this directory is executable and it has a .start extension, it will be run when the local service is started. If a file is executable and it has a .stop extension, it will be run when the local service is stopped. For more info refer [https://github.com/OpenRC/openrc/blob/master/local.d/README README]&lt;br /&gt;
&lt;br /&gt;
To enable the {{ic|local}} service, issue the command:{{Cmd|# rc-update add local}}&lt;br /&gt;
&lt;br /&gt;
== Preventing slow services from delaying system startup ==&lt;br /&gt;
&lt;br /&gt;
Services that take a while to start will block the boot process until they complete. E.g.: {{ic|iwd}},{{ic|networking}},{{ic|chrony}} etc... might delay startup of an interactive system rather than start in the background. &lt;br /&gt;
&lt;br /&gt;
=== Parallel services === &lt;br /&gt;
&lt;br /&gt;
If the setting {{Codeline|rc_parallel{{=}}&amp;quot;YES&amp;quot;}} is configured, the OpenRC system tries to start services in parallel for a slight speed improvement. &lt;br /&gt;
This setting however comes with a message from openRC developers:{{Warning|whilst we have improved parallel, it can still potentially lock the boot process. Don&#039;t file bugs about this.}} &lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevel method === &lt;br /&gt;
&lt;br /&gt;
Slow services can also be [https://ptrcnull.me/posts/openrc-async-services.html started after login prompt] using [[#Stacked runlevels|stacked runlevels]]. &lt;br /&gt;
{{Warning|Editing the file {{Path|&#039;&#039;&#039;/etc/inittab&#039;&#039;&#039;}} wrongly will render the system unusable. Take backup and learn to restore it using rescue disk before proceeding.}}&lt;br /&gt;
&lt;br /&gt;
# Create a custom runlevel &#039;&#039;&#039;async&#039;&#039;&#039;:  {{Cmd|# mkdir /etc/runlevels/async}}&lt;br /&gt;
# Add &#039;&#039;&#039;default&#039;&#039;&#039; as a stacked runlevel {{Cmd|# rc-update add -s default async}}&lt;br /&gt;
# Remove slow service from &#039;&#039;&#039;default&#039;&#039;&#039; runlevel and add them to the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel:{{Cmd|&amp;lt;nowiki&amp;gt;# rc-update del &amp;lt;servicename&amp;gt; default&lt;br /&gt;
# rc-update add &amp;lt;servicename&amp;gt; async &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# Enable the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel by adding the line &#039;&#039;&#039;::once:/sbin/openrc async&#039;&#039;&#039; to {{Path|/etc/inittab}} file as follows: {{Cat|/etc/inittab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
::wait:/sbin/openrc default&lt;br /&gt;
::once:/sbin/openrc async -q&lt;br /&gt;
&lt;br /&gt;
# Set up a couple of getty&#039;s&lt;br /&gt;
tty1::respawn:/sbin/getty 38400 tty1&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
After rebooting, services from &#039;&#039;&#039;async&#039;&#039;&#039; will start separately. Other services started in &#039;&#039;&#039;default&#039;&#039;&#039; runlevel may still block [[TTY_Autologin|agetty]] from running, due to the {{ic|wait}} label.&lt;br /&gt;
&lt;br /&gt;
== User services ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports managing services for users. User services are currently experimental and available from [[Release_Notes_for_Alpine_3.22.0#OpenRC_User_services|v3.22]]. Here is the [https://pkgs.alpinelinux.org/contents?file=*&amp;amp;path=%2Fetc%2Fuser%2Finit.d&amp;amp;name=&amp;amp;branch=edge&amp;amp;repo=&amp;amp;arch=x86_64 list of OpenRC User services] available currently.&lt;br /&gt;
&lt;br /&gt;
Such services are said to be running in &#039;&#039;user mode&#039;&#039; and are managed with usual OpenRC commands using the  &#039;&#039;&#039;-U&#039;&#039;&#039; option (as distinct from the &#039;&#039;-u&#039;&#039; option), and without &#039;&#039;&#039;doas&#039;&#039;&#039; (nor as root).  &lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
* [[XDG_RUNTIME_DIR]] variable must be set &lt;br /&gt;
&lt;br /&gt;
=== Config files for user services ===&lt;br /&gt;
&lt;br /&gt;
OpenRC uses {{path|$XDG_CONFIG_HOME/rc}} for its user service configuration. If &amp;lt;code&amp;gt;$XDG_CONFIG_HOME&amp;lt;/code&amp;gt; is unset, the fallback {{path|~/.config}} is used.&lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC User services is {{path|~/.config/rc/rc.conf}}.&lt;br /&gt;
&lt;br /&gt;
==== Runlevels ====&lt;br /&gt;
&lt;br /&gt;
Runlevels are represented by directories in {{path|$XDG_CONFIG_HOME/rc/runlevels}}. The default runlevel is &amp;lt;code&amp;gt;sysinit&amp;lt;/code&amp;gt; and needs to be created explicitly in order to be enabled:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p ${XDG_CONFIG_HOME:-~/.config}/rc/runlevels/sysinit&lt;br /&gt;
&lt;br /&gt;
To start the default runlevel (&amp;lt;code&amp;gt;sysinit&amp;lt;/code&amp;gt;), use:&lt;br /&gt;
&lt;br /&gt;
 openrc -U&lt;br /&gt;
&lt;br /&gt;
To start another runlevel, use:&lt;br /&gt;
&lt;br /&gt;
 openrc -U $RUNLEVEL&lt;br /&gt;
&lt;br /&gt;
Add the above line to &amp;lt;code&amp;gt;~/.profile&amp;lt;/code&amp;gt; to automatically start the runlevel after logging in.&lt;br /&gt;
&lt;br /&gt;
If automatic start-up of a runlevel needs to be enforced by the system administrator, see [[#PAM support|PAM support]] below.&lt;br /&gt;
&lt;br /&gt;
==== Services ====&lt;br /&gt;
&lt;br /&gt;
The service scripts for each OpenRC user service provided as part of official packages can be found at {{Path|/etc/user/init.d/}} and their respective service configuration files at {{Path|/etc/user/conf.d/}}. &lt;br /&gt;
&lt;br /&gt;
The folders {{path|~/.config/rc/init.d/}} and {{path|~/.config/rc/conf.d/}} can have user customized service scripts for User services and their respective configuration files. These scripts override official files at {{Path|/etc/user/}}, if their service names match.&lt;br /&gt;
&lt;br /&gt;
=== Configure environment variables ===&lt;br /&gt;
&lt;br /&gt;
==== For Wayland ====&lt;br /&gt;
{{Tip|User services like {{pkg|wlsunset}} depend on the {{ic|$WAYLAND_DISPLAY}} environment variable. Hence, it is [https://gitlab.alpinelinux.org/alpine/aports/-/issues/17375#note_530383 recommended] to use &#039;&#039;&#039;gui&#039;&#039;&#039; runlevel for such services. Even though [[PipeWire]] can run at &#039;&#039;&#039;default&#039;&#039;&#039; runlevel, ensure that all your User services can run at the chosen runlevel.}} &lt;br /&gt;
* Allow propagation of the {{ic|$WAYLAND_DISPLAY}} and associated environment variables by adding the following lines to file {{path|~/.config/rc/rc.conf}} as follows:{{Cat|~/.config/rc/rc.conf|&amp;lt;nowiki&amp;gt;rc_env_allow=&amp;quot;WAYLAND_DISPLAY&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* Create a custom &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel:{{Cmd|$ mkdir -p ~/.config/rc/runlevels/gui}}&lt;br /&gt;
* To start &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel, add the line {{ic|openrc -U gui}} to the startup file of your compositor. For eg, for [[Sway]] add:{{Cat|~/.config/sway/config|...&lt;br /&gt;
exec openrc -U gui}}&lt;br /&gt;
&lt;br /&gt;
==== For Xorg ====&lt;br /&gt;
&lt;br /&gt;
If [[Elogind]] is not used, ensure that [[Wayland#Creating_and_exporting_XDG_RUNTIME_DIR_manually|XDG_RUNTIME_DIR]] is set manually in {{path|~/.xinitrc}}. For eg, for [[dwm]] add:{{Cat|~/.xinitrc|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
if [ -z &amp;quot;$XDG_RUNTIME_DIR&amp;quot; ]; then&lt;br /&gt;
	XDG_RUNTIME_DIR=&amp;quot;/tmp/$(id -u)-runtime-dir&amp;quot;&lt;br /&gt;
	mkdir -pm 0700 &amp;quot;$XDG_RUNTIME_DIR&amp;quot;&lt;br /&gt;
	export XDG_RUNTIME_DIR&lt;br /&gt;
fi&lt;br /&gt;
openrc -U default&lt;br /&gt;
exec dwm&amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
&lt;br /&gt;
{{Note|For both the above cases, logout and login for the OpenRC user services to be started, before proceeding further.}}&lt;br /&gt;
&lt;br /&gt;
=== User service management ===&lt;br /&gt;
&lt;br /&gt;
Issue the command {{ic|$ rc-status -Ur}} to view and verify the current user runlevel as &#039;&#039;&#039;gui&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; for Wayland and Xorg, respectively, before proceeding. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|ServiceName}} user service, issue the command:{{Cmd|$ rc-service -U {{ic|ServiceName}} start}}&lt;br /&gt;
Verify that the above OpenRC user service is started before proceeding further: {{Cmd|$ rc-status -U}} &lt;br /&gt;
To enable {{ic|ServiceName}} user service, issue the command: {{Cmd|$ rc-update -U add ServiceName}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|Once a user service is configured, to prevent duplicate instance, remove them from {{Path|/etc/xdg/autostart}} folder or from the startup/config file.}}&lt;br /&gt;
&lt;br /&gt;
=== PAM support ===&lt;br /&gt;
&lt;br /&gt;
The default installation of OpenRC user services in Alpine Linux is without PAM support.&lt;br /&gt;
&lt;br /&gt;
In scenarios where services should not be allowed to [https://wiki.gentoo.org/wiki/OpenRC#lingering linger] on logout, PAM support for OpenRC user services can be enabled by installing the {{pkg|openrc-user-pam}} package.{{Cmd|# apk add {{pkg|openrc-user-pam}}}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Whenever a openRC service fails to run, troubleshoot by enabling a debugging option, and then run the command. &lt;br /&gt;
&lt;br /&gt;
For example, if running the command {{ic|rc-service greetd start}} causes the [[Greetd|greetd]] service to immediately crash, then alter the command to enable debug and to view its output:{{Cmd|# rc-service -d greetd restart}}&lt;br /&gt;
&lt;br /&gt;
=== XDG_RUNTIME_DIR unset ===&lt;br /&gt;
&lt;br /&gt;
While configuring [[#User services|user services]], running the command {{ic|$ doas rc-update add -U pipewire gui}} will generate the above error {{ic|XDG_RUNTIME_DIR unset}}.  Always issue the command as normal user {{ic|$ rc-update add -U pipewire gui}} and do NOT use {{ic|doas}}. &lt;br /&gt;
&lt;br /&gt;
=== ERROR: user.greetd failed to start ===&lt;br /&gt;
&lt;br /&gt;
While using [[#User services|user services]] with [[greetd]], the above error message will appear. This failed error message for {{ic|user.greetd}} service is harmless as per {{MR|81612#note_492385}}.&lt;br /&gt;
&lt;br /&gt;
=== failed to create display ===&lt;br /&gt;
&lt;br /&gt;
When using openRC user services for {{ic|wlsunset}}, the following  error message may appear:{{Cmd|daemon.err wlsunset: failed to create display}}You will need the GUI runlevel for services that depend on {{ic|$WAYLAND_DISPLAY}}. Refer [[#For Wayland| Configure environment variables For Wayland]] section.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Writing Init Scripts]]&lt;br /&gt;
* [[Multiple Instances of Services]]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user Guide]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md OpenRC Service Script Writing Guide]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/OpenRC Gentoo Wiki]&lt;br /&gt;
* [https://wiki.archlinux.org/title/OpenRC ArchWiki]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/OpenRC PostmarketOS Wiki]&lt;br /&gt;
* [https://ptrcnull.me/posts/openrc-async-services.html Start services after login prompt]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]] &lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>StruanR</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=30895</id>
		<title>OpenRC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=30895"/>
		<updated>2025-09-12T08:49:04Z</updated>

		<summary type="html">&lt;p&gt;StruanR: Fix typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Alpine Linux uses [https://github.com/OpenRC/ OpenRC] for its [https://en.wikipedia.org/wiki/Init init] system. The init system manages the services, including the boot and shutdown of your system. OpenRC also supports managing [[#User services|services for users]]. &lt;br /&gt;
&lt;br /&gt;
To learn the basics of OpenRC quickly, refer to the [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html working with OpenRC] guide from the Alpine Linux documentation project. &lt;br /&gt;
&lt;br /&gt;
== Quickstart  ==&lt;br /&gt;
&lt;br /&gt;
{|align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;50%&amp;quot; |Action&lt;br /&gt;
|             |Command&lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Managing a service - start,stop and restart&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Start {{ic|ServiceName}} now || {{ic|# rc-service {{ic|ServiceName}} start}}&lt;br /&gt;
|-&lt;br /&gt;
| Stop {{ic|ServiceName}} now || {{ic|# rc-service {{ic|ServiceName}} stop}} &lt;br /&gt;
|-&lt;br /&gt;
| Restart {{ic|ServiceName}} now || {{ic|# rc-service {{ic|ServiceName}} restart}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Adding and removing service from runlevels&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Add {{ic|ServiceName}} to {{ic|runlevel}} || {{ic|# rc-update add {{ic|ServiceName}} {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| Remove {{ic|ServiceName}} from {{ic|runlevel}} || {{ic|# rc-update del {{ic|ServiceName}} {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check services in a runlevel and their status&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To check status of {{ic|ServiceName}} || {{ic|$ rc-service {{ic|ServiceName}} status}} &lt;br /&gt;
|-&lt;br /&gt;
| To view services configured at {{ic|runlevel}}  || {{ic|$ rc-update show {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| To view currently active runlevels and state of services  || {{ic|$ rc-status}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check and manage runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view available runlevels || {{ic|$ rc-status -l}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different {{ic|runlevel}} || {{ic|# openrc {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Stacked runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{ic|# rc-update add -s {{ic|s-runlevel}} {{ic|runlevel}}}} &lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; |&#039;&#039;&#039;User Services&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view currently active User runlevels and state of User services || {{ic|$ rc-status -U}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different user {{ic|runlevel}} || {{ic|$ openrc -U {{ic|runlevel}}}} &lt;br /&gt;
|-&lt;br /&gt;
| Add User {{ic|ServiceName}} to user {{ic|runlevel}} || {{ic|$ rc-update -U add {{ic|ServiceName}} {{ic|runlevel}}}} &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Runlevels ==&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;runlevel&#039;&#039; is basically a collection of services that needs to be started when certain conditions are met. Instead of using runlevel numbers, such as is used traditionally with &#039;&#039;SysV&#039;&#039; init, these are named, and users can create their own, if needed. The default startup uses the &#039;&#039;&#039;sysinit&#039;&#039;&#039;, &#039;&#039;&#039;boot&#039;&#039;&#039;, and &#039;&#039;&#039;default&#039;&#039;&#039; runlevels, in that order. Shutdown uses the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel.&lt;br /&gt;
&lt;br /&gt;
The available runlevels are:&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; - Used if no runlevel is specified. (This is generally the runlevel you want to add services to.)&lt;br /&gt;
* &#039;&#039;&#039;hotplugged&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The special runlevels are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;sysinit&#039;&#039;&#039; - Brings up system specific stuff such as &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; and optionally &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt; for Linux based systems. It also mounts &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; as a ramdisk using tmpfs where available unless &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is mounted rw at boot. &amp;lt;code&amp;gt;&#039;&#039;&#039;rc&#039;&#039;&#039;&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; to hold state information about the services it runs. &#039;&#039;&#039;sysinit&#039;&#039;&#039; always runs when the host first starts and should not be run again.&lt;br /&gt;
* &#039;&#039;&#039;boot&#039;&#039;&#039; - Generally, the only services that one should add to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel are those which deal with the mounting of filesystems, setting the initial state of attached peripherals, and logging. Hotplugged services are added to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel by the system. All services in the &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevels are automatically included in all other runlevels except for those listed here.&lt;br /&gt;
* &#039;&#039;&#039;single&#039;&#039;&#039; - Stops all services except for those in the &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevel.&lt;br /&gt;
* &#039;&#039;&#039;reboot&#039;&#039;&#039; - Changes to the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel, and then reboots the host.&lt;br /&gt;
* &#039;&#039;&#039;shutdown&#039;&#039;&#039; - Changes to the shutdown &#039;&#039;&#039;runlevel&#039;&#039;&#039;, and then halts the host.&lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevels ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Stacked&#039;&#039; runlevels allows for the &amp;quot;inheritance&amp;quot; of services. A few use cases are given below:-&lt;br /&gt;
* [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html#_runlevel_stacking Running an office runlevel with VPN service]&lt;br /&gt;
* [[#Preventing slow services from delaying system startup|Preventing slow services from delaying system startup]]&lt;br /&gt;
For more detailed information, refer [https://wiki.gentoo.org/wiki/OpenRC/Stacked%20runlevel Gentoo wiki].&lt;br /&gt;
&lt;br /&gt;
== Config files == &lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC is {{Path|/etc/rc.conf}}. The OpenRC service scripts for each service can be found at {{Path|/etc/init.d/}} and their respective service configuration files at {{Path|/etc/conf.d/}}.&lt;br /&gt;
&lt;br /&gt;
== Command usage ==&lt;br /&gt;
&lt;br /&gt;
OpenRC provides the following commands:&lt;br /&gt;
* {{ic|rc-update}} &lt;br /&gt;
* {{ic|rc-service}}&lt;br /&gt;
* {{ic|rc-status}}&lt;br /&gt;
* {{ic|openrc}}&lt;br /&gt;
&lt;br /&gt;
To view the command usage for all OpenRC commands, use the &#039;&#039;&#039;--help&#039;&#039;&#039; or &#039;&#039;&#039;-h&#039;&#039;&#039; flag.  For eg:{{ic|$ rc-update &#039;&#039;&#039;--help&#039;&#039;&#039;}} or {{ic|$ rc-update &#039;&#039;&#039;-h&#039;&#039;&#039;}} will show usage information for {{ic|rc-update}}.&lt;br /&gt;
&lt;br /&gt;
To {{ic|start}}, {{ic|stop}} or {{ic|restart}} a service {{ic|ServiceName}} immediately at the current runlevel:&lt;br /&gt;
{{cmd|$ doas rc-service {{ic|ServiceName}} start}}&lt;br /&gt;
{{cmd|$ doas rc-service {{ic|ServiceName}} stop}}&lt;br /&gt;
&lt;br /&gt;
To {{ic|add}} or {{ic|delete}} a service to/from the sequence of services that need to start automatically in future sessions at the {{ic|boot}} runlevel: &lt;br /&gt;
{{cmd|$ doas rc-update add {{ic|ServiceName}} boot}}&lt;br /&gt;
Note that the {{ic|&#039;&#039;&#039;default&#039;&#039;&#039;}} runlevel is assumed, so it does not need to be stated explicitly:&lt;br /&gt;
{{cmd|$ doas rc-update add {{ic|ServiceName}}}}&lt;br /&gt;
{{cmd|$ doas rc-update del {{ic|ServiceName}}}}&lt;br /&gt;
&lt;br /&gt;
List the current status of all services; to display the status of all &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{cmd|$ rc-status}}&lt;br /&gt;
List the assigned runlevels of all services; to display the runlevels of &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{cmd|$ rc-update}}&lt;br /&gt;
&lt;br /&gt;
Refer to the [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user guide] for more detailed information.&lt;br /&gt;
&lt;br /&gt;
== Cgroups ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports [https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html cgroups v2] in the default configuration. To enable hybrid cgroups, edit the file {{Path|/etc/rc.conf}} and change the setting for {{ic|rc_cgroup_mode}} as follows:{{Cat|/etc/rc.conf|rc_cgroup_mode{{=}}&amp;quot;hybrid&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Then, one should run {{Cmd|# rc-service cgroups start}}&lt;br /&gt;
to take effect and {{Cmd|# rc-update add cgroups}}&lt;br /&gt;
to auto mount the cgroup filesystem on boot.&lt;br /&gt;
&lt;br /&gt;
== Local service ==&lt;br /&gt;
&lt;br /&gt;
Use the {{Path|/etc/local.d/}} directory to place programs or scripts which are to be run when the {{ic|local}} service is started or stopped.&lt;br /&gt;
&lt;br /&gt;
If a file in this directory is executable and it has a .start extension, it will be run when the local service is started. If a file is executable and it has a .stop extension, it will be run when the local service is stopped. For more info refer [https://github.com/OpenRC/openrc/blob/master/local.d/README README]&lt;br /&gt;
&lt;br /&gt;
To enable the {{ic|local}} service, issue the command:{{Cmd|# rc-update add local}}&lt;br /&gt;
&lt;br /&gt;
== Preventing slow services from delaying system startup ==&lt;br /&gt;
&lt;br /&gt;
Services that take a while to start will block the boot process until they complete. E.g.: {{ic|iwd}},{{ic|networking}},{{ic|chrony}} etc... might delay startup of an interactive system rather than start in the background. &lt;br /&gt;
&lt;br /&gt;
=== Parallel services === &lt;br /&gt;
&lt;br /&gt;
If the setting {{Codeline|rc_parallel{{=}}&amp;quot;YES&amp;quot;}} is configured, the OpenRC system tries to start services in parallel for a slight speed improvement. &lt;br /&gt;
This setting however comes with a message from openRC developers:{{Warning|whilst we have improved parallel, it can still potentially lock the boot process. Don&#039;t file bugs about this.}} &lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevel method === &lt;br /&gt;
&lt;br /&gt;
Slow services can also be [https://ptrcnull.me/posts/openrc-async-services.html started after login prompt] using [[#Stacked runlevels|stacked runlevels]]. &lt;br /&gt;
{{Warning|Editing the file {{Path|&#039;&#039;&#039;/etc/inittab&#039;&#039;&#039;}} wrongly will render the system unusable. Take backup and learn to restore it using rescue disk before proceeding.}}&lt;br /&gt;
&lt;br /&gt;
# Create a custom runlevel &#039;&#039;&#039;async&#039;&#039;&#039;:  {{Cmd|# mkdir /etc/runlevels/async}}&lt;br /&gt;
# Add &#039;&#039;&#039;default&#039;&#039;&#039; as a stacked runlevel {{Cmd|# rc-update add -s default async}}&lt;br /&gt;
# Remove slow service from &#039;&#039;&#039;default&#039;&#039;&#039; runlevel and add them to the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel:{{Cmd|&amp;lt;nowiki&amp;gt;# rc-update del &amp;lt;servicename&amp;gt; default&lt;br /&gt;
# rc-update add &amp;lt;servicename&amp;gt; async &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# Enable the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel by adding the line &#039;&#039;&#039;::once:/sbin/openrc async&#039;&#039;&#039; to {{Path|/etc/inittab}} file as follows: {{Cat|/etc/inittab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
::wait:/sbin/openrc default&lt;br /&gt;
::once:/sbin/openrc async -q&lt;br /&gt;
&lt;br /&gt;
# Set up a couple of getty&#039;s&lt;br /&gt;
tty1::respawn:/sbin/getty 38400 tty1&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
After rebooting, services from &#039;&#039;&#039;async&#039;&#039;&#039; will start separately. Other services started in &#039;&#039;&#039;default&#039;&#039;&#039; runlevel may still block [[TTY_Autologin|agetty]] from running, due to the {{ic|wait}} label.&lt;br /&gt;
&lt;br /&gt;
== User services ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports managing services for users. User services are currently experimental and available from [[Release_Notes_for_Alpine_3.22.0#OpenRC_User_services|v3.22]]. Here is the [https://pkgs.alpinelinux.org/contents?file=*&amp;amp;path=%2Fetc%2Fuser%2Finit.d&amp;amp;name=&amp;amp;branch=edge&amp;amp;repo=&amp;amp;arch=x86_64 list of OpenRC User services] available currently.&lt;br /&gt;
&lt;br /&gt;
Such services are said to be running in &#039;&#039;user mode&#039;&#039; and are managed with usual OpenRC commands using the  &#039;&#039;&#039;-U&#039;&#039;&#039; option (as distinct from the &#039;&#039;-u&#039;&#039; option), and without &#039;&#039;&#039;doas&#039;&#039;&#039; (nor as root).  &lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
* [[XDG_RUNTIME_DIR]] variable must be set &lt;br /&gt;
&lt;br /&gt;
=== Config files for user services ===&lt;br /&gt;
&lt;br /&gt;
OpenRC uses {{path|$XDG_CONFIG_HOME/rc}} for its user service configuration. If &amp;lt;code&amp;gt;$XDG_CONFIG_HOME&amp;lt;/code&amp;gt; is unset, the fallback {{path|~/.config}} is used.&lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC User services is {{path|~/.config/rc/rc.conf}}.&lt;br /&gt;
&lt;br /&gt;
==== Runlevels ====&lt;br /&gt;
&lt;br /&gt;
Runlevels are represented by directories in {{path|$XDG_CONFIG_HOME/rc/runlevels}}. The default runlevel is &amp;lt;code&amp;gt;sysinit&amp;lt;/code&amp;gt; and needs to be created explicitly in order to be enabled:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p ${XDG_CONFIG_HOME:-~/.config}/rc/runlevels/sysinit&lt;br /&gt;
&lt;br /&gt;
To start the default runlevel (&amp;lt;code&amp;gt;sysinit&amp;lt;/code&amp;gt;), use:&lt;br /&gt;
&lt;br /&gt;
 openrc -U&lt;br /&gt;
&lt;br /&gt;
To start another runlevel, use:&lt;br /&gt;
&lt;br /&gt;
 openrc -U $RUNLEVEL&lt;br /&gt;
&lt;br /&gt;
Add the above line to &amp;lt;code&amp;gt;~/.profile&amp;lt;/code&amp;gt; to automatically start the runlevel after logging in.&lt;br /&gt;
&lt;br /&gt;
If automatic start-up of a runlevel needs to be enforced by the system administrator, see [[#PAM support|PAM support]] below.&lt;br /&gt;
&lt;br /&gt;
==== Services ====&lt;br /&gt;
&lt;br /&gt;
The service scripts for each OpenRC user service provided as part of official packages can be found at {{Path|/etc/user/init.d/}} and their respective service configuration files at {{Path|/etc/user/conf.d/}}. &lt;br /&gt;
&lt;br /&gt;
The folders {{path|~/.config/rc/init.d/}} and {{path|~/.config/rc/conf.d/}} can have user customized service scripts for User services and their respective configuration files. These scripts override official files at {{Path|/etc/user/}}, if their service names match.&lt;br /&gt;
&lt;br /&gt;
=== Configure environment variables ===&lt;br /&gt;
&lt;br /&gt;
==== For Wayland ====&lt;br /&gt;
{{Tip|User services like {{pkg|wlsunset}} depend on the {{ic|$WAYLAND_DISPLAY}} environment variable. Hence, it is [https://gitlab.alpinelinux.org/alpine/aports/-/issues/17375#note_530383 recommended] to use &#039;&#039;&#039;gui&#039;&#039;&#039; runlevel for such services. Even though [[PipeWire]] can run at &#039;&#039;&#039;default&#039;&#039;&#039; runlevel, ensure that all your User services can run at the chosen runlevel.}} &lt;br /&gt;
* Allow propagation of the {{ic|$WAYLAND_DISPLAY}} and associated environment variables by adding the following lines to file {{path|~/.config/rc/rc.conf}} as follows:{{Cat|~/.config/rc/rc.conf|&amp;lt;nowiki&amp;gt;rc_env_allow=&amp;quot;WAYLAND_DISPLAY&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* Create a custom &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel:{{Cmd|$ mkdir -p ~/.config/rc/runlevels/gui}}&lt;br /&gt;
* To start &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel, add the line {{ic|openrc -U gui}} to the startup file of your compositor. For eg, for [[Sway]] add:{{Cat|~/.config/sway/config|...&lt;br /&gt;
exec openrc -U gui}}&lt;br /&gt;
&lt;br /&gt;
==== For Xorg ====&lt;br /&gt;
&lt;br /&gt;
If [[Elogind]] is not used, ensure that [[Wayland#Creating_and_exporting_XDG_RUNTIME_DIR_manually|XDG_RUNTIME_DIR]] is set manually in {{path|~/.xinitrc}}. For eg, for [[dwm]] add:{{Cat|~/.xinitrc|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
if [ -z &amp;quot;$XDG_RUNTIME_DIR&amp;quot; ]; then&lt;br /&gt;
	XDG_RUNTIME_DIR=&amp;quot;/tmp/$(id -u)-runtime-dir&amp;quot;&lt;br /&gt;
	mkdir -pm 0700 &amp;quot;$XDG_RUNTIME_DIR&amp;quot;&lt;br /&gt;
	export XDG_RUNTIME_DIR&lt;br /&gt;
fi&lt;br /&gt;
openrc -U default&lt;br /&gt;
exec dwm&amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
&lt;br /&gt;
{{Note|For both the above cases, logout and login for the OpenRC user services to be started, before proceeding further.}}&lt;br /&gt;
&lt;br /&gt;
=== User service management ===&lt;br /&gt;
&lt;br /&gt;
Issue the command {{ic|$ rc-status -Ur}} to view and verify the current user runlevel as &#039;&#039;&#039;gui&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; for Wayland and Xorg, respectively, before proceeding. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|ServiceName}} user service, issue the command:{{Cmd|$ rc-service -U {{ic|ServiceName}} start}}&lt;br /&gt;
Verify that the above OpenRC user service is started before proceeding further: {{Cmd|$ rc-status -U}} &lt;br /&gt;
To enable {{ic|ServiceName}} user service, issue the command: {{Cmd|$ rc-update -U add ServiceName}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|Once a user service is configured, to prevent duplicate instance, remove them from {{Path|/etc/xdg/autostart}} folder or from the startup/config file.}}&lt;br /&gt;
&lt;br /&gt;
=== PAM support ===&lt;br /&gt;
&lt;br /&gt;
The default installation of OpenRC user services in Alpine Linux is without PAM support.&lt;br /&gt;
&lt;br /&gt;
In scenarios where services should not be allowed to [https://wiki.gentoo.org/wiki/OpenRC#lingering linger] on logout, PAM support for OpenRC user services can be enabled by installing the {{pkg|openrc-user-pam}} package.{{Cmd|# apk add {{pkg|openrc-user-pam}}}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Whenever a openRC service fails to run, troubleshoot by enabling a debugging option, and then run the command. &lt;br /&gt;
&lt;br /&gt;
For example, if running the command {{ic|rc-service greetd start}} causes the [[Greetd|greetd]] service to immediately crash, then alter the command to enable debug and to view its output:{{Cmd|# rc-service -d greetd restart}}&lt;br /&gt;
&lt;br /&gt;
=== XDG_RUNTIME_DIR unset ===&lt;br /&gt;
&lt;br /&gt;
While configuring [[#User services|user services]], running the command {{ic|$ doas rc-update add -U pipewire gui}} will generate the above error {{ic|XDG_RUNTIME_DIR unset}}.  Always issue the command as normal user {{ic|$ rc-update add -U pipewire gui}} and do NOT use {{ic|doas}}. &lt;br /&gt;
&lt;br /&gt;
=== ERROR: user.greetd failed to start ===&lt;br /&gt;
&lt;br /&gt;
While using [[#User services|user services]] with [[greetd]], the above error message will appear. This failed error message for {{ic|user.greetd}} service is harmless as per {{MR|81612#note_492385}}.&lt;br /&gt;
&lt;br /&gt;
=== failed to create display ===&lt;br /&gt;
&lt;br /&gt;
When using openRC user services for {{ic|wlsunset}}, the following  error message may appear:{{Cmd|daemon.err wlsunset: failed to create display}}You will need the GUI runlevel for services that depend on {{ic|$WAYLAND_DISPLAY}}. Refer [[#For Wayland| Configure environment variables For Wayland]] section.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Writing Init Scripts]]&lt;br /&gt;
* [[Multiple Instances of Services]]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user Guide]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md OpenRC Service Script Writing Guide]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/OpenRC Gentoo Wiki]&lt;br /&gt;
* [https://wiki.archlinux.org/title/OpenRC ArchWiki]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/OpenRC PostmarketOS Wiki]&lt;br /&gt;
* [https://ptrcnull.me/posts/openrc-async-services.html Start services after login prompt]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]] &lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>StruanR</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Radeon_Video&amp;diff=30373</id>
		<title>Radeon Video</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Radeon_Video&amp;diff=30373"/>
		<updated>2025-07-09T22:45:37Z</updated>

		<summary type="html">&lt;p&gt;StruanR: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
The following instructions are for modern AMD GPU chipsets covered by the &amp;lt;code&amp;gt;radeon&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;amdgpu&amp;lt;/code&amp;gt; drivers.&lt;br /&gt;
&lt;br /&gt;
== Firmware ==&lt;br /&gt;
&lt;br /&gt;
For [https://en.wikipedia.org/wiki/List%20of%20AMD%20graphics%20processing%20units Vega and later], the {{Pkg|linux-firmware-amdgpu}} package is required. Otherwise, the {{Pkg|linux-firmware-radeon}} should be used.&lt;br /&gt;
&lt;br /&gt;
Programs using [https://www.vulkan.org/ Vulkan] may require the {{Pkg|mesa-vulkan-ati}} package to be installed.&lt;br /&gt;
&lt;br /&gt;
See [https://wiki.gentoo.org/wiki/AMDGPU the relevant section on the Gentoo Wiki] for a more granular list of product names and microarchitecture names.&lt;br /&gt;
&lt;br /&gt;
== Kernel Modesetting (KMS) ==&lt;br /&gt;
&lt;br /&gt;
To enable [[KMS]] at boot:&lt;br /&gt;
&lt;br /&gt;
# Run &amp;lt;code&amp;gt;lspci -k | grep amdgpu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lspci -k | grep radeon&amp;lt;/code&amp;gt; to find your module. For example it will return &amp;lt;code&amp;gt;Kernel driver in use: amdgpu&amp;lt;/code&amp;gt; for the &amp;lt;code&amp;gt;amdgpu&amp;lt;/code&amp;gt; module when running the first command.&lt;br /&gt;
# Add the &amp;lt;code&amp;gt;radeon&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;amdgpu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fbcon&amp;lt;/code&amp;gt; modules to {{Path|/etc/modules}}: {{Cmd|$ echo radeon &amp;gt;&amp;gt; /etc/modules&amp;lt;br /&amp;gt;$ echo fbcon &amp;gt;&amp;gt; /etc/modules}} or {{Cmd|$ echo amdgpu &amp;gt;&amp;gt; /etc/modules&amp;lt;br /&amp;gt;$ echo fbcon &amp;gt;&amp;gt; /etc/modules}}&lt;br /&gt;
# Install &amp;lt;code&amp;gt;mkinitfs&amp;lt;/code&amp;gt;: {{Cmd|apk add mkinitfs}}&lt;br /&gt;
# Enable the &amp;lt;code&amp;gt;kms&amp;lt;/code&amp;gt; feature in the &amp;lt;code&amp;gt;mkinitfs&amp;lt;/code&amp;gt; configuration by adding it to the &amp;lt;var&amp;gt;features&amp;lt;/var&amp;gt; variable, e.g., {{cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}&amp;quot;keymap cryptsetup kms ata base ide scsi usb virtio ext4&amp;quot;}}&lt;br /&gt;
# Run &amp;lt;code&amp;gt;mkinitfs&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Reboot to test the configuration.&lt;br /&gt;
&lt;br /&gt;
== Wayland ==&lt;br /&gt;
&lt;br /&gt;
Install the following packages as needed:&lt;br /&gt;
&lt;br /&gt;
* {{Pkg|mesa-dri-gallium}}: &#039;&#039;&#039;necessary&#039;&#039;&#039; Mesa drivers.&lt;br /&gt;
* {{Pkg|mesa-va-gallium}}: VA-API drivers, for hardware accelerated video encoding and decoding&lt;br /&gt;
&lt;br /&gt;
If driver auto-selection does not work, e.g. no mouse cursor under Sway, manual driver selection might be needed:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;export MESA_LOADER_DRIVER_OVERRIDE=r300&amp;lt;/code&amp;gt;: for AMD&#039;s Radeon R300, R400, and R500 GPUs.&lt;br /&gt;
* &amp;lt;code&amp;gt;export MESA_LOADER_DRIVER_OVERRIDE=r600&amp;lt;/code&amp;gt;: for AMD&#039;s Radeon R600 GPUs up to Northern Islands. Officially supported by AMD.&lt;br /&gt;
* &amp;lt;code&amp;gt;export MESA_LOADER_DRIVER_OVERRIDE=radeonsi&amp;lt;/code&amp;gt;: for AMD&#039;s Southern Island GPUs and later. Officially supported by AMD.&lt;br /&gt;
&lt;br /&gt;
For VA-API:&lt;br /&gt;
* &amp;lt;code&amp;gt;export LIBVA_DRIVER_NAME=r600&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;export LIBVA_DRIVER_NAME=radeonsi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Xorg ==&lt;br /&gt;
{{Main|Xorg}}&lt;br /&gt;
Install either the Free Software driver {{Pkg|xf86-video-ati}} or the proprietary amdgpu firmware {{Pkg|linux-firmware-amdgpu}}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;modprobe fbcon&amp;lt;/code&amp;gt; might be needed to avoid black screen when leaving Xorg.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/AMDGPU AMDGPU - ArchWiki]&lt;br /&gt;
* [https://wiki.archlinux.org/title/ATI ATI - ArchWiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Drivers]]&lt;br /&gt;
[[Category:Graphics]]&lt;/div&gt;</summary>
		<author><name>StruanR</name></author>
	</entry>
</feed>