Installing a Linux VM on OpenBSD with vmm
Install an Alpine Linux VM in OpenBSD with vmm.
Me
371 Words 1 Minute, 41 Seconds
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.
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 vmdCreating a disk for the VM
The command below creates a disk for the VM.
# vmctl create -s 50G disk.qcow2Installing 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 alpineThe -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 alpineThe -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 alpineConfiguring 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 vmdThen, the VM can be started with the following command:
# vmctl start alpineStopping the VM
The command below stops a running VM named alpine.
# vmctl stop alpine