Installing a Linux VM on OpenBSD with vmm
Install an Alpine Linux VM in OpenBSD with vmm.
375 Words, 3 Minutes
05 Mar 2024
Installing a Linux VM on OpenBSD with vmm
It's possible to run Linux (and BSD) VMs on OpenBSD using the vmm hypervisor.
Tested on OpenBSD 7.4.
Enabling VMD
Virtual machines are managed by the vmd daemon, so it's required to start it. In the example below, it's enabled too, so it will automatically start at boot.
# rcctl enable vmd
# rcctl start vmd
Creating a disk for the VM
The command below creates a disk for the VM.
# vmctl create -s 50G disk.qcow2
Installing the VM
Starting the VM
The command below starts the OS installer in a VM named alpine with 2GB of RAM. The installation will be done on disk.qcow2.
# vmctl start -m 2G -L -i 1 -c -r alpine-3.19.1-x86_64.iso -d disk.qcow2 alpine
The -L and -i 1 options are there to create a network interface between the host and the VM. If the host allows it in /etc/pf.conf, the VM could access to the Internet. The -c is to connect to the console. Then, follow the installer.
Running the VM
The command below starts a VM named alpine with 2GB of RAM, on disk disk.qcow2.
# vmctl start -m 2G -L -i 1 -c -d disk.qcow2 alpine
The -L and -i 1 options are there to create a network interface between the host and the VM. If the host allows it in /etc/pf.conf, the VM could access to the Internet.
Another option is to run the start command without the -c flag, to start the VM without attaching to the console. This way it's possible to connect to the VM via SSH, or manually attach to the console with the following command:
# vmctl console alpine
Configuring the VM in /etc/vm.conf
The VM can be configured in the file /etc/vm.conf, to avoid giving the parameters manually.
Replace disable by enable if you want vmd to start this VM at boot.
vm "alpine" { disable memory 2G disk "/home/user/path/to/disk.qcow2" local interface }
Be sure to restart vmd after updating this file:
# rcctl restart vmd
Then, the VM can be started with the following command:
# vmctl start alpine
Stopping the VM
The command below stops a running VM named alpine.
# vmctl stop alpine