Difference between revisions of "OpenRC"

From ArchWiki
Jump to: navigation, search
(Disabling IPv6 doesn't work)
m (Alad moved page Init/OpenRC to OpenRC over a redirect without leaving a redirect: move back to original location, Category:Init)
 
(335 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Category:Boot process]]
+
[[Category:Init]]
{{Note|Arch uses [[systemd]] by default. If you use OpenRC, please mention so while asking for help.}}
+
[[ja:OpenRC]]
 +
[[ru:OpenRC]]
 +
{{Related articles start}}
 +
{{Related|init}}
 +
{{Related articles end}}
 +
{{Warning|Arch Linux only has official support for [[systemd]]. When using OpenRC, please mention so in support requests.}}
  
OpenRC is an init system maintained by the Gentoo developers. OpenRC is a dependency based init system that works with the system provided init program, normally sysvinit. It is not a replacement for sysvinit.
+
[https://wiki.gentoo.org/wiki/OpenRC OpenRC] is a service manager maintained by the Gentoo developers. OpenRC is dependency based and works with the system provided init program, normally [[SysVinit]].
  
 
== Installation ==
 
== Installation ==
  
OpenRC is available in the [[AUR]]. You can choose to install either {{AUR|openrc}} or {{AUR|openrc-git}} package. You will also need to install {{AUR|openrc-arch-services-git}} (provides service files for use with openrc on arch) and {{AUR|openrc-sysvinit}} (a slightly patched version of traditional sysvinit). For the sake of compatibility with initscripts,  {{AUR|openrc-sysvinit}} installs the sysvinit init binary as {{ic|/sbin/init-openrc}}.
+
{{Accuracy|{{AUR|openrc-sysvinit}} removes {{Pkg|systemd-sysvcompat}}}}
  
The packages will be installed under {{Ic|/etc/openrc}} instead of the default location of {{Ic|/etc}}, so that users can switch to [[initscripts]] or [[systemd]] when desired.
+
OpenRC and accompanying packages are available in the [[AUR]]. For details on init components, see [[Init]].
 +
 
 +
Install either the {{AUR|openrc}} or {{AUR|openrc-git}} package. {{AUR|openrc-sysvinit}} or {{Pkg|busybox}} are used as the init process. Service files are available from the {{AUR|openrc-arch-services-git}} package.
 +
 
 +
To maintain compability with {{AUR|initscripts-fork}}, configuration files are installed to {{ic|'''/etc/openrc/'''}}. The sysvinit init binary is installed to {{ic|/usr/bin/init-openrc}} for compability with {{Pkg|systemd-sysvcompat}} or similar packages.
 +
 
 +
=== Booting ===
 +
 
 +
For booting with OpenRC add {{Ic|1=init=/usr/bin/init-openrc}} to the [[kernel parameters]]. To switch back to systemd, remove the parameter again.
 +
 
 +
The {{Ic|1=/etc/openrc/conf.d}} directory, and the {{Ic|1=/etc/openrc/rc.d}} file is used for configuration.
  
 
== Configuration ==
 
== Configuration ==
  
For booting with OpenRC add {{Ic|1=init=/sbin/init-openrc}} to the kernel line in your bootloader configuration. If you want to switch back to systemd, change it to {{ic|1=init=/usr/lib/systemd/systemd}}.
+
For general information on configuring OpenRC, see:
 +
 
 +
* [http://www.calculate-linux.org/main/en/openrc_manuals OpenRC manuals]
 +
* [http://www.gentoo.org/doc/en/openrc-migration.xml OpenRC migration]
 +
* [http://wiki.gentoo.org/wiki/OpenRC gentoo wiki].  
  
For detailed instructions on configuring OpenRC, read the [http://www.calculate-linux.org/main/en/openrc_manuals man pages], visit the [http://www.gentoo.org/doc/en/openrc-migration.xml gentoo guide] and the [http://wiki.gentoo.org/wiki/OpenRC gentoo wiki].
+
For instructions when migrating from [[systemd]], see [[Init#Configuration]].
  
It is worth noting that the udev service is not enabled by default. In order to enable it, do:
+
=== Services ===
  
# rc-update add udev sysinit
+
OpenRC services are enabled by issuing {{ic|rc-update add ''service_name'' ''runlevel''}} as root. It is recommended to at least enable the following services:
 +
{| class="wikitable"
 +
! Service name
 +
! [https://wiki.gentoo.org/wiki/OpenRC#Named_runlevels Runlevel]
 +
! Description
 +
|-
 +
| udev
 +
| sysinit
 +
| Device hot-plugging
 +
|-
 +
| alsa
 +
| default
 +
| [[ALSA]] state
 +
|-
 +
| acpid
 +
| default
 +
| ACPI events
 +
|-
 +
| dbus
 +
| default
 +
| Messaging bus
 +
|-
 +
| dcron
 +
| default
 +
| Scheduling
 +
|-
 +
| syslog-ng
 +
| default
 +
| System logs
 +
|}
 +
 
 +
See also [https://wiki.gentoo.org/wiki/Systemd#Native_services Native services] and [[Daemons]].
  
 
=== Network ===
 
=== Network ===
  
There are multiple ways to get a network up and running. One way is by configuring the {{ic|/etc/openrc/conf.d/network}} file. Both the {{ic|ip}} ({{Pkg|iproute2}}) and the {{ic|ifconfig}} ({{Pkg|net-tools}}) commands are supported.  
+
The network is configured through {{ic|newnet}}. [https://github.com/funtoo/openrc/blob/master/README.newnet] Modify the {{ic|/etc/openrc/conf.d/network}} file; both the {{ic|ip}} ({{Pkg|iproute2}}) and the {{ic|ifconfig}} ({{Pkg|net-tools}}) commands are supported. Below is an example configuration using {{ic|ip}}.
 
 
Below is an example configuration using {{ic|ip}}.
 
  
 
{{bc|
 
{{bc|
 
<nowiki>ip_eth0="192.168.1.2/24"
 
<nowiki>ip_eth0="192.168.1.2/24"
 
defaultiproute="via 192.168.1.1"
 
defaultiproute="via 192.168.1.1"
ifup_eth0="ip link set \$int mtu 1500"</nowiki>}}
+
ifup_eth0="ip link set \$int mtu 1500"
 +
</nowiki>}}
 +
 
 +
The network service is added to the boot runlevel by default, so no further action is required. See [[Network configuration]] for general networking information.
 +
 
 +
{{Note|1=You may also use [[NetworkManager]], [[dhcpcd]] or {{AUR|netcfg}} by enabling the respective services. ''netcfg'' mimics the [[netctl]] behaviour (see [https://bbs.archlinux.org/viewtopic.php?pid=1489283#p1489283] if you want to enable profiles connection on booting - requires {{ic|wpa_actiond}}). See [https://www.archlinux.org/netcfg/features.html netcfg features].}}
 +
 
 +
=== Boot logs ===
  
The network service is added to the boot runlevel by default, so no further action is required.
+
To enable boot logging, uncomment the {{ic|1=rc_logger="YES"}} line in {{ic|/etc/openrc/rc.conf}}. When enabled, boot logs are stored in {{ic|/var/log/rc.log}}.
  
You can also use [[NetworkManager]], [[Dhcpcd]] or {{AUR|netcfg}} by enabling the respective services.
+
=== Hostname ===
  
Take a look at [[Network Configuration]] for a detailed look at networking in general.
+
OpenRC sets the hostname from {{ic|/etc/openrc/conf.d/hostname}}. The file looks as follows:
  
=== Logging ===
+
{{bc|# Set to the hostname of this machine
 +
hostname<nowiki>=</nowiki>"myhostname"}}
  
====syslog-ng====
+
=== Kernel modules ===
If you use syslog-ng, comment out the following line in {{ic|/etc/syslog-ng/syslog-ng.conf}}:
 
{{bc|unix-dgram("/run/systemd/journal/syslog")}}
 
and add this line instead: {{bc|unix-dgram("/dev/log");}}
 
{{Note|Without making this change syslog-ng will fail to run and as a result nothing will be logged!}}
 
  
====Boot logging====
+
OpenRC uses {{ic|/etc/openrc/conf.d/modules}} instead of {{ic|/etc/modules-load.d}}. For example:
OpenRC's boot logging is disabled by default. To enable it, uncomment the following line in {{ic|/etc/openrc/rc.conf}}:
 
{{bc|<nowiki>#rc_logger="YES"</nowiki>}}
 
  
=== Hostname ===
+
{{hc|/etc/openrc/conf.d/modules|2=
OpenRC sets the hostname from {{ic|/etc/openrc/conf.d/hostname}}.
+
# You should consult your kernel documentation and configuration
 +
# for a list of modules and their options.
  
Here is an example file:
+
modules="vboxdrv acpi_cpufreq"
{{hc|/etc/openrc/conf.d/hostname|
 
<nowiki>hostname="myhostname"</nowiki>
 
 
}}
 
}}
  
=== Module autoloading ===
+
=== Locale ===
OpenRC doesn't use /etc/modules-load.d/ folder, instead it uses {{ic|/etc/openrc/conf.d/modules}}.
+
 
 +
Keyboard layout can be configured via {{ic|/etc/openrc/conf.d/keymaps}} and {{ic|/etc/openrc/conf.d/consolefont}}. You can also configure the settings through the {{ic|/etc/locale.conf}} file, which is sourced via {{ic|/etc/profile.d/locale.sh}}.
 +
 
 +
See [http://wiki.gentoo.org/wiki/Localization/HOWTO#Keyboard_layout_for_the_console] and [[Locale]] for details.
  
add a line like this to that file :
+
== Usage ==
{{bc|<nowiki>modules=acpi_cpufreq</nowiki>}}
 
  
=== Locale ===
+
This section draws a parallel between [[systemd]] and other [[init]] systems.
 +
 
 +
You can omit the {{ic|.service}} and {{ic|.target}} extensions, especially if temporarily editing the [[kernel parameters]].
 +
 
 +
{| class="wikitable" width="100%"
 +
! systemd !! SysVinit !! OpenRC !! Description
 +
|-
 +
| {{ic|systemctl list-units}} || {{ic|rc.d list}} || {{ic|rc-status}} || List running services status
 +
|-
 +
| {{ic|systemctl --failed}} || || {{ic|rc-status --crashed}} || Check failed services
 +
|-
 +
| {{ic|systemctl --all}} || || {{ic|rc-update -v show}} || Display all available services.
 +
|-
 +
| {{ic|systemctl (start, stop, restart, status) daemon.service}} || {{ic|rc.d (start, stop, restart) daemon}} || {{ic|rc-service (start, stop, restart, status) daemon}} || Change service state.
 +
|-
 +
| {{ic|systemctl (enable, disable) daemon.service}} || {{ic|chkconfig daemon (on, off)}} || {{ic|rc-update (add, del) daemon}} || Turn service on or off.
 +
|-
 +
| {{ic|systemctl daemon-reload}} || {{ic|chkconfig daemon --add}} || || Create or modify configuration.
 +
|}
 +
 
 +
== Tips and tricks ==
  
There is no built-in support for configuring locales in OpenRC. Though, you can configure the settings through the {{ic|/etc/locale.conf}} file, which is sourced via {{ic|/etc/profile.d/locale.sh}}.
+
=== Quiet booting ===
  
For details on configuring the locale, take a look [[Locale | here]].
+
To hide boot messages from OpenRC, you can edit {{ic|/etc/inittab}} and add {{ic|--quiet}} to every openrc command. For further information check with {{ic|$ openrc -h}}.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 78: Line 149:
 
* in use but fuser finds nothing [ !! ]}}
 
* in use but fuser finds nothing [ !! ]}}
  
This can be fixed by adding  
+
This can be fixed by adding
 +
 
 
  no_umounts="/tmp"
 
  no_umounts="/tmp"
  
Line 85: Line 157:
 
{{Note|This problem occurs only if your tmp is mounted as a tmpfs.}}
 
{{Note|This problem occurs only if your tmp is mounted as a tmpfs.}}
  
=== Disabling IPv6 doesn't work ===
+
=== Disabling IPv6 does not work ===
  
If you have OpenRC installed under the {{Ic|/etc/openrc}} sysconf directory.
+
One option is to add:
  
One fix for this is to put
 
 
  # Disable ipv6
 
  # Disable ipv6
 
  net.ipv6.conf.all.disable_ipv6 = 1
 
  net.ipv6.conf.all.disable_ipv6 = 1
in a file (with a .conf extension) under {{Ic|/etc/openrc/sysctl.d}}
+
 
 +
in a file with a {{ic|.conf}} extension under {{ic|/etc/openrc/sysctl.d}}
  
 
=== During shutdown remounting root as read-only fails ===
 
=== During shutdown remounting root as read-only fails ===
  
 
If the above happens, edit the {{ic|/etc/openrc/init.d/mount-ro}} file and put:
 
If the above happens, edit the {{ic|/etc/openrc/init.d/mount-ro}} file and put:
 +
 
  telinit u
 
  telinit u
  
 
after the following line:
 
after the following line:
 +
 
  # Flush all pending disk writes now
 
  # Flush all pending disk writes now
 
  sync; sync
 
  sync; sync
  
== External Links ==
+
=== /etc/sysctl.conf not found ===
 +
 
 +
By default, {{ic|sysctl --system}} is called to load the sysctl configuration. [https://github.com/OpenRC/openrc/blob/master/init.d/sysctl.Linux.in#L17] This includes the {{ic|/etc/sysctl.conf}} file, which was removed from Arch. [https://www.archlinux.org/news/deprecation-of-etcsysctlconf/]
 +
 
 +
To prevent a missing file error, create the file:
 +
 
 +
# touch /etc/sysctl.conf
 +
 
 +
=== opentmpfiles-setup failed to start ===
 +
 
 +
On booting openrc you may see lines like these :
 +
 
 +
* Setting up tmpfiles.d entries ...
 +
chattr: Operation not supported while setting flags on /var/log/journal
 +
chattr: No such file or directory while trying to stat /var/log/journal/%m
 +
chattr: Operation not supported while setting flags on /var/log/journal/remote
 +
[ !! ]
 +
ERROR: opentmpfiles-setup failed to start
 +
 
 +
This is caused by {{ic|/usr/lib/tmpfiles.d/journal-nocow.conf}} using options that are only valid if journal is on a btrfs filesystem.
 +
 
 +
See https://github.com/OpenRC/opentmpfiles/issues/2 for details
 +
 
 +
A workaround is to create an empty /etc/tmpfiles.d/journal-nocow.conf to override the settings.
 +
 
 +
== Using OpenRC with a desktop environment ==
 +
 
 +
If using ''OpenRC'' with a [[desktop environment]], ConsoleKit may help. Install the [https://gist.github.com/ad73f9087f39d7cadd8e service] to {{ic|/etc/openrc/init.d}}, and enable it:
 +
 
 +
# rc-update add consolekit default
 +
 
 +
See [[ConsoleKit]] for more information.
 +
 
 +
== See also ==
 +
 
 
* [[Wikipedia:OpenRC]]
 
* [[Wikipedia:OpenRC]]
 +
* [https://wiki.gentoo.org/wiki/OpenRC Gentoo wiki]
 
* [https://bbs.archlinux.org/viewtopic.php?id=152606 Forum thread about OpenRC in Arch]
 
* [https://bbs.archlinux.org/viewtopic.php?id=152606 Forum thread about OpenRC in Arch]
 +
* [http://blog.notfoss.com/posts/openrc-on-arch-linux/ Blog: OpenRC on Arch Linux]
 +
* [https://wiki.manjaro.org/index.php?title=OpenRC,_an_alternative_to_systemd Manjaro wiki]

Latest revision as of 11:35, 21 July 2017

Related articles

Warning: Arch Linux only has official support for systemd. When using OpenRC, please mention so in support requests.

OpenRC is a service manager maintained by the Gentoo developers. OpenRC is dependency based and works with the system provided init program, normally SysVinit.

Installation

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: openrc-sysvinitAUR removes systemd-sysvcompat (Discuss in Talk:OpenRC#)

OpenRC and accompanying packages are available in the AUR. For details on init components, see Init.

Install either the openrcAUR or openrc-gitAUR package. openrc-sysvinitAUR or busybox are used as the init process. Service files are available from the openrc-arch-services-gitAUR package.

To maintain compability with initscripts-forkAUR, configuration files are installed to /etc/openrc/. The sysvinit init binary is installed to /usr/bin/init-openrc for compability with systemd-sysvcompat or similar packages.

Booting

For booting with OpenRC add init=/usr/bin/init-openrc to the kernel parameters. To switch back to systemd, remove the parameter again.

The /etc/openrc/conf.d directory, and the /etc/openrc/rc.d file is used for configuration.

Configuration

For general information on configuring OpenRC, see:

For instructions when migrating from systemd, see Init#Configuration.

Services

OpenRC services are enabled by issuing rc-update add service_name runlevel as root. It is recommended to at least enable the following services:

Service name Runlevel Description
udev sysinit Device hot-plugging
alsa default ALSA state
acpid default ACPI events
dbus default Messaging bus
dcron default Scheduling
syslog-ng default System logs

See also Native services and Daemons.

Network

The network is configured through newnet. [1] Modify the /etc/openrc/conf.d/network file; both the ip (iproute2) and the ifconfig (net-tools) commands are supported. Below is an example configuration using ip.

ip_eth0="192.168.1.2/24"
defaultiproute="via 192.168.1.1"
ifup_eth0="ip link set \$int mtu 1500"

The network service is added to the boot runlevel by default, so no further action is required. See Network configuration for general networking information.

Note: You may also use NetworkManager, dhcpcd or netcfgAUR by enabling the respective services. netcfg mimics the netctl behaviour (see [2] if you want to enable profiles connection on booting - requires wpa_actiond). See netcfg features.

Boot logs

To enable boot logging, uncomment the rc_logger="YES" line in /etc/openrc/rc.conf. When enabled, boot logs are stored in /var/log/rc.log.

Hostname

OpenRC sets the hostname from /etc/openrc/conf.d/hostname. The file looks as follows:

# Set to the hostname of this machine
hostname="myhostname"

Kernel modules

OpenRC uses /etc/openrc/conf.d/modules instead of /etc/modules-load.d. For example:

/etc/openrc/conf.d/modules
# You should consult your kernel documentation and configuration
# for a list of modules and their options.

modules="vboxdrv acpi_cpufreq"

Locale

Keyboard layout can be configured via /etc/openrc/conf.d/keymaps and /etc/openrc/conf.d/consolefont. You can also configure the settings through the /etc/locale.conf file, which is sourced via /etc/profile.d/locale.sh.

See [3] and Locale for details.

Usage

This section draws a parallel between systemd and other init systems.

You can omit the .service and .target extensions, especially if temporarily editing the kernel parameters.

systemd SysVinit OpenRC Description
systemctl list-units rc.d list rc-status List running services status
systemctl --failed rc-status --crashed Check failed services
systemctl --all rc-update -v show Display all available services.
systemctl (start, stop, restart, status) daemon.service rc.d (start, stop, restart) daemon rc-service (start, stop, restart, status) daemon Change service state.
systemctl (enable, disable) daemon.service chkconfig daemon (on, off) rc-update (add, del) daemon Turn service on or off.
systemctl daemon-reload chkconfig daemon --add Create or modify configuration.

Tips and tricks

Quiet booting

To hide boot messages from OpenRC, you can edit /etc/inittab and add --quiet to every openrc command. For further information check with $ openrc -h.

Troubleshooting

Error while unmounting /tmp

When shutting the system down, you might get an error message such as

* Unmounting /tmp ... 
* in use but fuser finds nothing [ !! ]

This can be fixed by adding

no_umounts="/tmp"

to /etc/openrc/conf.d/localmount

Note: This problem occurs only if your tmp is mounted as a tmpfs.

Disabling IPv6 does not work

One option is to add:

# Disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1

in a file with a .conf extension under /etc/openrc/sysctl.d

During shutdown remounting root as read-only fails

If the above happens, edit the /etc/openrc/init.d/mount-ro file and put:

telinit u

after the following line:

# Flush all pending disk writes now
sync; sync

/etc/sysctl.conf not found

By default, sysctl --system is called to load the sysctl configuration. [4] This includes the /etc/sysctl.conf file, which was removed from Arch. [5]

To prevent a missing file error, create the file:

# touch /etc/sysctl.conf

opentmpfiles-setup failed to start

On booting openrc you may see lines like these :

* Setting up tmpfiles.d entries ...
chattr: Operation not supported while setting flags on /var/log/journal
chattr: No such file or directory while trying to stat /var/log/journal/%m
chattr: Operation not supported while setting flags on /var/log/journal/remote
[ !! ]
ERROR: opentmpfiles-setup failed to start

This is caused by /usr/lib/tmpfiles.d/journal-nocow.conf using options that are only valid if journal is on a btrfs filesystem.

See https://github.com/OpenRC/opentmpfiles/issues/2 for details

A workaround is to create an empty /etc/tmpfiles.d/journal-nocow.conf to override the settings.

Using OpenRC with a desktop environment

If using OpenRC with a desktop environment, ConsoleKit may help. Install the service to /etc/openrc/init.d, and enable it:

# rc-update add consolekit default

See ConsoleKit for more information.

See also