Learn NetBSD - Virtualization & Cloud (NVMM, Xen)
Series/Learn NetBSD/Episode 18
Episode 18 of 23

Learn NetBSD - Virtualization & Cloud (NVMM, Xen)

Taking NetBSD into the virtualization world: understanding the NVMM hypervisor and its integration with QEMU, Xen's role as dom0/domU, and preparing cloud images for Vagrant and AMI.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

In episode 17 we explored the uniqueness of rump kernels. Now we climb another level — not just running a kernel in userspace, but running an entire operating system as a guest. In this episode we'll cover virtualization and cloud on NetBSD — understanding the NVMM hypervisor and its integration with QEMU, Xen's role as dom0/domU, and preparing cloud images for Vagrant and AMI.

Most modern servers run on virtualization. Understanding how NetBSD acts as both host (hypervisor) and guest is a skill that's immediately useful in the cloud and homelab world.

NVMM: NetBSD's Native Hypervisor

NVMM (NetBSD Virtual Machine Monitor) is NetBSD's own hypervisor — it runs as a kernel module (nvmm(4)) using hardware acceleration (Intel VT-x / AMD-V). It's not a replacement for QEMU; it's the engine underneath — QEMU uses NVMM as its acceleration backend, just as QEMU uses KVM on Linux.

Enabling NVMM

Loading the NVMM module
modload nvmm
Verifying the module is loaded
modstat | grep nvmm
nvmm             misc       -                 0     48

For automatic loading at boot, add it to /etc/modules.conf:

Add to /etc/modules.conf
nvmm

Warning

NVMM requires hardware virtualization support. On a physical machine, make sure VT-x/AMD-V is enabled in the BIOS. Inside a VM (nested virtualization), make sure the host hypervisor enables expose hardware virtualization.

Running QEMU with NVMM Acceleration

Install QEMU from pkgsrc:

Installing QEMU from pkgsrc
cd /usr/pkgsrc/emulators/qemu
make install clean

Run a VM with NVMM acceleration — the -accel nvmm flag gives near-native speed:

Running a VM with NVMM acceleration
qemu-system-x86_64 \
    -accel nvmm \
    -m 1024 \
    -drive file=netbsd.qcow2,format=qcow2 \
    -netdev user,id=n1 \
    -device virtio-net-pci,netdev=n1
Example QEMU output
qemu-system-x86_64: warning: Host doesn't support requested features...
VNC server running on 127.0.0.1:5900

With -accel nvmm, the guest runs with full acceleration. Without it, QEMU falls back to pure emulation mode — much slower.

Creating a Disk and Installing a Guest

Prepare a disk image, then boot the NetBSD installer as a guest:

Creating a qcow2 disk image
qemu-img create -f qcow2 netbsd.qcow2 10G
Example qemu-img output
Formatting 'netbsd.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off
Booting the NetBSD installer in QEMU
qemu-system-x86_64 -accel nvmm -m 1024 \
    -cdrom NetBSD-11.0-amd64.iso \
    -drive file=netbsd.qcow2,format=qcow2 \
    -boot d

Install NetBSD inside the guest exactly as in episode 3 — and you're running NetBSD inside NetBSD.

Xen: Server-Class Hypervisor

Xen is a community-owned type-1 (bare-metal) hypervisor, and NetBSD is one of the BSDs with the best Xen support. Its architecture:

RoleMeaning
dom0Control domain — the first domU, with full hardware access
domUGuest domain — the operating system running on top of Xen

NetBSD as dom0

NetBSD can act as a dom0 running Xen guests — including NetBSD, Linux, and FreeBSD guests. This makes NetBSD an attractive foundation for small server virtualization.

NetBSD as domU (Guest)

Conversely, NetBSD can run as a domU on top of Xen managed by another host. To run NetBSD as a domU, boot with the appropriate Xen kernel:

Lines in a Xen guest config (netbsd domU)
kernel = "/boot/xen/vmlinuz-3.14-x86_64"
ramdisk = "/boot/xen/initramfs-3.14-x86_64"
memory = 1024
vcpus = 2
disk = ['phy:/dev/vg0/nbsd-domu,xvda,w']

Xen suits environments that already use Xen infrastructure, or when you need very strict isolation between domains.

NVMM vs Xen: Which to Choose?

AspectNVMM + QEMUXen
TypeType-2 (via QEMU)Type-1 (bare-metal)
ComplexityLow — use directlyHigh — needs a Xen boot
Use caseDesktop VMs, homelab, testingData centers, many heavy guests
NetBSD integrationNative, modernTraditional, mature

For general needs — running a few VMs in a homelab or small server — NVMM + QEMU is the most practical choice.

Cloud Images: Vagrant and AMI

NetBSD provides ready-to-use cloud images for modern platforms.

Vagrant Images

Install a plugin that provides NetBSD boxes, or use an available box:

Running NetBSD with Vagrant
vagrant init generic/netbsd11
vagrant up
Example vagrant up output
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'generic/netbsd11'...

AMI Images for AWS

NetBSD is also published as an AMI (Amazon Machine Image) for AWS — available on the marketplace for a small fee. Once the instance is running, NetBSD on AWS uses the virtio drivers (episode 8: the virtio0 interface) and can be managed like any regular NetBSD server:

Checking virtio devices on a cloud instance
dmesg | grep -i virtio
Example virtio dmesg output
virtio0 at pci0 dev 4 function 0: Virtio network device

NetBSD's presence in mainstream cloud proves this system is alive — not just for enthusiasts.

Closing

In this episode 18, you've taken NetBSD into the virtualization world: understanding the NVMM hypervisor and its integration with QEMU, running guests with -accel nvmm acceleration, learning Xen's role as dom0/domU, and preparing cloud images for Vagrant and AWS AMI.

Key takeaways:

  • NVMM is NetBSD's native hypervisor — enable it with modload nvmm, then use QEMU with -accel nvmm.
  • It needs VT-x/AMD-V (or nested virtualization) — without it, NVMM won't run.
  • Xen: NetBSD can be both dom0 and domU — the choice for existing Xen environments.
  • For general use, NVMM + QEMU is more practical than Xen.
  • NetBSD is available on Vagrant and AMI for the cloud.

In the next episode, episode 19, we'll squeeze out performance: performance and optimization — tuning sysctls for the kernel, VM, and network, monitoring the system with systat and top, and comparing FFS with ZFS for storage. See you in episode 19!

Learn NetBSD - Virtualization & Cloud (NVMM, Xen) | Learn NetBSD