You are not logged in.

#1 2024-04-25 07:51:13

rep_movsd
Member
Registered: 2013-08-24
Posts: 142

[Solved] Network config for an install used both natively and in a VM

I'm reinstalling another Arch side by side with my existing install, I am going to manually migrate my apps and settings one by one for only the stuff I am using currently....
Running the install on KVM is very convenient since I don't have to reboot etc. and can work on it whenever I have a break from regular work.
This install is on a completely separate disk that has a /  and /boot (+EFI) partition.

So far its been going OK - I am able to get my wlan connection load when booting natively, and the KVM virtual ethernet card when booted in a VM.
However I run into the "systemd network wait online" service bootup delay for 1.5 minutes on the VM since there is no wlan0 adapter.

I am using wpa_supplicant and systemd-networkd with dnsmasq

Here are my network files:

$ cat 25-wireless.network 
[Match]
Type=wlan

[Network]
DHCP=ipv4
IgnoreCarrierLoss=3s

[Link]
RequiredForOnline=yes

$ cat 30-wired.network 
[Match]
Type=ether

[Network]
DHCP=ipv4

Here is the service file

$ cat /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Wait for Network to be Configured
Documentation=man:systemd-networkd-wait-online.service(8)
ConditionCapability=CAP_NET_ADMIN
DefaultDependencies=no
Conflicts=shutdown.target
BindsTo=systemd-networkd.service
After=systemd-networkd.service
Before=network-online.target shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --interface=any --timeout=5
RemainAfterExit=yes

[Install]
WantedBy=network-online.target

Adding the options "--interface=any" and  "--timeout=5" has no effect on the behaviour.


Whats the best way to avoid the delay or at least reduce it to 10 seconds?
Thanks in advance

Last edited by rep_movsd (2024-05-05 06:34:26)

Offline

#2 2024-04-26 06:38:47

Nebulosa
Member
Registered: 2009-08-24
Posts: 48

Re: [Solved] Network config for an install used both natively and in a VM

You shouldn't edit directly the .service file that exists in the package, it will overwritten on the next update.

You need to make a drop-in file as the Wiki says:

sudo EDITOR=micro systemctl edit systemd-networkd-wait-online --drop-in=wait-for-only-one-interface.conf

and add lines:
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any

Last edited by Nebulosa (2024-04-26 06:44:01)

Offline

#3 2024-05-05 06:33:52

rep_movsd
Member
Registered: 2013-08-24
Posts: 142

Re: [Solved] Network config for an install used both natively and in a VM

I found a clean solution:

I made a simple script that checks if the system is not under a vm - it dies nothing but invert the result of systemd-detect-virt

$ cat /usr/bin/check_no_vm.sh 
#!/bin/bash

if systemd-detect-virt; then
    exit 1
else
    exit 0
fi

and made the wpa_supplicant service conditional on the script

$ cat /etc/systemd/system/wpa_supplicant@.service
[Unit]
Description=WPA supplicant daemon (interface-specific version)
# ConditionPathExists=/sys/class/net/%i
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
Before=network.target
Wants=network.target

# NetworkManager users will probably want the dbus version instead.
[Service]
Type=simple
ExecStartPre=/bin/check_no_vm.sh
ExecStart=/usr/bin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I

[Install]
WantedBy=multi-user.target

Offline

Board footer

Powered by FluxBB