systemd - bunnyamin/bunnix GitHub Wiki
-
journalctl -u <SERVICE>
-
-b<INTEGER>
log from last boot. That is, 0 "current", 1 "previous", ... . -
-e
show logs from the last entry. -
-f
show the most recent entries and monitor output for new ones.
-
-
systemd-analyze verify <FILE>
ensure that the service file is valid. -
systemctl list-unit-files --type=service --state=enabled
systemctl edit <SERVICE>
- Add new section
[SERVICE]
and define thereunderEnvironment=SYSTEMD_LOG_LEVEL=debug
- Restart service
systemctl restart <SERVICE>
- Revert changes
systemctl revert <SERVICE>
systemctl restart <SERVICE>
Control the system locale and keyboard layout settings.
localectl set-x11-keymap <layout>
-
systemd-networkd
enablessystemd-networkd-wait-online.service
- Create configuration files in
/etc/systemd/network/
- Overview
networkctl list
udevadm test-builtin net_setup_link /sys/class/net/<NAME OF INTERFACE TO TEST>
- Create a WPA Supplicant for the wireless device.
Delete a started device (link): networkctl delete <LINK>
SystemD NetworkD can handle IP forwarding instead of DHCPD
- Start the DHCP Server
DHCPServer=yes
under the section[Network]
-
[DHCPServer]
to configure, for example:Poolsize=20
- Debug
tcpdump -i enp1s0 -nn -s0 -v -A udp port 67
- Can systemd networkd be configured for netboot, PXE boot, if yes, how?
[Match]
Name=<NETWORK INTERFACE>
[Link]
RequiredForOnline=False
[Network]
DHCP=yes
DHCPServer=true
IPForward=yes
IPMasquerade=both
Address=10.0.0.2/24
ConfigureWithoutCarrier=true
[DHCPServer]
PoolOffset=100
PoolSize=1
BootServerAddress=10.0.0.2
# 12 "Hostname"
# Hostname=
SendOption=12:string:<CLIENT HOSTNAME>
# 17 "Root Path"
SendOption=17:string:/srv/netboot
# EFI
#SendOption=67:string:netboot/x86_64-efi/core.efi
#BootFilename=/srv/netboot/grub/x86_64-efi/core.efi
BootFilename=grub/x86_64-efi/core.efi
# i386
#SendOption=67:string:netboot/grub/i396-pc/core.0
#BootFilename=netboot/grub/i396-pc/core.0
#BootFilename=/srv/tftp/netboot/grub/i396-pc/core.0
[DHCPServerStaticLease]
# Device #1
MACAddress=1a:2b:3c:4d:5e:6f
Address=10.0.0.101
#[DHCPServerStaticLease]
# Device #2
MACAddress=a1:b2:c3:d4:e5:f6
#Address=10.0.0.102
SystemD NetworkD can handle IP forwarding instead of /etc/sysctl.d/30-ipforward.conf
-
IPForward=yes
under the section[Network]
Event | Error | Cause | Remedy |
---|---|---|---|
Starting Network Configuration | Network configuration changed, trying to establish connection |
Unknown | Wait until the configuration is done. It is observed to take around 10-20 minutes. |
networkctl |
Operational status is reported as degraded
|
Invalid configuration | |
Starting Network Configuration | Could not set hostname: Access denied |
Unknown | Change the hostname manually with hostnamectl . |
Attempting to connect | Network is unreachable |
No gateway | Under the section [Network] , either add DHCP=yes or assign a static IP Address=192.168.1.9/24 , Gateway=192.168.1.1 , DNS 192.168.1.1 . |
Create a link configuration that lexically comes before "99". For example, 00-mac-wlv.link.
Example, match virtual devices.
- Could not use
MACAddress
because "MAC address on the device already set by userspace.". - The
#PermanentMACAddress
matches the physical device, and from it all derived virtual interfaces.
Event | Error | Cause | Remedy |
---|---|---|---|
Initialization | <interface>: Could not bring up interface: Name not unique on network |
The interface MAC address is not unique. | Assign a new MAC address to interface. |
Initialization | WLAN interface exists, using existing without changing its parameters. |
The interface MAC address is not unique. | Assign a new MAC address to interface. |
The order of the files for devices in /etc/systemd/network/
has not been tested. The following worked:
- 00-mac-ether.link
- 01-mac-wireless.link
- 10-wan-ether.network
- 11-lan-ether.network
- 20-wan-wireless.network
- 30-lan-wireless-ap.netdev
- 31-lan-wireless-ap.network
Address RouteMetric applies to connected route
Route Metric deals with static route
DHCPxx RouteMetric applies to routes learned from DHCP
- Arch Linux Wiki WireGuard
-
40-wan-vpn-wg.netdev
- If the private key is provided in the configuration file or another file the
permission of that file must be
chown root:systemd-network
chmod 0640
- Note: changes to the content of the configuration files may require a restart of
systemd-networkd
instead ofnetworkctl reload
.
- If the private key is provided in the configuration file or another file the
permission of that file must be
- 41-wan-vpn-wg.network
Create a configuration
-
/etc/wpa_supplicant/wpa_supplicant-wlp0s0.conf
-
/etc/wpa_supplicant/wpa_supplicant-nl80211-wlp0s0.conf
-
wpa_supplicant-<interface>.conf
-
/etc/systemd/network/10-wlp0s0.network
-
systemctl enable --now [email protected]
-
systemctl enable --now [email protected]
Event | Error | Cause | Remedy |
---|---|---|---|
systemctl start ... |
sys-subsystem-net-devices-wlp0s0.device: Job sys-subsystem-net-devices-wlp0s0.device/start timed out. Timed out waiting for device /sys/subsystem/net/devices/wlp0s0. Dependency failed for WPA supplicant daemon (interface-specific version). [email protected]: Job [email protected]/start failed with result 'dependency'. sys-subsystem-net-devices-wlp0s0.device: Job sys-subsystem-net-devices-wlp0s0.device/start failed with result 'timeout'
|
Followed answer by WonderWoofy to question Managing WPA wireless with systemd-networkd ? on Arch Linux forums. The instruction # systemctl enable [email protected] seemed to have caused the problem; the .conf part. |
Remove .conf . That is, the name of the service has to be # systemctl enable [email protected] . |
systemctl start ... |
wpa_supplicant[14261]: nl80211: kernel reports: Match already configured |
Even | Error | Cause | Remedy |
---|---|---|---|
systemctl start resolvconf-pull-resolved |
start-limit-hit |
Unknown | Edit the service file: After=network-online.target
|
Display current system time.
# timedatectl status
Enable automatic NTP synchronization.
# timedatectl set-ntp true
Force NTP synchronization.
# systemctl restart systemd-timesyncd
Error | Cause | Remedy |
---|---|---|
[FAILED] Failed to start Network Time Synchronization. |
Update timedatectl system time. |
/etc/system/system/<UNIT>
systemd-analyze plot > overview.svg
-
systemctl reset-failed
fix references to missing unit files
When inserting the device, auto-mount it. When removing the device, auto-unmount it.
The distinct behavior from unit.mount, unit.automount is important. If attempting to access the mount point when the device is not mounted, the program accessing the mount point as is, for example, an empty directory.
Whether the device is inserted or not, when accessing the device, attempt to mount it. If the device is not inserted then the program attempting to access the device may return with error.
The distinct behavior from Fstab is important. If attempting to access the mount point when the device is not mounted, the program accessing the mount point will not find any valid storage, that is, not even an empty mount point.
- Create a unit file in
/etc/system/user/<UNIT>
- with
ExecStart
andExecStop
- If the execution requires root privileges then execute with
=+
"full privileges". For example:ExecStart=+/usr/bin/bash -c "echo 'heartbeat' > /sys/class/leds/red:power/trigger
- with
- Enable the file globally
systemctl --global enable <unit>
Note that the global unit file cannot have the same name as a system unit file.
List global unit files.
systemctl --global list-unit-files