Raspberry Pi Zero W: Headless bring up (Raspbian)
Preparation
Download and unpack the image:
wget -O raspbian-stretch-lite.zip https://downloads.raspberrypi.org/raspbian_lite_latest unzip raspbian-stretch-lite.zip
Mount the image to the local filesystem:
su -c 'losetup -f --show 2017-11-29-raspbian-stretch-lite.img' /dev/loop0 su -c 'partx -a /dev/loop0' mkdir boot root su -c 'mount /dev/loop0p1 boot' su -c 'mount /dev/loop0p2 root'
Configure WiFi interface
Automatically setup wlan0 for DHCP:
su -c 'emacs root/etc/network/interfaces'
source-directory /etc/network/interfaces.d + +auto wlan0 +allow-hotplug wlan0 +iface wlan0 inet dhcp + wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Create and open file wpa_supplicant.conf:
su -c 'emacs root/etc/wpa_supplicant/wpa_supplicant.conf'
Configure wpa_supplicant according to your WiFi network:
-country=GB +country=DE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 + +network={ + ssid="YOUR_SSID" + psk="YOUR_PSK" + proto=RSN + key_mgmt=WPA-PSK + pairwise=CCMP + auth_alg=OPEN +}
Clean up
Unmount and clean up:
su -c 'umount root' su -c 'umount boot' su -c 'partx -d /dev/loop0' su -c 'losetup -d /dev/loop0'
Install image to MicroSD card
Insert the MicroSD card into your host computer and check the systemd journal for the appropriate device node:
journalctl -k -f | grep sd ... Jan 23 20:41:10 discordia kernel: sdb: sdb1 ...
Use dd to write the image to the card:
Be careful when running the following command! The output file (of) has to be the MicroSD card's device node!
su -c 'dd bs=4M if=2017-11-29-raspbian-stretch-lite.img of=/dev/sdb conv=fsync'
Now put the MicroSD card into your Raspberry Pi and attach the power supply. Give the device some time to boot up.