Raspberry Pi - Headless Installation
This wiki describes a method to prep an sd card for a raspberry pi so that the pi will connect to your local wifi on first boot and allow password-less root login over ssh to continue setup. This allows you to setup a raspberry pi without connecting a keyboard or monitor.
This method assumes that you are working from a linux machine and are already familiar with prepping an sd card with Alpine Linux for a raspberry pi. The basic procedure is to first create the sd card as normal but then also copy a one-time use overlay file into the root of the sd card. This file gets extracted on boot and creates /etc/.default_boot_services and replaces /bin/hostname with a custom shell script which will connect to your wifi network and start sshd.
Note that this is a hacky and insecure procedure though I've tried to put things back the way I found them after the script runs. Once you ssh in, run through the setup-alpine script, and run lbu commit -d the overlay will be replaced and the system will be back to a normal configuration after a reboot.
I've tested this with Alpine Linux 3.11.2 aarch64 on the Pi4 and armhf on the Pi Zero W. The Pi Zero W takes about 2 minutes and 20 seconds before it responds to a ping, though if you watch it boot it looks like it pulls an IP address and gets to the login prompt in about 1 minute and 17 seconds. The more powerful Pi4 comes up faster.
Create Overlay File
It is assumed that you have already extracted the Alpine Linux archive to the sd card. In a working directory create the following directory/file structure:
Edit bin/hostname as follows, updating ssid and psk to match your local network:
Create the overlay file:
Copy the localhost.apkovl.tar.gz into the root of the sd card, unmount, insert into the pi and boot. The above script uses dhcp on the wlan0 interface so you'll need to get into your dhcp server and watch for a new lease to determine the IP address assigned to the pi. Alternatively, you could change the script to use a static ip though I haven't tested that so I don't have verified syntax to provide at the time I'm writing this.
Once you know the IP address, you should be able to ssh to the pi as root without a password and run the setup-alpine script as usual. I would also recommend installing rng-tools and updating startup services:
Be sure to create a new overlay file (deleting the old one) before the first reboot: