Installing OpenBSD 7.5 with virt-install on Linux

June 12, 2024 
OpenBSD logo

Introduction

OpenBSD 7.5 is a UNIX-like operating system. The project's "efforts emphasize portability, standardization, correctness, proactive security and integrated cryptography". Compared to modern Linux distributions OpenBSD is very compact, but comes with the usual packages and ports tree you would expect from any *BSD operating system. This article shows the process of installing OpenBSD 7.5 with virt-install, making it a virtualization guest on Linux.

Downloading the ISO installer

First you need to download the OpenBSD 7.5 ISO installer on your Linux system. On most systems the amd64 install75.iso is the correct choice. Check the OpenBSD download page for other architectures.

Installing OpenBSD 7.5 with virt-install on Linux

You can install OpenBSD 7.5 using the graphical virt-manager tool as well, but then you won't have a way to easily redo the installation should you need to. Fortunately you can use the virt-install command-line tools instead for installing OpenBSD 7.5 on Linux. The host system used here is Fedora 40, but the same command-line should work equally well on any Linux system that has the default virtualization tools installed:

sudo virt-install \
  --name=openbsd75 \
  --os-variant=openbsd7.5 \
  --virt-type=kvm \
  --memory=1024,maxmemory=2048 \
  --vcpus=1,maxvcpus=2 \
  --cpu host \
  --network=bridge=virbr0,model=virtio \
  --disk path=/var/lib/libvirt/images/openbsd75.qcow2,size=40,bus=virtio,format=qcow2 \
  --graphics=spice \
  --cdrom=/path/to/install75.iso \
  --machine=q35 \
  --input=type=keyboard,bus=usb  

Some notes:

  • You need to add an USB keyboard (see --input=type=keyboard,bus=usb, above) or you won't be able to type in the installer. The default keyboard type, PS/2, is apparently not support by default anymore.
  • You have to set --machine=q35 or OpenBSD 7.5 will (kernel) panic when the installation is about to start.
  • Older versions of virt-install might not support --os-variant=openbsd7.5. If so, an older openbsd variant or a generic Linux variant might work as a substitute.
  • You probably want to use the default network bridge (--network=bridge=virbr0,model=virtio) so that you can SSH in to OpenBSD from your virtualization host easily.

After you've launched the image you can use virt-manager to view the OpenBSD 7.5 installation screen and go through the installation normally. Please refer to the OpenBSD installation guide for details.

NOTE: if OpenBSD fails to boot after install you may have to set CPU to "host-passthrough" in its config file (e.g. /etc/libvirt/qemu/openbsd75.xml):

<cpu mode='host-passthrough' check='none' migratable='on'/>

Post-install tasks

After OpenBSD 7.5 install has finished you may want to add a normal user and enable doas for him/her:

useradd -m -G wheel john.doe
cp /etc/examples/doas.conf /etc/

Once this is done you can use your OpenBSD 7.5 installation in a very similar way as you'd use any Linux system.

PS. If you have more than a handful of OpenBSDs running you should consider automating their configurations with some Infrastructure as Code tool.

Links

Samuli Seppänen
Samuli Seppänen
Author archive
menucross-circle