I have decided to use Ubuntu 20.10, since this one will now boot from USB out of the box, 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 requires a firmware update, and Ubuntu does not have tools to do this)
- SSH client of your choice, usually putty.
Hardware to have
- Some kind of PC to set up the USB and SD card (windows ideally, but can be done with Linux or Mac just as well. We will focus on Windows).
- 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 the firmware on Raspberry Pi 4 to enable USB boot. This firmware is out of beta and marked stable, so we should be ok. Sadly, there is an additional step you need to take: get the Raspberry Pi Imager and have it write Raspberry Pi 4 EEPROM boot recovery to the SD card. This is a 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 the green light next to power starts blinking periodically. That will mean it’s done. The 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 the number of Raspberry Pis, this will take some time, so just keep on it. There is no hurry, and between flashing you can prepare the Ubuntu 20.10 usbs. It goes without saying that you need to flash as many USB as you have nodes; in my case, it’s 9x 32GB USB flash drives. Use etcher.
When done, switch to the next USB disk and use “Flash Another”.
There are a couple of things we can do before booting the Raspberry Pi 4 for which we don’t have to use keyboard and monitor.
When you insert a USB disk with flashed Ubuntu 20.10 from steps above, you will get one partition that you can look up files in.
- Add an empty file called
ssh- This will enable ssh when the 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"
You could set up static IPs instead; that’s up to you.
For a 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 into the Raspberry Pi 4 and plug in the power. Now wait a little, watch on the router for a new IP to appear 🙂 (If it doesn’t, attach your monitor and keyboard, and look for what is wrong). Do not stress about the green light staying on all the time; this is because rPi is trying to read the SD card, which is not there. I will show you how to turn it off later.
Hopefully, you were able to ssh to the new IP and log in with username: ubuntu / password: ubuntu (you will be forced to change password, so make it same on all nodes for now)
For now, only connect the 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 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 🙂).
I went a bit overboard with Cluster Box...
This is my custom box to house the Raspberry Pi nodes. It’s combination of laser cut plywood, plexiglass and 3D printed caddies which hold the nodes themselves. But hey, just get some standoffs and mount them in one column, it will work the same (or tape it to cardboard 😀).