Installing OpenBSD 7.2 on an ODROID-HC4

       1295 words, 7 minutes

Those are my notes about installing OpenBSD 7.2 on the ODROID-HC4 ; an arm64 board that provides SATA slots. It is quite straightforward to install, once you get the ordered steps.

What I use(d)

Hardware

An ODROID-HC4 , obviously.

A 3.5" 14TB SATA disk where OpenBSD and its data will lie. A second similar disk will be used to host various backups.

A microSD card to boot OpenBSD installer. Then it is used to boot from the SATA disk in normal usage. For some reasons, not all microSD cards seem to boot properly. In my case:

An ethernet cable to gain access to the network.

An USB keyboard and HDMI display.

Software

The OpenBSD arm64 installer image. I used 7.2/arm64/miniroot72.img.

The u-boot image gracefully provided here .

What I did

Plug the network cable, the HDMI screen and the USB keyboard to the HC4. And turn it on.

Remove Petitboot from the internal HC4 eMMC. Booting OpenBSD from Petitboot is not possible as of today. Booting OpenBSD requires using U-boot. When the Petitboot prompt appears, select Exit to shell and issue:

# flash_eraseall /dev/mtd0
# flash_eraseall /dev/mtd1
# flash_eraseall /dev/mtd2
# flash_eraseall /dev/mtd3

Then, turn the HC4 off. If you wish / need to restore Petitboot, check at the end of this post for a recovery procedure.

A few steps are required to get a bootable OpenBSD installer. They involve both the stock OpenBSD installer and the U-boot binary image. The setup can be done from any computer, I used my OpenBSD laptop. Insert the MicroSD card into the computer, copy the OpenBSD installer onto it. Then add some bits from the U-boot image.

# dd if=Téléchargements/miniroot72.img of=/dev/rsd2c bs=1M
504+0 records in
504+0 records out
528482304 bytes transferred in 118.498 secs (4459824 bytes/sec)

# dd if=Téléchargements/u-boot.bin.sd.bin of=/dev/sd2c bs=512 skip=1 seek=1
2227+1 records in
2227+1 records out
1140592 bytes transferred in 3.278 secs (347929 bytes/sec)

# dd if=Téléchargements/u-boot.bin.sd.bin of=/dev/sd2c bs=1 count=444
444+0 records in
444+0 records out
444 bytes transferred in 0.005 secs (82760 bytes/sec)

The OpenBSD installer seem to expect you to use a serial console with arm64 machine. Hopefully, the HC4 can use an HDMI screen and a USB keyboard for operating. This requires telling the installer to rather use the framebuffer to print stuff.

# mount /dev/sd2a /mnt/usb 
# mkdir /mnt/usb/etc
# echo "set tty fb0" > /mnt/usb/etc/boot.conf
# umount /mnt/usb

Insert the (install) MicroSD card and the SATA disk into the HC4. Turn the power on and… run the OpenBSD installer as usual!

I installed OpenBSD on the sd0 SATA disk using whole disk and auto layout. The response file looks like:

System hostname = odroid-hc4
Which network interface do you wish to configure = dwge0
IPv4 address for dwge0 = autoconf
IPv6 address for dwge0 = none
Which network interface do you wish to configure = done
Start sshd(8) by default = yes
Setup a user = jca
Full name for user jca = Joel Carnat
Allow root ssh login = prohibit-password
Which disk is the root disk = sd0
Use (W)hole disk or (E)dit the MBR = whole
Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout = e
Which disk do you wish to initialize = done
Location of sets = http
HTTP proxy URL = none
HTTP Server = cdn.openbsd.org
Server directory = pub/OpenBSD/7.2/arm64
Set name(s) = done
Location of sets = done
What timezone are you in = Europe/Paris

Note that if you are using a disk bigger than 2TB, the default MBR installation will not be able to use the full disk space. This can be corrected after reboot by issuing a couple of disklabel and growfs magics. Or you may use a GPT configuration from the installer. In such a case, before lauching the installation, switch to a shell and configure GPT on the destination disk:

(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? s
# cd /dev
# sh MAKEDEV sd0
# fdisk -gy -b 960 sd0
Writing GPT.
# exit

The installer should now identify the disk with its full size.

When installation is done, halt the system and turn the HC4 off.

In this state, OpenBSD is not bootable. Without Petitboot, the HC4 will try to boot from the MicroSD card. So it is goind to be replaced with the U-boot image that was already used. The U-boot process will look for stuff in the SATA MSDOS partition and boot OpenBSD.

Take the MicroSD card out of the HC4 and plug it back to the computer. Then copy the U-boot image on it:

# dd if=Téléchargements/u-boot.bin.sd.bin of=/dev/sd2c bs=1M

Insert the MicroSD card in the HC4 and power it on. Wait a few moments and connect to the HC4 using ssh(1). Enjoy OpenBSD on the ODROID-HC4!

Thanks a lot Mark Kettenis for your help (and your patience ;)

Extra notes

Installation on MicroSD card

I initially planned to install and run the OS from the MicroSD card. But the formatting process failed. It seems “that access to SD cards is indeed not working properly” yet.

Using two disks

As of OpenBSD 7.2-STABLE, you can’t really use the two disks slots. As soon as you mount the second disk, the OS becomes unresponsive . A patch has been produced and submitted to -CURRENT. You can use sysupgrade(8) to switch to snapshot (or install a snapshot). Then you can use both disks.

Restoring Petitboot

To restore Petitboot, read and apply the documented procedure . I used the spiupdate_odroidhc4_20201222.img.xz image. Then, from the Petitboot prompt, I updated it using pb-update.

Boot images backup

I keep a local copy of the u-boot.bin.sd.bin and the spiupdate_odroidhc4_20201222.img.xz images. Feel free to grab them from here if the initial repository disapear.

Running Nextcloud

The HC4 is tough enough to run NextCloud v25. I use PHP 8.1, Redis, MariaDB on this machine and my NextCloud/CalDAV/CardDAV clients (on iOS & OpenBSD) don’t complain at all. I don’t really use the Web interface. It’s a bit slow compared to the previous Core i5 machine but it is absolutely useable.

Running Samba

The HC4 also serves as a TimeMachine and CIFS server. And it behaves as good as my Synology DS918+.

Metrics

While using cp(1) to copy a bunch a files from one disk to another, I get about 80 MBps:

 tin tout  KB/t  t/s    MB/s   KB/t  t/s    MB/s  us ni sy sp in id
   0 1469 64.00 1265   79.08  64.00 1425   89.05   1  0 25 25  0 50
   0  493 64.00 1328   83.00  64.00 1410   88.12   1  0 27 12  2 58
   0  172 63.37  517   31.98  22.40 2664   58.28   1  0 20 19  2 58
   0  172 63.01 1079   66.40  64.00 1270   79.39   1  0 28 21  1 50
   0  169 64.00 1517   94.84  64.00 1545   96.54   1  0 21  5  1 72
   4 1543 64.00 1478   92.39  64.00 1493   93.32   0  0 17  4  1 78
   0  174 64.00 1690  105.62  64.00 1690  105.62   0  0 17  1  1 81
   0  171 63.92 1416   88.37  64.00 1400   87.50   2  0 20 11  1 67
   0  176 64.00 1425   89.08  64.00 1486   92.87   0  0 28  8  1 63

Using iperf3(1), I get about halt a Gigabit:

# iperf3 -c arcadia -bidir
(...)
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   549 MBytes   460 Mbits/sec    0             sender
[  5]   0.00-10.00  sec   548 MBytes   460 Mbits/sec                  receiver

With only a single disk and ideling, the HC4 needs about 10W. With both disks pluggued in and services started, it takes from 15W to 20W. According to the power outlet, it uses about 0.40KWh every day. That’s about 1/4 of the Synology DS918+ consumption.

dmesg

Both 7.2 and 7.2-CURRENT dmesg have been uploaded on NYC*BUG: