systemd - bunnyamin/bunnix GitHub Wiki
-
journalctl -u <SERVICE>-
-b<INTEGER>log from last boot. That is, 0 "current", 1 "previous", ... . -
-eshow logs from the last entry. -
-fshow 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>
- Part of SystemD
- Only EFI boot
- Verify if system is in UEFI mode by confirming presence of
-
efivar --listorls /sys/firmware/efi/efivars.
-
- Mount the boot ESP drive
-
bootctl install- Creates the EFI and loader directories.
Example of boot as the install directory:
/boot/
+-- EFI/
+-- loader/
| +-- entries/
| | +-- archlinux.conf
| | +-- archlinux-fallback.conf
| +-- keys/
| +-- entries.srel
| +-- loader.conf
| +-- random-seed
+-- initramfs-linux.img
+-- initramfs-linux.img
+-- initramfs-linux-fallback.img
+-- vmlinuz-linux
A work around is to install the boot loader from the non-chroot environment:
bootctl --esp-path=/mnt/boot install
arch-chroot /mnt
bootctl install
Note # If ESP path is mounted to a sub-directory then entry conf had problem finding the initramfs and vmlinuz.
-
/boot/espas mount point - Next time, try
../vmlinuz-linux
-
systemd-networkdenablessystemd-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>
Example configuration:
[Match]
Name=device_ap
WLANInterfaceType=ap
[Link]
RequiredForOnline=routable
[Network]
ConfigureWithoutCarrier=false
DHCPServer=true
IPv4Forwarding=true
Address=192.168.2.2/24
[DHCPServer]
ServerAddress=192.168.2.2/24
PoolOffset=2
PoolSize=20
EmitDNS=yes
DNS=1.1.1.1 4.4.4.4 8.8.8.8 ...
The device is connected to the AP and responds to ping. From the device:
- ping an IP address if it fails then the problem is routing, NAT or firewall
- ping a domain name if it fails then the problem is DNS
SystemD NetworkD can handle IP forwarding instead of DHCPD
- Start the DHCP Server
DHCPServer=yesunder the section[Network] -
[DHCPServer]to configure, for example:Poolsize=20
Clean DHCP server leases
/var/lib/systemd/network/dhcp-server-lease/<device name>
- 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=yesunder 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
MACAddressbecause "MAC address on the device already set by userspace.". - The
#PermanentMACAddressmatches 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-networkchmod 0640
- Note: changes to the content of the configuration files may require a restart of
systemd-networkdinstead 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
|
/etc/systemd/timesyncd.conf
systemctl status systemd-timesyncd
systemctl start/restart systemd-timesyncd
timedatectl show-timesync --all
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-failedfix references to missing unit files
- When the storage device in inserted then auto-mount it
- When removing the device then auto-unmount it
Two methods:
- x-systemd.automount - on failure, do nothing
- unit.mount, unit.automount - on failure, raise error
When accessing the mount point and the device is not available then content of the mount point is accessed, usually an empty directory, i.e. no error is raised.
For example, in fstab:
UUID=<UUID> /<MOUNT-POINT> ext4 rw,noatime,discard,noauto,x-systemd.automount 0 1
In order for the change to take effect:
sudo systemctl daemon-reloadsudo systemctl restart remote-fs.targetsudo systemctl restart local-fs.target
When accessing the mount point and the device is not available then an error is raised.
- Create a unit file in
/etc/systemd/user/<UNIT>- with
ExecStartandExecStop - 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