OpenBSD Virtual Machines - Beginner Guide
OpenBSD Virtual Machines - Beginner Guide
Running OpenBSD as a virtual machine is great for testing, learning, or running services isolated from your main system. Here's how.
Step 1: Install vmd (OpenBSD VM Daemon)
OpenBSD includes a built-in virtual machine system called vmd.
pkg_add vmd - installs the virtual machine daemon
After installation: Start the vmd service:
rcctl enable vmd - start vmd on boot
rcctl start vmd - start vmd immediately
Step 2: Create a Virtual Machine
Create a VM configuration file:
vmctl create name=testvm
This creates:
/etc/vmd/testvm.conf - VM configuration file
/var/vmd/testvm.disk0 - virtual disk image
View the configuration:
cat /etc/vmd/testvm.conf
Typical configuration looks like:
machtype "openbsd-74"
disk0 " /var/vmd/testvm.disk0" {
size 10G # 10 GB virtual disk
}
nmd0 "opt_nmd0" {
# Network configuration
}
Step 3: Start the Virtual Machine
vmctl start testvm - start your VM
What happens: The VM boots, and you'll see a console appear.
To connect to the VM console:
vmctl console testvm - opens the VM console interface
Alternatively, use SSH: If you set up networking in the VM config, you can SSH into the VM.
Step 4: Manage the VM
List your VMs:
vmctl list - shows all defined VMs and their status
Stop a VM:
vmctl stop testvm - gracefully stop the VM
Delete a VM:
vmctl destroy testvm - permanently delete the VM and its disk
Important: destroy removes the virtual disk file cannot be undone!
Resize the disk: Edit the configuration file and change the size, then use
vmctl stop testvm before resizing, or the changes may not take effect properly.
Step 5: Networking for VMs
By default, VMs can communicate with the host and each other.
Bridge networking: Connect the VM to your physical network interface.
In /etc/vmd.conf or per-VM config:
nmd0 "opt_nmd0" { } - enables network interface
Host-only networking: VM can only communicate with the host, not the external network.
Common use cases:
- Testing: Try OpenBSD or other OSes without affecting your main system
- Learning: Experiment with configuration changes safely
- Servers: Run development servers isolated from production
Advanced virtualization topics? Proceed to Lesson 81: Virtual Machines.
Next: OpenBSD Course Conclusion - Beginner Guide
Article author: Arthur Isaev