Linux (Arch) WPA_SUPPLICANT service not starting @ boot

Posted on

Problem :

Setting up linux “Arch” on my Microsoft Surface Pro 6, installed OK but an issue with wpa_supplicant as service. Service is enabled but fails to start @ boot time. After login as root, “systemctl start wpa_supplicant.service” works great. Seems like a timing issue (to me) but I’ve not been able to help myself with WiKi or Google. Any help appreciated.

/etc/wpa_supplicant.conf

network={
    ssid="MyWiFi"
    psk=be131c51e250735aab71b89563250cba1e13e513ce53e037cd2351791dd07c52
}

/etc/systemd/system/wpa_supplicant.service

[Unit]
Description=WPA supplicant
Before=network.target
Wants=network.target

[Service]
Type=dbus
BusName=fi.w1.wpa_supplicant1
ExecStart=/usr/bin/wpa_supplicant -u -i wlp1s0 -c /etc/wpa_supplicant.conf

[Install]
WantedBy=multi-user.target
Alias=dbus-fi.w1.wpa_supplicant1.service

journalctl (after boot)

    -- Logs begin at Thu 2019-08-01 03:57:36 MST, end at Fri 2019-08-02 05:28:18 MST. --
Aug 02 05:27:41 surface systemd[1]: Starting WPA supplicant...
Aug 02 05:27:41 surface wpa_supplicant[462]: Successfully initialized wpa_supplicant
Aug 02 05:27:41 surface systemd[1]: Started WPA supplicant.
Aug 02 05:27:41 surface wpa_supplicant[462]: Could not read interface wlp1s0 flags: No such device
Aug 02 05:27:41 surface wpa_supplicant[462]: nl80211: Driver does not support authentication/association or connect commands
Aug 02 05:27:41 surface wpa_supplicant[462]: nl80211: deinit ifname=wlp1s0 disabled_11b_rates=0
Aug 02 05:27:41 surface wpa_supplicant[462]: Could not read interface wlp1s0 flags: No such device
Aug 02 05:27:41 surface wpa_supplicant[462]: wlp1s0: Failed to initialize driver interface
Aug 02 05:27:41 surface systemd[1]: wpa_supplicant.service: Main process exited, code=exited, status=255/EXCEPTION
Aug 02 05:27:41 surface systemd[1]: wpa_supplicant.service: Failed with result 'exit-code'.

journalctl (after manually starting service)

    -- Logs begin at Thu 2019-08-01 03:57:36 MST, end at Fri 2019-08-02 05:28:55 MST. --
Aug 02 05:28:51 surface systemd[1]: Starting WPA supplicant...
Aug 02 05:28:51 surface wpa_supplicant[505]: Successfully initialized wpa_supplicant
Aug 02 05:28:51 surface systemd[1]: Started WPA supplicant.
Aug 02 05:28:55 surface wpa_supplicant[505]: wlp1s0: Trying to associate with e0:3f:49:9b:4f:e8 (SSID='MyWiFi' freq=2437 MHz)
Aug 02 05:28:55 surface wpa_supplicant[505]: wlp1s0: Associated with e0:3f:49:9b:4f:e8
Aug 02 05:28:55 surface wpa_supplicant[505]: wlp1s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Aug 02 05:28:55 surface wpa_supplicant[505]: wlp1s0: WPA: Key negotiation completed with e0:3f:49:9b:4f:e8 [PTK=CCMP GTK=CCMP]
Aug 02 05:28:55 surface wpa_supplicant[505]: wlp1s0: CTRL-EVENT-CONNECTED - Connection to e0:3f:49:9b:4f:e8 completed [id=0 id_str=]

Solution :

You didn’t specify when to start the service, so it starts too early; it says “wlp1s0 doesn’t exist” because the interface indeed does not exist yet at that point in time.

The recommended way is to use:

[Unit]
Requires=sys-subsystem-net-devices-wlp1s0.device
After=sys-subsystem-net-devices-wlp1s0.device

This is also how the stock wpa_supplicant@.service solves the problem (and you could have simply used that unit, instead of making your own).

Leave a Reply

Your email address will not be published. Required fields are marked *