Difference between revisions of "OpenRC"

From ArchWiki
Jump to: navigation, search
m (Network: netcfg redirects to netctl which works only with systemd)
m (Reverted edits by Xan (talk) to last revision by Alad)
 
(320 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
[[Category:Boot process]]
 
[[Category:Boot process]]
{{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|eudev}}
 +
{{Related|init}}
 +
{{Related|init Rosetta}}
 +
{{Related|SysVinit}}
 +
{{Related articles end}}
 +
{{Warning|Arch Linux only has official support for [[systemd]]. When using OpenRC, please mention so in support requests.}}
  
OpenRC is an alternate init system developed by 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}}.
+
OpenRC and accompanying packages are available in the [[AUR]]. For details on init components, see [[Init]].
  
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.
+
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.
 +
 
 +
{{Accuracy|{{AUR|openrc-sysvinit}} removes {{Pkg|systemd-sysvcompat}}}}
 +
 
 +
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:
  
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].
+
* [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].  
  
It is worth noting that the udev service is not enabled by default. In order to enable it, do:
+
=== Preparation ===
  
# rc-update add udev sysinit
+
See [[Init#Configuration]].
  
=== Network ===
+
=== Services ===
  
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.
+
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
 +
|}
  
Below is an example configuration using {{ic|ip}}.
+
See also [https://wiki.gentoo.org/wiki/Systemd#Native_services Native services] and [[Daemons]].
 +
 
 +
=== Network ===
 +
 
 +
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}}.
  
 
{{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.
+
The network service is added to the boot runlevel by default, so no further action is required. See [[Network configuration]] for general networking information.
  
You can also use [[NetworkManager]], [[Dhcpcd]] or {{AUR|netcfg}} by enabling the respective services.
+
{{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}}). You could consult the [https://www.archlinux.org/netcfg/features.html official documentation] or [https://wiki.archlinux.org/index.php?title=Netcfg&oldid=243178 old wiki documentation] (be aware of consulting version later than [https://www.archlinux.org/news/netcfg-282-release/ 2012-05-13])}}
  
Take a look at [[Network Configuration]] for a detailed look at networking in general.
+
=== Boot logs ===
  
=== Logging ===
+
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}}.
  
====syslog-ng====
+
=== Hostname ===
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 sets the hostname from {{ic|/etc/openrc/conf.d/hostname}}. The file looks as follows:
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 ===
+
{{bc|# Set to the hostname of this machine
OpenRC sets the hostname from {{ic|/etc/openrc/conf.d/hostname}}.
+
hostname<nowiki>=</nowiki>"myhostname"}}
  
Here is an example file:
+
=== Kernel modules ===
{{hc|/etc/openrc/conf.d/hostname|
+
<nowiki>hostname="myhostname"</nowiki>
+
}}
+
  
=== Module autoloading ===
+
OpenRC uses {{ic|/etc/openrc/conf.d/modules}} instead of {{ic|/etc/modules-load.d}}. For example:
OpenRC doesn't use /etc/modules-load.d/ folder, instead it uses {{ic|/etc/openrc/conf.d/modules}}.
+
  
add a line like this to that file :
+
{{hc|/etc/openrc/conf.d/modules|2=
{{bc|<nowiki>modules=acpi_cpufreq</nowiki>}}
+
# You should consult your kernel documentation and configuration
 +
# for a list of modules and their options.
 +
 
 +
modules="vboxdrv acpi_cpufreq"
 +
}}
  
 
=== Locale ===
 
=== Locale ===
  
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}}.  
+
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}}.  
  
For details on configuring the locale, take a look [[Locale | here]].
+
See [http://wiki.gentoo.org/wiki/Localization/HOWTO#Keyboard_layout_for_the_console] and [[Locale]] for details.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 78: Line 126:
 
* 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 134:
 
{{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, and disabling IPv6 through {{Ic|/etc/sysctl.conf}} doesn't work.
+
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}}
 
  
== External Links ==
+
in a file with a {{ic|.conf}} extension under {{ic|/etc/openrc/sysctl.d}}
 +
 
 +
=== During shutdown remounting root as read-only fails ===
 +
 
 +
If the above happens, edit the {{ic|/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, {{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
 +
 
 +
== 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 16:49, 3 February 2016

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

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.

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#)

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:

Preparation

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). You could consult the official documentation or old wiki documentation (be aware of consulting version later than 2012-05-13)

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.

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

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