I have decided to use Ubuntu 20.10 since this one will boot from USB out of the box now, and is not in Beta like Raspberry Pi OS 64bit.
Tools / Downloads
- Etcher ( Super easy to “burn” the iso to USB or SD card ) – https://www.balena.io/etcher/
- Ubuntu 20.10 64bit Server version – https://ubuntu.com/download/raspberry-pi
- Raspberry Pi Imager – https://www.raspberrypi.org/downloads/ ( To make Rpi4 boot from USB it require firmware update and Ubuntu does not have tools to do it )
- SSH client of your choice, usually putty or anything else
Hardware to have
- Some kind of PC to setup the USB and SD card ( windows ideally, but can be done with Linux or Mac just as well. We will focus on Windows though )
- SD card reader
- USB keyboard / Micro HDMI cable / Monitor
- Rpi4 of course ( just don’t go overboard with so many 😀 )
- USB-C cable and way to power the Rpi4
Update Raspberry Pi 4 firmware
Most likely you will have to update firmware on Raspberry Pi 4 to enable USB boot. This firmware is out of beta and marked stable so we should be ok. Sadly, this is additional step you need to take, get the Raspberry Pi Imager and have it write Raspberry Pi 4 EEPROM boot recovery to SD card. This is super small and fast way to update firmware and enable boot from USB.
When done, put the SD card to Rpi4 and turn the power on. You don’t need to connect anything else, just wait a minute or two until green light next to power start blinking periodically. That will mean its done. New firmware should be flashed. We can use the same SD card to update every node.
You have to do this on every Raspberry Pi node you have.
Depending on number of Raspberry Pi's this will take some time, so just keep on it. No hurry, and between flashing you can prepare the Ubuntu 20.10 usb’s. Goes without saying you need flash as many USB as you have nodes… in my case its 9x using 32GB USB flash drive. Use etcher.
When done, switch to next USB disk and use “Flash Another”
There is couple things we can do before booting the Raspberry Pi 4 that we don’t have to use keyboard and monitor.
Insert USB disk with flashed Ubuntu 20.10 from steps above, you will get one partition that you can look up files in.
- Add empty file called ssh – This will enable ssh when Raspberry Pi 4 boots up.
- Edit network-config – Look into the links in the file for additional options, I will be adding my wifi “Kubernetes” into this, so the Rpi connects right away.
I’m using wifi for connection and all IPs are assigned by DHCP but already pre-defined to specific IP based on MAC address. This step can be done when all the Rpis are up and running. Log into your router and assign permanent IPs in DHCP.
version: 2 ethernets: eth0: # Rename the built-in ethernet device to "eth0" match: driver: bcmgenet smsc95xx lan78xx set-name: eth0 dhcp4: true optional: true wifis: wlan0: dhcp4: true optional: true access-points: "Kubernetes": password: "some_password"
Or setup static IPs, thats up to you.
For fixed ip it might looks like this:
network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp4-overrides: use-dns: no gateway4: 192.168.0.1 addresses: - 192.168.0.101/24 match: driver: bcmgenet smsc95xx lan78xx optional: true set-name: eth0
Plug the USB disk in Raspberry Pi 4 and plug in power. Now wait a little, watch on router for new IP to appear 🙂 ( If it doesn’t, attach monitor and keyboard, look what is wrong ). Do not stress about green light staying on all the time, this is because it is trying to read SD card which is not there. I will show you have to turn it off later.
Hopefully you were able to ssh to the new IP and log in with user: ubuntu / password: ubuntu ( you will be forced to change password, so make it same on all nodes for now )
For now only connect all Rpis, make sure they all have unique IPs and are up and running. For reference this is my IP layout.
We are going to do some manual tasks on each node and later on we use Ansible a little to help us execute commands on all nodes at once. ( And yes, you can make one Ansible playbook that would do 99% of deployment, but that’s for another tutorial :D)
I went bit over board with cluster box 🙂.
This is my custom box to house the Raspberry Pi nodes. Its combination of laser cut plywood, plexiglass and 3d printed caddies that holds the nodes it self. But hey, just get some standoffs and mount it in one column, will work the same. ( Or tape it to card board 😀 )