Running OpenBSD on Raspberry Pi Zero 2 W
781 words, 4 minutes
I had that Raspberry Pi Zero 2 W lying in a box. And because I changed my network configuration, I decided I could use that Pi as a DNS et DHCP server. But I also wanted to take benefits from my POE switch.
It turns out to be really simple, with the proper hardware. Here are the notes.
Software
Get the OpenBSD installer for ARM. I’m using 7.4.
# ftp https://ftp.openbsd.org/pub/OpenBSD/7.4/arm64/miniroot74.img
Get the Raspberry Pi Zero 2 W Device Tree Blob.
# ftp https://github.com/raspberrypi/firmware/raw/master/boot/bcm2710-rpi-zero-2.dtb
Hardware
I have used:
- a Raspberry Pi Zero 2 W ;
- a 32GB SanDisk Ultra microSDHC UHS-I Card ;
- a WaveShare PoE Ethernet / USB HUB HAT for Raspberry Pi Zero, 1x RJ45, 3x USB (19635) ;
- a Mini HDMI® to HDMI® Cable, an HDMI® Cable and an HDMI® monitor ;
- a USB keyboard ;
- a Cat6 RJ45 Cable and a TP-Link Switch PoE (TL-SG1210P).
Attach the Pi to the POE Hat using the provided screws. Plug the HDMI cable to the Pi. Plug the USB keyboard to the Hat.
Do not plug the RJ45 cable, yet.
Installation
Plug the microSDHC to a machine ; I used a ThinkPad running OpenBSD. Transfer the OpenBSD installer onto the card. Add the DTB file to it. Configure OpenBSD to use the HDMI output.
# dd if=miniroot74.img of=/dev/rsd2c bs=1m
# mount /dev/sd2i /mnt/usb
# cp bcm2710-rpi-zero-2.dtb /mnt/usb/
# umount /mnt/usb
# mount /dev/sd2a /mnt/usb
# mkdir -p /mnt/usb/etc
# echo "set tty fb0" >> /mnt/usb/etc/boot.conf
# umount /mnt/usb
Take the microSD card out of the laptop and plug it into the Pi.
Plug the RJ45 cable. The Pi should start and boot from the microSD card.
Thanks to the HDMI monitor and USB keyboard, you can proceed to the
OpenBSD installation as usual. Be sure to configure the ure0
network
interface as the WiFi card has no available firmware (yet). When asked
for disk partitioning, select the “Whole” option. Select an HTTP mirror
to install the sets.
When the installation is finished, turn off the Pi, take the microSD card out and plug it back to your other machine. Copy the DTB to the microSD card to be able to boot. Instruct OpenBSD to use the HDMI output.
# mount -t msdos /dev/sd2i /mnt/usb
# cp bcm2710-rpi-zero-2.dtb /mnt/usb/
# umount /mnt/usb
# mount /dev/sd2a /mnt/usb
# echo "set tty fb0" >> /mnt/usb/etc/boot.conf
# umount /mnt/usb
Take the microSD card out and plug it into the Pi. I’m using it headless, with only the RJ45 cable pluggued in. From my testings, the USB switch allows connecting and using USB keyboard and USB sticks (Corsair Flash VoyagetGT 16GB).
The dmesg is available here .
Performance overview
This POE Hat provides a 10/100 Realtek RTL8152 network interface:
# speedtest-cli --simple
Ping: 10.925 ms
Download: 91.35 Mbit/s
Upload: 65.38 Mbit/s
# mount -t mfs -o -s128M /dev/sd0b /mnt
# ftp -o /mnt/test https://cdn.openbsd.org/pub/OpenBSD/7.4/amd64/comp74.tgz
Trying 199.232.171.52...
Requesting https://cdn.openbsd.org/pub/OpenBSD/7.4/amd64/comp74.tgz
100% |*****************************************************| 75644 KB 00:07
77459716 bytes received in 7.74 seconds (9.53 MB/s)
# umount /mnt
Disk performance to download an OpenBSD set:
# ftp -o /root/test https://cdn.openbsd.org/pub/OpenBSD/7.4/amd64/comp74.tgz
Trying 199.232.171.52...
Requesting https://cdn.openbsd.org/pub/OpenBSD/7.4/amd64/comp74.tgz
100% |*****************************************************| 75644 KB 00:15
77459716 bytes received in 15.42 seconds (4.78 MB/s)
Disk performance while installing and extracting the python-3.10.13 package:
tty sd0 cpu
tin tout KB/t t/s MB/s us ni sy sp in id
0 92 7.28 303 2.15 7 0 6 1 2 84
0 326 8.96 350 3.06 6 0 6 0 1 87
0 49 8.61 262 2.21 5 0 5 1 1 88
0 132 9.62 422 3.96 4 0 3 1 2 90
0 50 9.98 363 3.54 3 0 3 0 0 94
0 49 9.81 357 3.42 2 0 5 1 1 91
0 90 8.70 454 3.86 3 0 6 1 2 88
0 48 7.61 411 3.05 3 0 7 1 1 88
0 128 11.77 450 5.17 8 0 7 0 1 84
0 126 11.34 370 4.09 7 0 4 2 1 86
0 159 13.79 323 4.35 7 0 4 0 2 87
0 120 19.90 158 3.07 6 0 3 2 2 87
0 49 20.21 126 2.49 3 0 3 1 0 93
0 84 19.22 151 2.83 1 0 3 0 1 95
0 80 24.67 124 2.98 3 0 11 5 1 80
0 81 25.04 282 6.89 7 0 3 0 1 89
0 79 20.07 292 5.73 13 0 10 3 2 73
0 107 15.10 279 4.11 4 0 5 1 3 87
0 106 15.99 314 4.91 10 0 13 7 1 68
0 129 23.15 345 7.81 6 0 3 2 2 87
Overall responsiveness is quite good.
Now, let’s use it!