Systemd USE flag transition and OpenRC script coexistence
0 reputation · 12 May 2023, 00:06 UTC
0 reputation · 12 May 2023, 00:06 UTC
Gentoo provides the systemd USE flag to enable integration across various packages. When this flag is active, Portage installs systemd service files, but many packages maintain their legacy OpenRC scripts simultaneously to ensure compatibility during the transition.
This dual-support mechanism creates a configuration boundary where both init systems may attempt to manage the same daemon. While the Gentoo Handbook outlines the migration path, the coexistence of service files in /etc/init.d and /usr/lib/systemd/system can lead to ambiguity regarding which init system holds primary authority over a specific process during the boot sequence.
There is a lack of clarity on how the system should resolve conflicts when a package provides both service types but the global environment is in a partial migration state. Specifically, it is unclear if the presence of an OpenRC script should automatically suppress the systemd unit or vice versa.
34775 reputation · 12 May 2023, 08:59 UTC
Gentoo does not provide a deterministic priority mechanism that automatically suppresses an OpenRC script when a systemd unit is installed, or vice versa. File coexistence under /etc/init.d and /usr/lib/systemd/system does not confer authority to either init system. Runtime authority is determined solely by which init system is running as PID 1 and by the enablement state of the service within that init system.
Confirmed: During a normal boot, only one init system runs as PID 1. The systemd USE flag controls whether Portage installs systemd unit files; it does not remove or disable OpenRC init scripts. Depending on the ebuild, OpenRC scripts may be installed independently of the openrc USE flag or through service dependencies. Because both file sets can be present on disk, the filesystem alone cannot tell you which init system is managing a daemon. systemd's internal unit precedence applies only within systemd, not against OpenRC.
Likely explanation: If systemd is PID 1, OpenRC scripts are inert unless explicitly executed or unless OpenRC tooling is still configured to manage runlevels. However, this is a runtime state, not a packaging guarantee. You should not assume an installed OpenRC script is inactive merely because systemd is the active init.
To confirm that a package is exclusively using the systemd unit, verify the init authority and then inspect both init systems' state for the specific service.
ps -p 1 -o comm=UNIT with the actual unit name, e.g., sshd.service):systemctl is-enabled UNIT
systemctl is-active UNIT
systemctl status UNITThe status load path should reference a systemd unit directory rather than /etc/init.d.rc-update show
rc-statusThe service should not appear in boot, default, or nonetwork runlevels.equery uses CATEGORY/PACKAGEExpect systemd enabled and openrc disabled, then correlate with the runtime checks above.systemctl status can display drop-ins or alias units that shadow the package's unit file.rc-update show lists the service in a runlevel, OpenRC may still attempt to start it during boot.Provide the package atom or the exact systemd unit name. If OpenRC is PID 1, or if the unit name is unknown, the verification steps change.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 12 May 2023, 05:12 UTC
When the systemd USE flag is enabled, Portage places the unit file in /usr/lib/systemd/system and leaves the OpenRC script in /etc/init.d. Neither format automatically disables the other; the init system that is running as PID 1 will only process its native units. Consequently, if you boot with systemd as PID 1, the OpenRC script is ignored unless you start it manually via rc-service or a compatibility layer, and vice‑versa for an OpenRC‑only boot. To confirm that a package is using only the systemd unit, list its installed files with equery files and verify that no file appears under /etc/init.d for that service, or check the output of systemctl status versus rc-status. Masking the unwanted script or setting INIT_SYSTEM=systemd in /etc/make.conf can prevent accidental parallel starts during hybrid boot scenarios.