I had some difficulty with installing and running OpenBSD 7.4 (and previously 7.3) under UTM on macOS. My main issue appears to be that OpenBSD cannot access the Mouse or Keyboard from the Mac. I am unsure whether this is a problem caused by one or more of UTM, QEMU, OpenBSD, or possibly macOS, but I can report that I have no problems with Ubuntu under UTM on macOS.

I have a MacBook Pro 2019 (Intel Core i9, 32 GB RAM) running macOS Sonoma 14.1.1. I am using UTM 4.4.5, and have downloaded the OpenBSD 7.4 image for the amd64 architecture.

Thankfully I have managed to find workarounds for each of the issues, which I am documenting below for my own memory, and because hopefully they may be useful for others.

Update 2024-01-17: A simpler workaround in UTM to fix the unresponsive Keyboard and Mouse.

How to Boot the OpenBSD Install Image in UTM

From the openbsd.org website, I downloaded the OpenBSD version 7.4 bootable image for amd64 systems from my closest mirror, the file is called: install74.img.

I created a new VM (Virtual Machine)  in UTM by selecting Virtualize, and choosing the Other category, I then assigned it 2 vCPU, 8 GB RAM, and a 40GB hard disk. However, as the install74.img file is not an ISO file, I had to click "Skip ISO boot" in the first stage of the configuration wizard, and then "Open VM Settings" in the last stage. From the VM settings I added a second drive of type Removable USB, set it to Read-Only, and selected the install74.img file as the source.

USB Disk Image for install74.img

How to use the Keyboard in OpenBSD Installer in UTM

Initially after booting the OpenBSD image described above, I found that I was unable to use the keyboard within the OpenBSD installer inside UTM; or at least OpenBSD did not seem to receiving any keystrokes!

Keyboard appears non-responsive within the OpenBSD Installer inside UTM

A little bit of experimentation showed however that before the installer starts, whilst at the initial OpenBSD kernel boot> prompt, the keyboard was actually working. With that knowledge, I was then able to add a Serial Port to the VM in UTM. One of the nice features of UTM, is that it will start up a terminal in a window that is connected to the new serial port.

Configuring a Serial Port for the VM in UTM

After adding the Serial Port to the VM, I rebooted OpenBSD and told it to redirect its default console to the serial port by entering the command set tty com0 at the boot> prompt.

Switching the default console to the com0 Serial Port during OpenBSD boot

With that done, I was able to boot and install OpenBSD as normal albeit using the serial port terminal for interacting with it via the keyboard.

One more thing to note is that during the install process, the installer will ask whether to permanently switch the default console to the serial port, due to the issue in UTM we should answer yes, and accept the defaults for the serial port speed, i.e.:

Change the default console to com0? [yes] yes
Available speeds are: 9600 19200 38400 57600 115200.
Which speed should com0 use? (or 'done') [9600] 9600

How to use the Keyboard and Mouse with X Window System in OpenBSD in UTM

During the installation process I opted to install X, however after the install finished and the system had rebooted, I could see the X Windows System on the default console but I could not interact with it via the Mouse or Keyboard.

Mouse and Keyboard appear non-responsive within the OpenBSD X Windows System inside UTM

We can work around this by installing a VNC Server and then remotely controlling X Windows via a VNC Client. We can install and configure the VNC Server using the Serial Console that we earlier setup:

su -
pkg_add tigervnc
exit

vncpasswd

XAUTHORITY=/etc/X11/xenodm/authdir/authfiles/A:0-r4dlnM x0vncserver -display :0 -PasswordFile ~/.vnc/passwd

You can then connect to the desktop via a VNC Client from the host Mac. Any VNC compatible client should work, personally I am using Real VNC for this:

Connecting via VNC from Mac to OpenBSD X Windows System

Additional UTM VM Settings for OpenBSD

Whilst the above is enough to get OpenBSD 7.4 running in UTM, I also made some additional changes to the VM configuration in UTM:

  • Enable the QEMU -> Balloon Device.
  • Enable the Display -> Retina Mode.
  • Change the Network -> Emulated Network Card to virtio-net-pci.
  • Change the IDE Drive -> Interface from IDE to VirtIO.

Update 2024-01-17: Simpler Workaround - i440FX instead of Q35

After submitting this article to Lobste.rs, I had some feedback from a user named vtech who suggested that changing the system type from Q35 (the default in UTM) to an i440FX would resolve the un-responsive Keyboard and Mouse issues I had been experiencing. I can confirm that this does appear to also workaround the issue in a simpler fashion. Thanks vtech!

Setting the System to i440FX instead of Q35 in UTM makes the Keyboard and Mouse responsive again