OpenBSD as a Xen domU

From Wiki
Jump to: navigation, search

This information is correct as of OpenBSD 4.6 and Xen 3.2.1.

Does it Work?

Yes, OpenBSD works in HVM (full virtualisation mode), but it can not be paravirtualised. You need a processor that supports Hyper-V (intel call it something else). If you have the following, you're fine:

# xm dmesg | grep HVM
(XEN) HVM: SVM enabled
(XEN) HVM: Hardware Assisted Paging detected and enabled.

Do it

  • Create a logical volume. (This also works with an image file, but an LV gives better performance):
# lvcreate -L10G -n example.spruce.toastputer.net-disk xen-vol
  Logical volume "example.spruce.toastputer.net-disk" created
  • Grab the install iso that corresponds with your CPU architecture from a convenient mirror:
# cd /home/xen
# wget http://www.mirrorservice.org/sites/ftp.openbsd.org/pub/OpenBSD/4.6/amd64/cd46.iso
  • Create a configuration file for the domU:
# vi /etc/xen/example.spruce.toastputer.net.cfg 
import os, re
arch = os.uname()[4]
kernel = "/usr/lib/xen-default/boot/hvmloader"
builder='hvm'

memory = 512
shadow_memory = 8
name = "example.spruce.toastputer.net"
# Setting ne2k_pci is essential if you want the virtual NIC to work
vif = [ 'type=ioemu, bridge=eth0, model=ne2k_pci' ]
# for image file instead of LV:
#disk = [ 'file:/home/xen/example.spruce.toastputer.net.img,xvda,w', 'file:/home/xen/cd46.iso,xvdc:cdrom,r' ]
disk = [ 'phy:/dev/xen-vol/example.spruce.toastputer.net-disk,xvda,w', 'file:/home/xen/cd46.iso,xvdc:cdrom,r' ]
device_model = '/usr/lib/xen-default/bin/qemu-dm'
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="cd"

sdl=0 
# Enable VNC
vnc=1 
# Listen on 127.0.0.1:5901
vncconsole=1
# Listen on all IPs (Do not want)
#listen='0.0.0.0'
vncviewer=0 
nographic=0 
stdvga=0 
serial='pty' 
audio=0 
localtime=1 
pae=0
acpi=0
apic=0
usb=0
nousb=1
audio=0
  • Instantiate the VM:
# xm create example.spruce.toastputer.net.cfg
Using config file "/etc/xen/example.spruce.toastputer.net.cfg".
Started domain example.spruce.toastputer.net
  • Verify that the dom0 has a listening socket for VNC:
# netstat -ntap | grep 5901
tcp        0      0 127.0.0.1:5901          0.0.0.0:*               LISTEN      9953/qemu-dm
  • ssh to the dom0, forwarding port 5901:
# ssh user@dom0-address -L 5901:127.0.0.1:5901
  • You will now be able to VNC to 127.0.0.1:5901 and see the domU console, so just install OpenBSD as usual. I get messages about corrupt NIC memory during the install, but this does not persist once booted into the installed system.
  • NOTE: Chicken of the VNC on OS X doesn't like the VNC encoding used by Xen. Vine Viewer works fine, as does JollysFastVNC.