×


Install OpenBSD As Guest Operating System using KVM virt-install

Are you trying to install OpenBSD As Guest Operating System using KVM?

This guide will help you.

OpenBSD is a UNIX like system based on Berkeley Software Distribution (BSD). It does not compromise position on software licensing while providing quality code and documentation.
OpenBSD is also well known for its focus on security features such as Memory protection, cryptography, randomization, and much more in default base installation.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to install OpenBSD on KVM.
In this context, we shall look into how to troubleshoot KVM Virtualization Problem with log files in Linux for our customers.

How to install OpenBSD as guest operating system while using KVM ?

Now we will see the steps which our Support Experts follow to install OpenBSD as guest operating system for our clients having KVM.

1. First, we will download OpenBSD iso image from the URL:

https://www.openbsd.org/ftp.html

We can use the wget command or lftp command or curl command to grab the ISO image.


2. The following commands can be used to 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

3. To Verify SHA256 (256-bit) checksums for install63.iso we can use the following commands:

# grep install63.iso SHA256 > /tmp/x
# sha256sum -c /tmp/x
# rm /tmp/x

3. After that we can install OpenBSD 6.3 AMD64 VM on Linux KVM by typing 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

4. We can use our local vnc viewer or type the following at server itself to view installer screen:

# vncviewer

5. 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'>

Keep in mind to note down the port value (i.e. 5903).


6. We need to SSH client to setup the tunnel and a VNC client to access the remote vnc server by typing the following SSH port forwarding command from our client/desktop:

$ ssh ibmimedia@server1.ibmimedia.com -L 5903:127.0.0.1:5903

Once we have ssh tunnel established, we can point our VNC client at our own 127.0.0.1 (localhost) address and port 5903 to continue with OpenBSD 6.3 installation.

7. Now, just follow the on-screen installation instructions to install OpenBSD as per our requirements.


8. We have to ensure OpenBSD vm starts when Linux KVM box restarts:

# virsh autostart openbsd


OpenBSD Guest Hangs At Starting tty Flags in Linux KVM – How to fix ?

OpenBSD version 4.5 and above made changes in the kernel which prevents it from booting OpenBSD using KVM technology.
OpenBSD 4.4 runs with mbbios enabled. However, due to some sort of bug in KVM, it does not boot and hangs while displaying a message which reads as “Starting tty flags”.
We can fix this if we can disable mpbios by using the following procedure:

1. Boot OpenBSD With -c Option

At boot> prompt type the following command:

bsd -c
disable mpbios
quit

2. Now OpenBSD will boot without any problem.

Login as root and type the following command to disable mpbios permanently:

# config -ef /bsd
disable mpbios
quit

Here we have modified the kernel to boot without mpbios support.

[Still facing issue with KVM ? – We can help you. ]


OpenBSD Running in KVM Does Not Accept FTP Traffic – How to fix ?

After setting up OpenBSD under KVM at times we may face issues regarding ftp protocol.
We can fix this either by configuring iptables to allow all traffic to be forwarded across the bridge from KVM gues or by disabling it on bridges.

1. Configure Iptables

Type the following command as root user on KVM host (RHEL/CentOS host system):

/sbin/iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
/sbin/service iptables save
/sbin/service iptables restart


2. Disable Iptables On Bridges

This can be done by editing /etc/sysctl.conf as given below:

# vi /etc/sysctl.conf

Append the following config directives:

# Disable iptables on bridges so that ftp will work
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

Save and close the file. Reload the changes:

# sysctl -p


[Still facing KVM issues? – We can help you. ]


Conclusion

This article covers how to install OpenBSD as guest operating while using KVM. OpenBSD is well know for focus on security features such as Memory protection, cryptography, randomization and much more in default base installation.
virt-install provides the option of supporting graphics for the guest operating system installation. This is achieved through use of QEMU.

virt-install is a command line tool for creating new KVM, Xen, or Linux container guests using the libvirt hypervisor management library
The virt-install tool provides a number of options that can be passed on the command line.

To see a complete list of options run the following command:
# virt-install --help