Gentoo Without systemd

Having trouble with 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.

systemd USE flag
Add  to the system's USE variable in.

Mask systemd and udev
In order to explicitly inform Portage to never install, a mask is required.

Masks can be created a two different ways. Either create a directory called in  then create individual text files containing lists of packages to be masked or create a file called  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.

OR

Masking udev will not result in a broken system; Portage is smart enough to automatically replace udev by : 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:

Remove systemd related files automatically
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.

External resources

 * Funtoo Linux Optimization Proposal: No-systemd system
 * without-systemd.org