KVM virt-install: Install OpenBSD As Guest Operating System

How do I install OpenBSD as guest operating system when using KVM? How can I use virt-install to setup OpenBSD VM under KVM running on a CentOS Linux 7 server?

OpenBSD is a UNIX like system based on Berkeley Software Distribution (BSD). It was forked form NetBSD and created by Theo de Raadt in 1995. OpenBSD is famous for quality code and documentation without compromising position on software licensing. OpenBSD is also well know for focus on security features such as Memory protection, cryptography, randomization and much more in default base installation. This page shows how to use the virt-install command line tool of KVM to setup OpenBSD guest VM.

How to install OpenBSD as guest operating system when using KVM

You need to first download OpenBSD iso image by visiting this page. You can use the wget command or lftp command or curl command to grab the ISO image as follows. The following command will download OpenBSD v6.3 64 bit (AMD64) iso file on a CentOS 7 or Ubuntu 18.4/16.04 LTS or Debian Linux 9.x server:
# cd /var/lib/libvirt/boot/
# wget https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.3/amd64/install63.iso
# wget https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.3/amd64/SHA256
# chown qemu:qemu install63.iso

Verify SHA256 (256-bit) checksums for install63.iso:
# grep install63.iso SHA256 > /tmp/x
# sha256sum -c /tmp/x
# rm /tmp/x

Install OpenBSD 6.3 AMD64 VM on Linux KVM

Type the following command to install OpenBSD 6.3 64 bit with minimum 2GB RAM, 2 vcpu, 40GB disk space, and virbr0 network interface:
# virt-install
--name=openbsd
--virt-type=kvm
--memory=2048,maxmemory=4096
--vcpus=2,maxvcpus=4
--cpu host
--os-variant=openbsd5.8
--cdrom=/var/lib/libvirt/boot/install63.iso
--network=bridge=virbr0,model=virtio
--graphics=vnc
--disk path=/var/lib/libvirt/images/openbsd.qcow2,size=40,bus=virtio,format=qcow2

Sample outputs:

Starting install...
Allocating 'openbsd.qcow2'                                                                                                                                                                  |  40 GB  00:00:00     
Domain installation still in progress. Waiting for installation to complete.

Use your local vnc viewer or type the following at server itself to view installer screen:
# vncviewer
To configure vnc login from another terminal over ssh and type:
# virsh dumpxml openbsd | grep vnc
<graphics type='vnc' port='5903' autoport='yes' listen='127.0.0.1'>

Please note down the port value (i.e. 5903). You need to use an SSH client to setup tunnel and a VNC client to access the remote vnc server. Type the following SSH port forwarding command from your client/desktop:
$ ssh [email protected] -L 5903:127.0.0.1:5903
Once you have ssh tunnel established, you can point your VNC client at your own 127.0.0.1 (localhost) address and port 5903 to continue with OpenBSD 6.3 installation:

Now, just follow on screen installation instructions and install OpenBSD as per your requirements:

Make sure OpenBSD vm starts when Linux KVM box restarts

# virsh autostart openbsd

After Reboot My OpenBSD Guest Hangs At The Boot Screen…