Systemd: Difference between revisions

From Q
Jump to navigation Jump to search
Tgurr (talk | contribs)
No edit summary
Tgurr (talk | contribs)
 
(45 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Description ==
== Description ==
systemd is a system and session manager for Linux.
systemd is a system and session manager for Linux also including udev nowadays.


== Kernel settings ==
== Kernel settings ==
First of all you need a recent kernel version >=2.6.39 and some [[Kernel#systemd|kernel options]] set.
First of all you need a recent kernel version >=4.2 and some [[Kernel#systemd|kernel options]] set.


== Paludis configuration ==
== Installation ==


=== System and package options ===
{{File|/etc/paludis/options.conf|
{{File|/etc/paludis/options.conf|
<pre>
<pre>
*/* build_options: jobs=5 -recommended_tests
*/* build_options: jobs=5 -recommended_tests
*/* systemd
*/* systemd
sys-apps/systemd simple-net
sys-apps/systemd seccomp
</pre>
</pre>
}}
}}
First we need to add repositories for the dependencies not in ::arbor (you need to setup [[Paludis]] for automatic repository installation first).
{{Root|cave resolve repository/x11 -x}}
Install the systemd package:


{{Root|cave resolve systemd -x}}
{{Root|cave resolve systemd -x}}
Line 26: Line 19:
Now we need to reinstall packages with the systemd option set.
Now we need to reinstall packages with the systemd option set.


{{Root|cave resolve world -c -x}}
{{Root|cave resolve world -cx}}
 
== Network ==


Swich over to systemd using eclectic.
You can find out what the network device will be named by running:


{{Root|eclectic init set systemd}}
{{Root|udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null}}


{{File|/etc/hostname|
{{Code|network device name|
<pre>
<pre>
desired-hostname
ID_NET_NAME_MAC=enx005056a84955
ID_NET_NAME_PATH=enp11s0
</pre>
</pre>
}}
}}


{{File|/etc/vconsole.conf|
=== systemd-networkd ===
 
This configuration will default to DHCP as long as the 10-static.network doesn't match.
 
{{File|/etc/systemd/network/10-static.network|
<pre>
<pre>
FONT="lat9w-16"
[Match]
KEYMAP="de"
Name=eno1
 
[Network]
Address=192.168.0.88/24
Gateway=192.168.0.1
DNS=192.168.0.1
</pre>
</pre>
}}
}}


{{File|/etc/conf.d/network.conf|
{{File|/etc/systemd/network/20-dhcp.network|
<pre>
<pre>
IFACE=eth0
[Match]
IPV4=192.168.0.2
Name=en*
MASK=255.255.255.0
 
BCAST=255.255.255.0
[Network]
GATEWAY=192.168.0.1
DHCP=yes
Domains=domain.local
 
[DHCP]
UseDomains=yes
</pre>
</pre>
}}
}}


{{File|/etc/env.d/02locale|
{{Root|systemctl enable systemd-networkd.socket}}
 
== Network Name Resolution manager ==
 
=== systemd-resolved ===
 
{{File|/etc/systemd/resolved.conf.d/resolved.conf|
<pre>
<pre>
LANG=de_DE.utf8
[Resolve]
DNS=192.168.0.1
</pre>
</pre>
}}
}}
{{Root|rm /etc/resolv.conf}}
{{Root|cd /etc}}


Reboot and login.
{{Root|ln -s /run/systemd/resolve/resolv.conf resolv.conf}}


{{Root|systemctl enable systemd-resolved.service}}


== Enable network ==
== Network Time Synchronization (NTP) ==


either for simple net:
=== systemd-timesyncd ===


{{Root|systemctl enable network.service}}
{{File|/etc/systemd/timesyncd.conf.d/timesyncd.conf|
<pre>
[Time]
NTP=192.168.0.1
</pre>
}}


or when using NetworkManager:
{{Root|systemctl enable systemd-timesyncd.service}}


{{Root|systemctl enable NetworkManager.service}}
{{Root|systemctl start systemd-timesyncd.service}}


== Enable tty login ==
{{Root|systemctl enable getty@tty1.service}}


== Enable sshd connectivity ==
== Enable sshd connectivity ==
Line 79: Line 106:
{{Root|systemctl enable sshd.socket}}
{{Root|systemctl enable sshd.socket}}


Reboot and login via SSH.
{{Root|systemctl start sshd.socket}}
 
 
== Configuration ==
 
=== Hostname ===
 
Edits /etc/hostname and /etc/machine-info.
 
{{Root|hostnamectl set-hostname desiredhostname}}
 
=== Timezone ===


== Manually starting and stopping services ==
Sets the /etc/localtime symlink.
 
{{Root|timedatectl set-timezone Europe/Berlin}}
 
Ensure the system RTC is in UTC, this might require setting Windows to UTC via a registry key when dual-booting.
 
{{Root|timedatectl set-local-rtc 0}}
 
=== Keyboard Layout ===
 
Edits /etc/vconsole.conf.
 
{{Root|localectl set-keymap de}}
 
=== Localization ===
 
Edits /etc/locale.conf.
 
{{Root|<nowiki>localectl set-locale LANG="en_US.UTF-8"</nowiki>}}
 
The systemd localectl commands sets the system locale, if you want to set your user locale use /etc/env.d/02locale.
 
== Misc ==
=== Manually starting and stopping services ===
You'll find an overview of all installed services and sockets in /lib/systemd/system.
You'll find an overview of all installed services and sockets in /lib/systemd/system.


Line 90: Line 151:
{{Root|systemctl}} prints a status report of your systemd setup.
{{Root|systemctl}} prints a status report of your systemd setup.


== Enable additional/optional services ==
=== Enable additional/optional services ===
vixie-cron:
 
systemd-journal-gatewayd (accessible via port 19531):


{{Root|systemctl enable vixie-cron.service}}
{{Root|systemctl enable systemd-journal-gatewayd.socket}}
 
cronie:
 
{{Root|systemctl enable cronie.service}}


ntp:
ntp:


{{Root|systemctl enable ntpd.service}}
{{Root|timedatectl set-ntp 1}}


MySQL:
MySQL:


{{Root|systemctl enable mysql.service}}
{{Root|systemctl enable mysql.service}}
Samba 4:
{{Root|systemctl enable smbd.service}}
{{Root|systemctl enable nmbd.service}}
{{Root|systemctl enable winbindd.service}}
SSSD:
{{Root|systemctl enable sssd.service}}
mdadm:
{{Root|systemctl enable mdadm.service}}
postfix:
{{Root|systemctl enable postfix.service}}
NFS (client):
{{Root|systemctl enable rpcstatd.service}}
NFS (server):
{{Root|systemctl enable nfs-server.service}}

Latest revision as of 09:51, 18 March 2020

Description

systemd is a system and session manager for Linux also including udev nowadays.

Kernel settings

First of all you need a recent kernel version >=4.2 and some kernel options set.

Installation

File: /etc/paludis/options.conf
*/* build_options: jobs=5 -recommended_tests
*/* systemd
sys-apps/systemd seccomp
# cave resolve systemd -x

Now we need to reinstall packages with the systemd option set.

# cave resolve world -cx

Network

You can find out what the network device will be named by running:

# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null
Code: network device name
ID_NET_NAME_MAC=enx005056a84955
ID_NET_NAME_PATH=enp11s0

systemd-networkd

This configuration will default to DHCP as long as the 10-static.network doesn't match.

File: /etc/systemd/network/10-static.network
[Match]
Name=eno1

[Network]
Address=192.168.0.88/24
Gateway=192.168.0.1
DNS=192.168.0.1
File: /etc/systemd/network/20-dhcp.network
[Match]
Name=en*

[Network]
DHCP=yes
Domains=domain.local

[DHCP]
UseDomains=yes
# systemctl enable systemd-networkd.socket

Network Name Resolution manager

systemd-resolved

File: /etc/systemd/resolved.conf.d/resolved.conf
[Resolve]
DNS=192.168.0.1
# rm /etc/resolv.conf
# cd /etc
# ln -s /run/systemd/resolve/resolv.conf resolv.conf
# systemctl enable systemd-resolved.service

Network Time Synchronization (NTP)

systemd-timesyncd

File: /etc/systemd/timesyncd.conf.d/timesyncd.conf
[Time]
NTP=192.168.0.1
# systemctl enable systemd-timesyncd.service
# systemctl start systemd-timesyncd.service

Enable tty login

# systemctl enable getty@tty1.service

Enable sshd connectivity

# systemctl enable sshd.socket
# systemctl start sshd.socket


Configuration

Hostname

Edits /etc/hostname and /etc/machine-info.

# hostnamectl set-hostname desiredhostname

Timezone

Sets the /etc/localtime symlink.

# timedatectl set-timezone Europe/Berlin

Ensure the system RTC is in UTC, this might require setting Windows to UTC via a registry key when dual-booting.

# timedatectl set-local-rtc 0

Keyboard Layout

Edits /etc/vconsole.conf.

# localectl set-keymap de

Localization

Edits /etc/locale.conf.

# localectl set-locale LANG="en_US.UTF-8"

The systemd localectl commands sets the system locale, if you want to set your user locale use /etc/env.d/02locale.

Misc

Manually starting and stopping services

You'll find an overview of all installed services and sockets in /lib/systemd/system.

# systemctl start <service>.service
# systemctl stop <service>.service
# systemctl

prints a status report of your systemd setup.

Enable additional/optional services

systemd-journal-gatewayd (accessible via port 19531):

# systemctl enable systemd-journal-gatewayd.socket

cronie:

# systemctl enable cronie.service

ntp:

# timedatectl set-ntp 1

MySQL:

# systemctl enable mysql.service

Samba 4:

# systemctl enable smbd.service
# systemctl enable nmbd.service
# systemctl enable winbindd.service

SSSD:

# systemctl enable sssd.service

mdadm:

# systemctl enable mdadm.service

postfix:

# systemctl enable postfix.service

NFS (client):

# systemctl enable rpcstatd.service

NFS (server):

# systemctl enable nfs-server.service