systemd on Gentoo

This tutorial is a guide to help setting up systemd on Gentoo. systemd is a modern sysvinit and RC replacement for Linux systems. This article is based on the official Gentoo article on systemd.

Kernel Configuration-

Mandatory options:

General setup  —>

[*] Control Group support

[ ] Enable deprecated sysfs features to support old userspace tools

[*] Networking support —>

Device Drivers  —>

Generic Driver Options  —>

[*] Maintain a devtmpfs filesystem to mount at /dev

File systems  —>

[*] Inotify support for userspace

[*] Filesystem wide access notification

Recommended options:

General setup  —>

[*]   open by fhandle syscalls

Processor type and features  —>

[*]   Enable seccomp to safely compute untrusted bytecode

Networking support —>

Networking options —>

<*> The IPv6 protocol

Device Drivers  —>

Generic Driver Options  —>

()  path to uevent helper

Firmware Drivers  —>

[*]   Export DMI identification via sysfs to userspace

File systems —>

<*> Kernel automounter version 4 support (also supports v3)

Pseudo filesystems —>

[*]   Tmpfs virtual memory file system support (former shm fs)

[*]   Tmpfs POSIX Access Control Lists

[*]   Tmpfs extended attributes

systemd-bootchart support

File systems  —>

Pseudo filesystems —>

[*] /proc file system support

Kernel hacking  —>

[*]   Kernel debugging

[*]   Collect scheduler debugging info

[*]   Collect scheduler statistics

UEFI support

[*] Enable the block layer  —>

Partition Types  —>

[*] Advanced partition selection

[*]   EFI GUID Partition support

Processor type and features  —>

[*]   EFI runtime service support

Firmware Drivers  —>

<*> EFI Variable Support via sysfs

Filesystem Changes:

/etc/mtab symlink to /proc/self/mounts

# ln -sf /proc/self/mounts /etc/mtab

 

Other filesystem changes like creation of /run directory and /etc/machine-id is automatically handled by the sys-apps/systemd and sys-apps/dbus packages respectively.

Software Installation

The Gentoo article states it is necessary to install the systemd package before enabling the USE flag:

# emerge -av systemd

Now, enable global USE flag systemd:

# nano -w /etc/portage/make.conf

USE="... systemd ..."

After setting this, update your system so the changes take effect:

# emerge -avuND @world

Configuration files

File containing the system hostname:

/etc/hostname

tux

Configuration file specifying console font and keymap:

/etc/vconsole.conf

KEYMAP=us
FONT=default8x16

Configuration file for locale settings:

/etc/locale.conf

LANG="en_US.UTF-8"
LC_COLLATE="C"

Configuration file for local machine information:

/etc/machine-info

PRETTY_NAME="Home Computer"
ICON_NAME="computer-laptop"

Enabling systemd

Edit your GRUB configuration file and add the following to your kernel line:

real_init=/usr/lib/systemd/systemd

Example Grub entry:

menuentry 'Gentoo Base System release 2.1'

{

insmod part_msdos

insmod ext2

set root='hd0,msdos3'

linux /boot/kernel-3.8.13-gentoo root=/dev/sda3 real_init=/usr/lib/systemd/systemd

initrd /boot/initramfs-3.8.13-gentoo

}

Finally, reboot to enjoy the benefits of systemd.