Notes on bootstrapping Raspberry Pi OS. This blog post is written in the heavy influence of a cold. Take care with your copy and pasting. No more information at the point.
Before first boot 🔗
Export your WiFi network and credentials to shell variables.
export WIFI_NAME="internett"
export WIFI_PASS="password"
Run a configuration script before you put the SD Card in your Raspberry Pi Zero 2 W. Base folder is the folder where you have mounted the OS boot
partition.
cd /run/media/${USER}
# Enable ethernet over OTG
grep -q ^dtoverlay boot/config.txt || sed -i '$ a\dtoverlay=dwc2' boot/config.txt
sed -i -E '/rootwait [^m]/ s/(rootwait)/\1 modules-load=dwc2,g_ether/' boot/cmdline.txt
# Set the good old pi:raspberry
echo "pi:$(echo -n 'raspberry' | openssl passwd -6 -stdin)" > boot/userconf.txt
# Enable SSHd
touch boot/ssh.txt
# Cofigure WIFI
cat <<CONF > boot/wpa_supplicant.conf
country=no
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="${WIFI_NAME}"
psk="${WIFI_PASS}"
}
CONF