With the move to NetworkManager this has become quite complex to the extent that so far I have been unable to automate the system to connect on first boot. The NetworkManager conf files create some UUID identification numbers which I cannot replicate.
As a result I am currently staying with legacy for my headless setups so am curious if anyone has managed to create an nmconnections conf file to facilitate the connection on first boot.
The following snippet from image-config is a working example of how to create an nmconnections conf file for WiFi to facilitate the connection on first boot:
Code:
rm "${BOOTMNT2}/firstrun.sh" &> /dev/nullsed -i 's| systemd.run.*||g' "${BOOTMNT2}/cmdline.txt"rm -r "${MNTPATH}/etc/NetworkManager/system-connections/"mkdir "${MNTPATH}/etc/NetworkManager/system-connections/"rm "${BOOTMNT2}/wpa_supplicant.conf" &> /dev/nullif [ "${WPA_CONF}" != "" ]; then OSVER="$(sed -n 's|^VERSION=".*(\(.*\))"|\1|p' ${MNTPATH}/etc/os-release)" if [[ "${OSVER}" = "trixie" || "${OSVER}" = "bookworm" ]]; then cat <<EOF > "${MNTPATH}/etc/NetworkManager/system-connections/${WPA_SSID}.nmconnection"[connection]id=${WPA_SSID}uuid=$(cat /proc/sys/kernel/random/uuid)type=wifiinterface-name=wlan0[wifi]mode=infrastructuressid=${WPA_SSID}[wifi-security]auth-alg=openkey-mgmt=wpa-pskpsk=${WPA_PASS}[ipv4]method=auto[ipv6]method=autoEOF chmod 600 "${MNTPATH}/etc/NetworkManager/system-connections/${WPA_SSID}.nmconnection" cat <<EOF > "${BOOTMNT2}/firstrun.sh"#!/bin/bashset +eraspi-config nonint do_wifi_country ${WPA_CC}rm -f ${BOOTMNT1}/firstrun.shsed -i 's| systemd.run.*||g' ${BOOTMNT1}/cmdline.txtexit 0EOF sed -i "/^[[:space:]]*#/!s|^\(.*\)$|\1 systemd.run=${BOOTMNT1}/firstrun.sh systemd.run_success_action=reboot systemd.unit=kernel-command-line.target|" "${BOOTMNT2}/cmdline.txt" else cat <<EOF > "${BOOTMNT2}/wpa_supplicant.conf"ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevcountry=${WPA_CC}update_config=1network={ ssid="${WPA_SSID}" psk="${WPA_PASS}"}EOF fifiStatistics: Posted by RonR — Sun Sep 07, 2025 7:03 pm