For the complete documentation index, see llms.txt. This page is also available as Markdown.

34.1 Installing Windows 11 with bhyve and vm-bhyve

vm-bhyve is a command-line management tool for bhyve that wraps the underlying bhyve commands, simplifying virtual machine configuration management.

This section is based on FreeBSD 14.2-RELEASE and Windows 11 IoT Enterprise LTSC, covering the installation, environment configuration, and system image preparation of the bhyve virtual machine management tool.

Preparing the Windows Image

Windows 11 IoT Enterprise LTSC, version 24H2 (x64) - DVD (English) system download link (from MSDN I Tell You: https://next.itellyou.cn/):

The IoT version lists the Trusted Platform Module (TPM) as an optional requirement, and installation limits such as memory size are also more relaxed, lowering the deployment barrier.

SHA-256 checksum: 4F59662A96FC1DA48C1B415D6C369D08AF55DDD64E8F1C84E0166D9E50405D7A

Magnet link: magnet:?xt=urn:btih:7352bd2db48c3381dffa783763dc75aa4a6f1cff&dn=en-us_windows_11_iot_enterprise_ltsc_2024_x64_dvd_f6b14814.iso&xl=5144817664

Loading Kernel Modules

First, the kernel modules related to virtual machine management need to be loaded. vmm is the virtual machine monitor provided by the FreeBSD kernel, offering hardware-assisted virtualization support for bhyve. This module only needs to be loaded once; afterward, vm-bhyve will manage it automatically.

Tip

After a system reboot, there is no need to manually load it; vm-bhyve will automatically load this module.

# kldload vmm	# Load the FreeBSD virtual machine management module (vmm)

View the loaded vmm-related kernel modules. Among them, vmm.ko is the bhyve virtual machine monitor module, and vmmemctl.ko is the VMware memory balloon driver, which is unrelated to bhyve:

# kldstat | grep vmm
 7    1 0xffffffff83320000     44b0 vmmemctl.ko
10    1 0xffffffff83400000   33e438 vmm.ko

Next, install the Unified Extensible Firmware Interface (UEFI) firmware, Virtual Network Computing (VNC) client, and vm-bhyve management tool. The UEFI firmware provides modern boot support for virtual machines, and the VNC client is used to access the virtual machine graphical interface.

  1. Install using pkg:

  2. Or install using Ports:

Configuring vm-bhyve

Edit the /etc/rc.conf file to enable the vm service and specify the virtual machine storage directory:

Tip

The /home/ykla shown in the examples in this section is a sample path; please replace it with the actual user home directory in your environment.

Create the template path:

Copy templates to the virtual machine template location:

Next, configure the virtual network. public is the virtual switch name specified by the template, and ue0 is the current host's physical network interface name; please modify it according to your actual network card (you can check it with the ifconfig command). The virtual switch uses bridge(4) to complete network bridging, connecting the virtual machine network stack to the host's physical network interface, allowing the virtual machine to directly access the physical network.

After creation, view the newly added vm-public:

Tip

If created incorrectly, you can delete the virtual switch with the following command:

View the assigned virtual switches:

To use the xHCI mouse on hosts running FreeBSD 13.0 and above, the USB HID subsystem must be enabled. Add the following to the /boot/loader.conf file:

Related file structure:

Configuring the Virtual Machine Template

Virtual machine templates are the base configuration files for creating virtual machines. The following demonstrates how to create and configure a Windows virtual machine template.

Tip

If running a version prior to Windows 10, or when installing Microsoft SQL Server on a Windows system, you need to use the parameter disk0_opts="sectorsize=512" to set the disk sector size to 512.

Create a Windows virtual machine based on the template with a 40 GB disk:

Tip

Command to destroy a virtual machine:

The default template has issues and needs to be modified. The configuration file path is /home/ykla/vm/winguest/winguest.conf:

Note

In older versions of FreeBSD (prior to FreeBSD 14.0), /home/ is a symbolic link to /usr/home/, and both are identical.

Since FreeBSD 14, symbolic links are no longer used; the /home/ directory is used directly.

Installing the Windows System

In installation mode, vm-bhyve will wait for a VNC client to connect before starting the virtual machine, in order to capture the "Press any key to boot from a CD/DVD" prompt that Windows may display. At this point, vm list will show the virtual machine in a locked state:

Accessing Win11 via VNC

After the virtual machine starts, you must connect with a VNC client to complete the system installation:

VNC connection

After the Press any key to boot from a CD/DVD prompt appears, quickly press Enter a few times.

Tip

If you miss the key press and fall back to the UEFI Shell, stop the virtual machine and re-execute the installation steps above.

UEFI Shell

Installation interface
Installation interface
Language selection

Change the second item to "Chinese (Simplified, Mainland China)".

Language settings

Select "Chinese (Simplified, Mainland China)".

Installation start

During installation, the VNC connection may disconnect several times; reconnecting will resume the session.

In tigervnc-viewer, enter localhost, click Connect, and then press any key to continue the installation process.

Tip

To stop the virtual machine: prefer using the vm stop command to send an ACPI shutdown signal to the virtual machine. If the virtual machine is blocking the host shutdown, you can press Ctrl+C in the tty to skip the wait and force a shutdown.

If vm stop is ineffective, use the SIGTERM signal:

Wait approximately 10-30 seconds to confirm the process has exited, then run bhyvectl --destroy --vm=winguest to clean up. Only use kill -9 as a last resort if SIGTERM fails after multiple attempts (Warning: this may cause virtual machine disk data corruption).

Post-Installation Configuration

After the system installation is complete, initial configuration is required. The steps are as follows:

Region selection

Select "China".

Start the virtual machine after installation:

Open a VNC connection to proceed.

Username input

Enter a username.

Password input

Enter a password.

Repeat password

Re-enter the password.

Security questions

Enter security questions; the system will repeat this three times, requiring three different questions to be set.

Security questions

Privacy settings. Adjust as needed, then click "Accept".

Privacy settings

During installation, the system will perform updates; you can try to skip this step (testing has shown that oobe\bypassnro is ineffective), depending on your situation.

System update
System update

Chinese environment configuration:

Chinese environment settings
Chinese environment settings
Chinese environment settings
Chinese environment settings
Chinese environment settings
Chinese environment settings

Troubleshooting and Unresolved Issues

This section lists issues that may be encountered when using bhyve virtual machines and their solutions.

If you encounter problems, please restart the host first; if the problem persists, you can use ifconfig to check and remove extra network interfaces.

If the virtual machine remains in the stopped state for a long time, please check the network configuration.

View network configuration (virtual machine off):

View network configuration (virtual machine on); an additional network interface tap0 will appear:

Optional Configuration

The following are additional virtual machine management commands:

  1. View all virtual machine statuses:

  2. View a specific virtual machine status:

References

Last updated