Technology & Life

Summary
Setting up Alpine Linux under OpenBSD's native vmd hypervisor
Published
Reading time
3 min
Tags
, ,

These are my notes on setting up Alpine Linux as a guest under OpenBSD's native vmd(8) hypervisor. This is useful way to gain access to Linux on an OpenBSD host. One can easily run Docker, Portainer, and other typically Linux-oriented software from the comfort of OpenBSD. :)

$ man vmm # virtual machine monitor
$ man vmd # virtual machine daemon
$ man vm.conf

$ dmesg | grep vmm >/dev/null && echo ye || echo ni

$ doas rcctl enable vmd
$ doas rcctl start vmd

Create your directory somewhere nice, examples:

$ mkdir -p /home/cosmic/vmm
$ mkdir -p /home/vmm

Tip: If you need more space on an existing system, you may be able to collapse /src and /obj into a single partition and remount it as /home/vmm, if needed.

$ vmctl create -s 2G alpine-virt-aarch64.qcow2
vmctl: qcow2 imagefile created

First, I went to Alpine's download page to grab the URL to the latest virt X86_64 Alpine ISO:

> Similar to standard. Slimmed down kernel. Optimized for virtual systems.

In this case it yielded this link:

https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-virt-3.18.2-x86_64.iso

If you are running on arm64 (e.g. Raspberry Pi) be sure to grab the corresponding aarch64 Alpine ISO:

https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/aarch64/alpine-virt-3.20.3-aarch64.iso

ftp will grab it easily and quickly.

$ cd /home/cosmic/vmm
$ ftp $ALPINE_ISO_URL

The key things I wanted to note:

This will need to be edited as root. An example file can be read here:

$ less /etc/examples/vm.conf

Here's my /etc/vm.conf with disk commented out since we need to boot the ISO first:

vm "alpine" {
    boot device cdrom # disk
    cdrom "/home/cosmic/vmm/alpine-virt-3.20.3-aarch64.iso"
    disable
    disk "/home/cosmic/vmm/alpine-virt-aarch64.qcow2"
    interface tap0 {
        up
    }
    owner cosmic:wheel
    memory 256M
}

$ doas vmd -dnv
configuration OK

I chose to use openntpd as my NTP server, I like OpenBSD software (as you might be able to tell). Supposedly chrony is more accurate, e.g. subsecond precision, but that doesn't matter for me. Kinda silly but it also reminds me of "crony":

While a crony is basically just a good pal or sidekick, the word sometimes has a negative connotation — that you and your crony are up to no good together.

You can test dhcp before running alpine-setup with udhcpc eth0. Make sure eth0 is up first.

With Alpine running successfully, we can install Docker now:

# visudo
Add this line: user ALL=(ALL) ALL

apk add docker docker-cli-compose

Back to top ↑