我在 toradex 板的启动过程中遇到问题(更多信息这里) wpa_supplicant 服务因“依赖”原因失败。我正在使用纯 systemd 网络设置,此文件用于我们的 wifi:
- 首先进行接口重命名:
root@colibri:/etc/systemd/network# cat 10-toradex-wifi-ifnames.link
[Match]
Driver=mwifiex_pcie
[Link]
NamePolicy=keep kernel
- 第二个用于接口升级:
root@colibri:/etc/systemd/network# cat 61-wireless-mambo.network
[Match]
Name=mlan0
[Network]
DHCP=ipv4
IgnoreCarrierLoss=3s
[DHCPv4]
RouteMetric=21
- 第三个用于 wpa_supplicant (特定于接口):
root@colibri:~# cat /etc/systemd/system/[email protected]
[Unit]
Description=WPA supplicant daemon (interface-specific version)
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
ExecStart=/usr/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
[Install]
WantedBy=multi-user.target
root@colibri:~#
我已将问题归结为:
root@colibri:~# systemctl status [email protected]
○ [email protected] - WPA supplicant daemon (interface-specific version)
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: disabled)
Active: inactive (dead)
Nov 03 11:50:02 colibri systemd[1]: Dependency failed for WPA supplicant daemon (interface-specific version).
Nov 03 11:50:02 colibri systemd[1]: [email protected]: Job [email protected]/start failed with result 'dependency'.
更多细节:
Nov 03 13:30:41 colibri systemd[1]: Timed out waiting for device /sys/subsystem/net/devices/mlan0.
Nov 03 13:30:41 colibri systemd[1]: Dependency failed for WPA supplicant daemon (interface-specific version).
我可以看出我已经超时,因为在启动时我尝试登录时收到此消息:
pi@tt:~$ ssh [email protected]
[email protected]'s password:
"System is booting up. Unprivileged users are not permitted to log in yet. Please come back later. For technical details, see pam_nologin(8)."
Connection closed by 192.168.28.38 port 22
pi@tt:~$
systemd-analyze
使用orsystemd-analyze
关键链 或不会出现任何结果systemd-analyze blame
。我的猜测是,这与接口重命名/udev
和竞争条件有关systemd
,正如我所看到的:
Nov 03 13:30:41 colibri systemd[1]: sys-subsystem-net-devices-mlan0.device: Job sys-subsystem-net-devices-mlan0.device/start failed with result 'timeout'.
检查时间:13:30:41,然后我们在日志中看到以下内容:
Nov 03 13:30:43 colibri systemd-networkd[656]: mlan0: udev initialized link
看起来udev
初始化是在systemd
尝试启动设备后完成的......
如果我让系统达到超时并最终启动,我只需启动 mlan0.service 即可运行:
root@colibri:~# systemctl status [email protected]
○ [email protected] - WPA supplicant daemon (interface-specific version)
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: disabled)
Active: inactive (dead)
Nov 03 13:30:41 colibri systemd[1]: Dependency failed for WPA supplicant daemon (interface-specific version).
Nov 03 13:30:41 colibri systemd[1]: [email protected]: Job [email protected]/start failed with result 'dependency'.
root@colibri:~# systemctl start [email protected]
root@colibri:~# systemctl status [email protected]
● [email protected] - WPA supplicant daemon (interface-specific version)
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-11-03 13:39:49 UTC; 1s ago
Main PID: 1333 (wpa_supplicant)
Tasks: 1 (limit: 1649)
Memory: 1.6M
CGroup: /system.slice/system-wpa_supplicant.slice/[email protected]
└─ 1333 /usr/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-mlan0.conf -imlan0
Nov 03 13:39:49 colibri systemd[1]: Started WPA supplicant daemon (interface-specific version).
Nov 03 13:39:49 colibri wpa_supplicant[1333]: Successfully initialized wpa_supplicant
root@colibri:~# systemctl status [email protected]
● [email protected] - WPA supplicant daemon (interface-specific version)
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-11-03 13:39:49 UTC; 5s ago
Main PID: 1333 (wpa_supplicant)
Tasks: 1 (limit: 1649)
Memory: 1.7M
CGroup: /system.slice/system-wpa_supplicant.slice/[email protected]
└─ 1333 /usr/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-mlan0.conf -imlan0
Nov 03 13:39:49 colibri systemd[1]: Started WPA supplicant daemon (interface-specific version).
Nov 03 13:39:49 colibri wpa_supplicant[1333]: Successfully initialized wpa_supplicant
Nov 03 13:39:51 colibri wpa_supplicant[1333]: mlan0: Trying to associate with 00:90:7f:47:66:41 (SSID='<REDACTED>' freq=5220 MHz)
Nov 03 13:39:51 colibri wpa_supplicant[1333]: mlan0: Associated with 00:90:7f:47:66:41
Nov 03 13:39:51 colibri wpa_supplicant[1333]: mlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Nov 03 13:39:51 colibri-imx8x-07330229 wpa_supplicant[1333]: mlan0: WPA: Key negotiation completed with 00:90:7f:47:66:41 [PTK=CCMP GTK=CCMP]
Nov 03 13:39:51 colibri wpa_supplicant[1333]: mlan0: CTRL-EVENT-CONNECTED - Connection to 00:90:7f:47:66:41 completed [id=0 id_str=]
root@colibri:~#
有什么猜测吗?或者创建一个可以解决此问题的服务文件的提示?