Skip to content

Instantly share code, notes, and snippets.

@aldemira
Last active October 7, 2024 18:44
Show Gist options
  • Select an option

  • Save aldemira/a33132a2d4cb2712c8d74f8b93aef1d0 to your computer and use it in GitHub Desktop.

Select an option

Save aldemira/a33132a2d4cb2712c8d74f8b93aef1d0 to your computer and use it in GitHub Desktop.
Install Debian Bookworm on a raspberry pi zero 2w without a keyboard

Get your desired Debian version for raspberry pi 3 from https://raspi.debian.net/daily-images/ Write it to the sdcard with:

xzcat 20210408_raspi_3_bullseye.xz | sudo dd of=/dev/{YOUR_DEVICE} bs=64k oflag=dsync status=progress If on macos, get the device name with: sudo diskutil list and umount any mounted volumes e.g. sudo diskutil unmount /dev/disk4s1 NOTE: Also omit oflag=dsync on macos. When done mount the sdcard (mount /dev/sdb2 /mnt) and chroot to it (chroot /mnt), also mount first partition (/dev/sdb1) to /mn/boot/firmware before chroot. Unfortunately we need to setup udev, systemd, and wpa_supplicant to get it to connect to wifi (it's just /etc/network/interfaces with sysvinit, which I'll instruct to migrate to) Create /etc/udev/rules.d/70-wireless-usb.rules and add this line:

ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan0", NAME="usbwifi"

Rename ifupdown files:

mv /etc/network/interfaces /etc/network/interfaces.save
mv /etc/network/interfaces.d /etc/network/interfaces.d.save

Create /etc/systemd/network/30-wlan.network and the lines below

[Match]                                                                                                                                                                                                    
Name=usbwifi                                                                                                                                                                                               
Type=wlan                                                                                                                                                                                                  
WLANInterfaceType=station                                                                                                                                                                                  
                                                                                                                                                                                                           
[Network]                                                                                                                                                                                                  
DHCP=ipv4                                                                                                                                                                                                  
                                                                                                                                                                                                           
[DHCP]                                                                                                                                                                                                     
UseDNS=yes

Set your wireless details in /etc/wpa_supplicant/wpa_supplicant-usbwifi.conf

ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
update_config=1

# Multiple `network` sections can be added for each SSID
network={
       ssid="myssid"
       psk="myssid_password"
}

Enable systemd networking and wpa_supplicant

systemctl enable wpa_supplicant@usbwifi.service
systemctl enable systemd-networkd

Add a user fro ssh to work:

useradd -m myuser -s /bin/bash
passwd myuser

Get all the required firmwares from: https://github.com/pyavitz/firmware/tree/main Exit chroot with CTRL+D unmount /mnt

On macos don't forget to eject the sdcard (sudo diskutil eject /dev/disk4)

After the boot it takes some time for the wifi to come up, be patient. Also try to find its IP from your routers. Note, for some reason stupid systemd-networkd doesn't create resolv.conf create it and a nameserver line.

Moving to sysinit

After sshing into pi:

  su -
  apt-get update && apt-get install -y sysinit-core
  rm -f /etc/wpa_supplicant/wpa_supplicant-usbwifi.conf
  mv /etc/network/interfaces.save /etc/network/interfaces
  mv /etc/network/interfaces.d.save /etc/network/interfaces.d

Add these lines to /etc/network/interfaces

auto wlan0
iface wlan0 inet dhcp
  wlan-ssid myssid
  wlan-psk mypsk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment