Gentoo Without systemd
This article has been flagged as dirty for not conforming to the wiki guidelines. It is now grouped in the list of articles to be cleaned.
Having trouble with sys-apps/systemd being pulled in for no apparent reason? This article contains some information how to resolve this problem.
Why is systemd pulled in?
Most packages depending on systemd, actually depend on systemd or OpenRC or some other init system. Portage will attempt to install the first in the list, which might be systemd.
Portage cannot magically guess which init system the user prefers. USE flags defined user preferences.
Permanently blocking systemd
systemd USE flag
-systemd to the system's USE variable in /etc/portage/make.conf.
Mask systemd and udev
In order to explicitly inform Portage to never install sys-apps/systemd, a mask is required.
Masks can be created a two different ways. Either create a directory called package.mask in /etc/portage then create individual text files containing lists of packages to be masked or create a file called package.mask and organize it all in one big file. Portage will be happy with either method. The choice is left up to the system administrator. Why two ways? Well, it would appear two methods continue to exist for organizational purposes. Some users like having everything defined in one file, while other users like having each set of packages masked in separate directories.
Masking udev will not result in a broken system; Portage is smart enough to automatically replace udev by sys-fs/eudev: the systemd-free fork of udev.
Packages requiring systemd
Some packages have systemd as a non-optional dependency (see: Hard dependencies_on_systemd), as long as systemd is masked, it's impossible to install them, so removing those packages is the only option.
To solve this, it is strongly advised to file a bug report to the upstream developer team. Sometimes alternative packages can be found.
Check if systemd is installed or not?
Portage does not activate systemd when installing it. Whenever systemd is not activated, the system remains on OpenRC (or whatever init selected).
To remove systemd, it is possible to follow the steps above and update the @world set, or remove it manually:
emerge --ask --depclean sys-apps/systemd
According to the official ebuild policy for systemd, unit files are installed unconditionally to the USE flag.
To get around this, we can install a hook for portage to delete these files.
The ebuild for this package can be found in the now defunct sunrise-overlay.
emerge --ask app-portage/portage-hooks
mkdir -p /etc/portage/hooks/pkg_postinst.d
rm -rf /etc/systemd/ \ /usr/lib/systemd/ \ /run/systemd