Difference between revisions of "OpenRC"

From ArchWiki
Jump to navigation Jump to search
(→‎artoo's way: Move unofficial repo in artoo's method)
Line 50: Line 50:
 
{{Deletion|This is completely out of scope for this article, and most important steps are already covered in [[Init]]. There's also the subjective steps, mandatory use of an unoffical repo, and poor writing style.}}
 
{{Deletion|This is completely out of scope for this article, and most important steps are already covered in [[Init]]. There's also the subjective steps, mandatory use of an unoffical repo, and poor writing style.}}
  
TL;DR: This is a step-by-step guide for a quick migration from systemd, which should be quite fail-safe. It follows the '''artoo's''' method. However, you are ''strongly advised'' to read the rest of the wiki page and make an educated decision on which method you should follow.
+
TL;DR: This is a step-by-step guide for a quick migration from systemd, which should be quite fail-safe. It follows the '''artoo's''' method. However, you are ''strongly advised'' to read the rest of the wiki page and make an educated decision on which method you should follow. Also, {{ic|eudev}} and {{ic|eudev-systemdcompat}} provide {{ic|udev}} and conflict with {{ic|systemd}} and {{ic|libsystemd}}, which will be removed. Read [[Init#Replacing_the_systemd_package]] and [[Eudev]] for more information.
 +
 
 +
Note: in the installation steps that follow, {{ic|pacman}} is used in conjunction with an unofficial repository. This is just for illustrating the procedure. You are expected to download the packages from the [[AUR]] and build them with {{ic|makepkg}}.
  
* Append the [https://wiki.archlinux.org/index.php/Unofficial_user_repositories#pfkernel unofficial <nowiki>[pfkernel]</nowiki> repository] to {{ic|/etc/pacman.conf}} and refresh the package database with {{ic|pacman -Sy}}
 
 
* Save a list of your running daemons:
 
* Save a list of your running daemons:
 
  systemctl list-units | grep service | grep running | awk '{print $1}' > daemons.list
 
  systemctl list-units | grep service | grep running | awk '{print $1}' > daemons.list
(Note: all commands below must be executed as root or with {{ic|sudo}}. Answer 'yes' to all '''pacman''' questions.)
+
* Install openrc and family: {{ic|pacman -Sdd openrc-core eudev eudev-openrc eudev-systemdcompat}}
* Remove systemd and family: {{ic|pacman -Rdd systemd libsystemd}}
+
You will be warned of conflicts with {{ic|systemd}} and {{ic|libsystemd}}; answer 'yes' to remove them. This will also pull {{ic|sysvinit}}.
* Install openrc and family: {{ic|pacman -S openrc-core eudev eudev-openrc eudev-systemdcompat}}
 
(This will also pull {{ic|sysvinit}}. {{ic|eudev-systemdcompat}} provides {{ic|systemd}} and {{ic|libsystemd}} dependencies for packages that are linked against systemd)
 
* Remove some systemd cruft: {{ic|for user in systemd-journal systemd-journal-gateway systemd-timesync systemd-network systemd-bus-proxy systemd-journal-remote systemd-journal-upload; do userdel $user; done}}
 
* Optional packages (mandatory for desktop users; do install): {{ic|pacman -S consolekit polkit-consolekit upower-pm-utils udisks2-nosystemd}}
 
 
* Install the openrc scripts for your daemons from the previous step: {{ic|pacman -S acpid-openrc alsa-utils-openrc autofs-openrc consolekit consolekit-openrc cronie-openrc dbus-openrc cups-openrc displaymanager-openrc fuse-openrc haveged-openrc hdparm-openrc openssh-openrc samba-openrc syslog-ng-openrc avahi-openrc}}  (edit accordingly)
 
* Install the openrc scripts for your daemons from the previous step: {{ic|pacman -S acpid-openrc alsa-utils-openrc autofs-openrc consolekit consolekit-openrc cronie-openrc dbus-openrc cups-openrc displaymanager-openrc fuse-openrc haveged-openrc hdparm-openrc openssh-openrc samba-openrc syslog-ng-openrc avahi-openrc}}  (edit accordingly)
 
To enable {{ic|sshd}}, run {{ic|rc-update add sshd default}}. Do this for each daemon you want.
 
To enable {{ic|sshd}}, run {{ic|rc-update add sshd default}}. Do this for each daemon you want.
* Edit {{ic|/etc/rc.conf}} to your liking and {{ic|/etc/conf.d/hostname}} to set your hostname. If you want to boot into X, edit /etc/conf.d/xdm and replace 'xdm' with your display manager (e.g. 'lxdm' or 'mdm') and run {{ic|rc-update add xdm default}}.
+
* Optional packages for desktop users session management: {{ic|pacman -S consolekit polkit-consolekit upower-pm-utils udisks2-nosystemd}}
* Add your users to the groups you want them having access to:
+
* Add your users to the groups you want them to have access to:
 
{{ic|usermod -a -G video,audio,power,disk,storage,optical,lp,scanner <USER>}}
 
{{ic|usermod -a -G video,audio,power,disk,storage,optical,lp,scanner <USER>}}
 
 
(USER can play video, audio, shutdown/reboot/hibernate, access non-system partitions, automount removable or non-persistent storage devices, burn DVDs, print and scan. You should check first which groups USER already belongs to: {{ic|id USER}}.
 
(USER can play video, audio, shutdown/reboot/hibernate, access non-system partitions, automount removable or non-persistent storage devices, burn DVDs, print and scan. You should check first which groups USER already belongs to: {{ic|id USER}}.
 
If you prefer to perform the installation from the [[AUR]] instead of the [pfkernel] repository, don't add the [pfkernel] repo to {{ic|/etc/pacman.conf}} and replace above {{ic|pacman -S}} commands with {{ic|yaourt -Sa}}. Since yaourt can't build packages as root anymore, you must run it as a regular user.
 
 
 
* You should now reboot. However, since '''systemd''' is no longer present, this is not possible from the command line. Run {{ic|sync}}, {{ic|sysctl kernel.sysrq<nowiki>=</nowiki>1}} and press {{ic|Alt-SysRq-S}}, {{ic|Alt-SysRq-U}} and {{ic|Alt-SysRq-B}} to reboot (in some machines reboot is not possible with the latter, so you must press {{ic|Alt-SysRq-O}} to poweroff). Your system should boot into the login prompt or load your display manager without problem.
 
* You should now reboot. However, since '''systemd''' is no longer present, this is not possible from the command line. Run {{ic|sync}}, {{ic|sysctl kernel.sysrq<nowiki>=</nowiki>1}} and press {{ic|Alt-SysRq-S}}, {{ic|Alt-SysRq-U}} and {{ic|Alt-SysRq-B}} to reboot (in some machines reboot is not possible with the latter, so you must press {{ic|Alt-SysRq-O}} to poweroff). Your system should boot into the login prompt or load your display manager without problem.
 
 
* Keep reading for additional configuration steps.
 
* Keep reading for additional configuration steps.
  

Revision as of 22:19, 6 March 2015

Note: Arch uses systemd by default. If you use OpenRC, please mention so while asking for help.

OpenRC is an rc system maintained by the Gentoo developers. OpenRC is dependency based and works with the system provided init program, normally sysvinit. It is not a replacement for sysvinit.

Installation

OpenRC and accompanying packages are available in the AUR.

apg's way

You can choose to install either openrcAUR or openrc-gitAUR. You will also need to install openrc-arch-services-gitAUR (provides service files for use with openrc on arch) and openrc-sysvinitAUR (a slightly patched version of traditional sysvinit). For the sake of compatibility with initscripts, openrc-sysvinitAUR installs the sysvinit init binary as /usr/bin/init-openrc.

The packages will be installed under /etc/openrc instead of the default location of /etc, so that users can switch to initscripts or systemd when desired.

artoo's way

Here you will need to install openrc-coreAUR and the packages in openrc-base.

Some other packages of note are displaymanager-openrcAUR and alsa-utils-openrcAUR (both grouped under the openrc-desktop group), and networkmanager-openrcAUR.

For the list of packages, look at the openrc packages maintained by artoo in the AUR.

A summary as well as the source for these package groups can be found at github.

Precompiled packages from the github sources are hosted in the unofficial [pfkernel] repository.

eudev can also be used as udev provider instead of systemd.

Difference between the approaches

apg's version:

  • uses a special directory /etc/openrc so that initscripts-forkAUR can be used instead of OpenRC.
  • uses newnet for network configuration.
  • follows a monolithic pattern, with one package that contains the base openrc system, and another containing the rc scripts

artoo's version:

  • uses the default /etc directory to maintain compatibility with the Gentoo version (thus initscripts-forkAUR cannot be used.).
  • uses netifrc for network (Gentoo default).
  • are split packages, which are greater in number, but allow more control in modifying the individual components.

Quick migration from systemd

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: This is completely out of scope for this article, and most important steps are already covered in Init. There's also the subjective steps, mandatory use of an unoffical repo, and poor writing style. (Discuss in Talk:OpenRC#)

TL;DR: This is a step-by-step guide for a quick migration from systemd, which should be quite fail-safe. It follows the artoo's method. However, you are strongly advised to read the rest of the wiki page and make an educated decision on which method you should follow. Also, eudev and eudev-systemdcompat provide udev and conflict with systemd and libsystemd, which will be removed. Read Init#Replacing_the_systemd_package and Eudev for more information.

Note: in the installation steps that follow, pacman is used in conjunction with an unofficial repository. This is just for illustrating the procedure. You are expected to download the packages from the AUR and build them with makepkg.

  • Save a list of your running daemons:
systemctl list-units | grep service | grep running | awk '{print $1}' > daemons.list
  • Install openrc and family: pacman -Sdd openrc-core eudev eudev-openrc eudev-systemdcompat

You will be warned of conflicts with systemd and libsystemd; answer 'yes' to remove them. This will also pull sysvinit.

  • Install the openrc scripts for your daemons from the previous step: pacman -S acpid-openrc alsa-utils-openrc autofs-openrc consolekit consolekit-openrc cronie-openrc dbus-openrc cups-openrc displaymanager-openrc fuse-openrc haveged-openrc hdparm-openrc openssh-openrc samba-openrc syslog-ng-openrc avahi-openrc (edit accordingly)

To enable sshd, run rc-update add sshd default. Do this for each daemon you want.

  • Optional packages for desktop users session management: pacman -S consolekit polkit-consolekit upower-pm-utils udisks2-nosystemd
  • Add your users to the groups you want them to have access to:

usermod -a -G video,audio,power,disk,storage,optical,lp,scanner <USER> (USER can play video, audio, shutdown/reboot/hibernate, access non-system partitions, automount removable or non-persistent storage devices, burn DVDs, print and scan. You should check first which groups USER already belongs to: id USER.

  • You should now reboot. However, since systemd is no longer present, this is not possible from the command line. Run sync, sysctl kernel.sysrq=1 and press Alt-SysRq-S, Alt-SysRq-U and Alt-SysRq-B to reboot (in some machines reboot is not possible with the latter, so you must press Alt-SysRq-O to poweroff). Your system should boot into the login prompt or load your display manager without problem.
  • Keep reading for additional configuration steps.

Post Installation

See Init#Troubleshooting.

Configuration

For more information on configuring OpenRC, man pages are available; you can also visit the gentoo guide and the gentoo wiki.

Booting

apg's way

For booting with OpenRC add init=/usr/bin/init-openrc to the kernel line in your bootloader configuration. If you want to switch back to systemd, change it to init=/usr/lib/systemd/systemd.

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

It is worth noting that the udev service is not enabled by default. In order to enable it, do:

# rc-update add udev sysinit

artoo's way

OpenRC is booted by default.

To boot with systemd, add init=/usr/lib/systemd/systemd to the kernel line in your bootloader configuration.

The files in the /etc/conf.d directory are used for configuration.

Here udev is enabled by default.

Network

See Network configuration for a detailed look at networking in general.

apg's way

There are multiple ways to get a network up and running. One way is by configuring 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.

You can also use NetworkManager, dhcpcd or netcfgAUR by enabling the respective services.

artoo's way

dhcpcd is enabled by default.

For network configuration, look at the /etc/conf.d/net file. By default it uses netifrc, which defaults to dhcpcd if not specified differently in /etc/conf.d/net

The dhcpcd-openrcAUR package provides a specific dhcpcd script, not to be confused with netifrc default. It will start /etc/init.d/dhcpcd

To use a static route you need to create a symlink of net.lo that reflects your device's name:

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0

See [1] for details.

For having a graphical network manager, networkmanager-openrcAUR can be installed. Other options are available, like connman via connman-openrcAUR.

Other option is netcfgAUR which mimetizes the netctl behaviour (see 1 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)

Logging

apg's way

See Init#Cron_functionality.

artoo's way

Different loggers are available, like syslog-ng-openrcAUR, metalog-openrcAUR, and rsyslog-openrcAUR. These loggers may conflict with each other, hence using only a single logger is recommended.

Boot logging

apg's way

OpenRC's boot logging is disabled by default. To enable it, uncomment the following line in /etc/openrc/rc.conf

#rc_logger="YES"

artoo's way

Boot logging is enabled by default. To disable it, comment out the rc_logger="YES" line in /etc/rc.conf

Tip: Boot logs are stored in /var/log/rc.log

Hostname

OpenRC sets the hostname from /etc/openrc/conf.d/hostname (apg's way) or /etc/conf.d/hostname (artoo's way).

It looks like the following:

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

Module autoloading

OpenRC does not use /etc/modules-load.d/ folder, instead it uses /etc/openrc/conf.d/modules (apg's way) or /etc/conf.d/modules (artoo's way).

It looks like the following:

# 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/conf.d/keymaps and /etc/conf.d/consolefont (artoo's way). You can also configure the settings through the /etc/locale.conf file, which is sourced via /etc/profile.d/locale.sh.

See [2] 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

If you have OpenRC installed under the /etc/openrc sysconf directory.

One fix for this is to put

# 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

Error about /etc/sysctl.conf not found

It can be created by running as root:

touch /etc/sysctl.conf

Using OpenRC with a Desktop Environment

If using OpenRC with a desktop environment, consolekit-openrcAUR and related consolekit packages in the AUR may help.

For more info on consolekit, have a look at the Gentoo wiki and the Manjaro wiki.

Xfce

The xfce4-session package has been compiled with logind support; xfce4-session-consolekitAUR from the AUR can be used.

For a login manager, lxdm-consolekitAUR (from the AUR), or lightdm (from the repos) could be used.

Mate

Install mate-session-manager-upowerAUR and mate-power-manager-upowerAUR from the AUR. If you use mdm-display-managerAUR as a login manager and have trouble logging in, edit /etc/pam.d/mdm, comment out session optional pam_systemd.so and restart mdm. Additionally append session optional pam_ck_connector.so nox11 if you have consolekitAUR installed.

KDE

The kdebase-workspace package needs to be recompiled for use with consolekit (kdebase-workspace-consolekitAUR is available from the AUR).

ALSA

You have to enable alsa: rc-update add alsasound default

Using OpenRC with eudev

With OpenRC being used as init system, the role of systemd is reduced to that of a udev provider, and for compatibility reasons.

eudev is a fork of udev started by the Gentoo project, with the goal of isolation from any particular flavor of system initialization, such as systemd or sysvinit.

Installation

Note: This method may not work with apg's packages.

eudevAUR is available in the AUR. It basically serves a drop-in replacement for the udev provided by systemd.

Three packages are needed in order to install eudev: eudev-systemdcompatAUR, eudevAUR, and eudev-openrcAUR.

The eudev-systemdcompat package conflicts with systemd and libsystemd, and requires the eudevAUR package. upower-pm-utilsAUR is an optional dependency.

Note: One may not be able to install the eudev packages directly from the AUR due to conflicts when installing; to circumvent it, eudevAUR (along with eudev-openrcAUR) can be built and added to a local repository, and then eudev-systemdcompatAUR can be built and installed from the AUR using:
makepkg -di
(-d to ignore build dependencies), which pulls in eudev as package dependency.

After that eudev-openrcAUR can be installed from the local repo created earlier.

upower-pm-utilsAUR can be installed for suspend / hibernate support.

Troubleshooting

If your unmounted partitions are not being displayed, then that is probably due to gvfs being compiled for systemd; using gvfs-nosystemdAUR from the AUR may fix it (probably not required if using eudev-systemdcompatAUR).

Some packages from the offical repos, like xfce4-power-manager, are compiled with the newer upower; for use with upower-pm-utilsAUR, they need to be compiled against it (xfce4-power-manager-upowerAUR is available in the AUR).

Your net devices will follow the pre-systemd pattern: from example wlp1s0 should be renamed to wlan0. You have to set your net configuration properly.

Your files in /etc/sysctl.d/ might disappear after removing the systemd package. OpenRC reads /etc/sysctl.conf.

If you own an ATI Radeon card and experience freezes with X (blank screen, non-resposive keyboard etc), appending nomodeset to the kernel boot command line should help. This is especially true with the closed source driver (catalystAUR).

See also