This is an automation I wrote to help me load up fresh versions of Ubuntu-server on RPi 4, without requiring ethernet or a monitor, so I could atomically test builds of octoprint/octoprint docker image. I may expand this some day to a GUI tool, but for now, it's scripted enough to work every time and you just have to "fill in the blanks" so to speak, of your own network details and desired hostname.
Steps to follow are below.
- insert usb disk
- download ubuntu image
- get disk device map designation using
lsblk -a -d -e7
- example device is
/dev/sde
- uncompress and pipe ubuntu compressed disk image to
dd
to "restore" it to usb disk xzcat ubuntu.img.xz | sudo dd status=progress of=/dev/sde bs=4M conv=sync,noerror
- mount the disk
sudo mount /dev/sde /media/${USER}
- Edit the network config in
writable/etc/wpa_supplicant/wpa_supplicant.conf
- Edit desired details in
cloud-config/user-data
sudo ./write-boot-configs /media/$USER
- Turn on pi, wait ~5 minutes for boot
- login using
ssh ubuntu@<static_ip_address (declared below in netplan example)>
with passwordubuntu
- Follow prompts to change password immediately, will disconnect after password is updated
- log back in using
ssh ubuntu@<static_ip_address>
with the new password, and voila!
Following example taken directly from netplan.io/examples#conecting-to-a-wpa-personal-wireless-network
Edit the system-boot/network-config
file as follows:
... # existing config
wifis:
wlan0:
optional: true
dhcp4: no
dhcp6: no
addresses: [192.168.0.21/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1, 8.8.8.8]
access-points:
"network_ssid_name":
password: "**********"
example etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="ssidname"
psk="password"
}
https://wiki.ubuntu.com/ARM/RaspberryPi https://www.raspberrypi.org/documentation/configuration/config-txt/README.md https://netplan.io/examples#connecting-to-a-wpa-personal-wireless-network