OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction
      • Installing OpenBSD
      • The X Window System
      • Networking
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • Graphical Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • smtpd
          • Dovecot
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound
          • NSD
          • BIND
        • Networking
          • OpenBGPD
          • rad
          • DHCP
          • slaacd
        • Web
          • Apache
          • nginx
          • httpd
          • relayd
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • sshd
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ
        • Time
          • NTP
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Complete the First 30 Minutes After Installation
        • Check Hardware Compatibility Before Installing
        • Bootstrap Wi-Fi Firmware Without Ethernet
        • Set Up OpenBSD as a Laptop or Workstation
        • Configure Laptop Power Management
        • Run OpenBSD as a Virtual Machine Guest
        • Install OpenBSD on a VPS or Cloud Server
        • Install OpenBSD with Full-Disk Encryption
        • Troubleshoot Web Browsers on OpenBSD
        • Create an Administrator Account with doas and SSH Keys
        • Establish a Conservative Security Baseline
        • Manage OpenBSD with Ansible
        • Recover Access and Reset the Root Password
        • Collect OpenBSD Diagnostic Evidence
        • Configure Secure Remote Access with OpenSSH
        • Set Up WordPress
        • Build Third-Party Software from Ports
        • Use FIDO Security Keys with OpenSSH
        • Build OpenBSD from Source
        • Configure Wi-Fi Roaming and Wired Failover
        • Dual-Boot OpenBSD on a UEFI System
        • Troubleshoot PF, NAT, and Routing
        • Automate OpenBSD Installation with Autoinstall and PXE
        • Route Multiple VLANs with PF
        • Configure a Road-Warrior WireGuard VPN
        • Troubleshoot Package Installation and Update Failures
        • Route IPv6 Networks without NAT
        • Schedule Recurring Maintenance
        • Plan a Docker Workload Migration to OpenBSD
        • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Build a Simple Router and Firewall
        • Monitor an OpenBSD System
        • Back Up and Restore an OpenBSD System
        • Configure softraid RAID1
        • Recover an OpenBSD System That Does Not Boot
        • Install Z shell (zsh)
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • Package Search
      • Synopsis
      • Record the Virtual Hardware
      • Create the Guest
      • Install OpenBSD
      • Verify Devices in the Installed Guest
      • Configure Console and Shutdown Paths
      • Treat Snapshots as a Recovery Aid

      Run OpenBSD as a Virtual Machine Guest

      Synopsis #

      OpenBSD can run as a guest under several third-party hypervisors. The installation procedure remains the standard OpenBSD procedure, but the hypervisor controls firmware, virtual disks, network adapters, consoles, power events, and snapshot behavior.

      This guide defines provider-neutral choices and verification steps. Hypervisor product interfaces change frequently and are not reproduced here. Confirm the current OpenBSD release and the selected virtual devices before relying on a guest for production work.

      Record the Virtual Hardware #

      Before creating the guest, record:

      • the OpenBSD architecture;
      • BIOS or UEFI firmware mode;
      • virtual CPU count and memory;
      • disk controller and disk size;
      • network adapter model and network attachment;
      • graphical, serial, or provider-console access;
      • the recovery-media attachment procedure.

      Prefer simple virtual devices documented by current OpenBSD section 4 manual pages. virtio(4) documents the paravirtual device framework used by many hypervisors. Availability and behavior depend on the host product and its configured device model.

      Create the Guest #

      Use conservative initial resources and one disk. Attach the verified OpenBSD installation ISO for the selected architecture. Do not enable optional acceleration, nested virtualization, unusual storage caching, or several network adapters until the basic guest boots and installs reliably.

      Connect the first virtual network adapter to a network that provides either DHCP or recorded static settings. Maintain console access until SSH connectivity has been tested after a reboot.

      Install OpenBSD #

      Boot the installation media and follow the installation chapter . The installer should display the virtual disk and network adapter in its kernel messages. Stop and correct the virtual hardware configuration if the intended disk or network interface is absent.

      Use the automatic disk layout unless the workload requires a documented alternative. Install all sets for a general-purpose guest. Eject or detach the installation media before the first disk boot.

      Verify Devices in the Installed Guest #

      After the first boot, record the virtual devices with dmesg(8) , disklabel(8) , and ifconfig(8) .

      $ dmesg
        # Confirm the firmware, storage, network, clock, and console devices
      $ disklabel sd0
        # Confirm the installed disk and OpenBSD partition layout
      $ ifconfig
        # Confirm the virtual network interface and address
      

      Replace sd0 when the installed disk uses another name. Device names must be discovered from the guest’s own kernel messages.

      Complete the first 30 minutes , then reboot again. Confirm that the guest starts from its virtual disk, obtains the expected network configuration, and remains accessible from the hypervisor console.

      Configure Console and Shutdown Paths #

      A graphical console is sufficient for installation, but a serial console can improve headless recovery when the hypervisor exposes one. Configure it only after confirming the architecture-specific boot(8) and ttys(5) requirements. Keep the known-working console until the serial path has been tested across a reboot.

      Test a normal in-guest shutdown with shutdown(8) :

      # shutdown -p now
      

      Confirm that the host recognizes the powered-off state. Do not treat an abrupt hypervisor power-off as a normal shutdown procedure.

      Treat Snapshots as a Recovery Aid #

      A hypervisor snapshot captures virtual-disk state at a point chosen by the host. It does not automatically guarantee filesystem or application consistency. Before a planned snapshot, stop or quiesce applications that maintain important write state and allow filesystem writes to complete.

      Snapshots do not replace an independent backup because they commonly share the same storage system and administrative control plane as the guest. Maintain a guest-aware backup and test restoration separately.

      Before a base-system upgrade, confirm all three recovery paths:

      1. hypervisor console access;
      2. verified installation or ramdisk media;
      3. an independent backup of configuration and application data.

      The virtualization chapter covers OpenBSD as a virtualization host. It is distinct from running OpenBSD as a guest under another hypervisor.

      Report a bug
      • Synopsis
      • Record the Virtual Hardware
      • Create the Guest
      • Install OpenBSD
      • Verify Devices in the Installed Guest
      • Configure Console and Shutdown Paths
      • Treat Snapshots as a Recovery Aid