Running Windows - churchers/vm-bhyve GitHub Wiki
If you plan on running Windows, it is highly advised that you are running FreeBSD 11+ and use UEFI graphics support.
First of all you will need to make sure you have the UEFI firmware if not already installed:
# pkg install bhyve-firmware
Guest Configuration
Create a guest using the Windows template. This guest defaults to 2 cpus and 2GB of memory. It also uses an e1000
Intel network adapter which is supported by Windows out-of-the-box. Use the vm configure guest
command if you would like to change also configuration options.
Note that if you are running a version of Windows older than Windows 10, you will need to set the disk sector size to 512 using the
disk0_opts="sectorsize=512"
option. You also have to set the disk sector size to 512 when you want to install Microsoft SQL Server on the Windows system.
# vm create -t windows winguest
Installation
Start the installation as normal by specifying the Windows iso file. When run in install mode, vm-bhyve
will wait until a VNC client is connected before starting the guest. This allows you to catch the "Boot from CD/DVD" option that Windows may display. You can see in vm list
that the guest will show as locked at this point.
# vm install winguest Windows-Installer.iso
Once connected with a VNC client, complete the Windows installation as normal.
Adding VirtIO network drivers
While the e1000
network adapter works out of the box and allows the guest to get network access, it is recommended to use the virtio-net
device where possible. There are several ways of installing these drivers.
-
If the machine has Internet access via the e1000 device, you can download and install the virtio drivers directly in the guest. Once installed, shutdown the guest, change the device in guest configuration and restart.
-
The guest can be booted in install mode, but specifying the VirtIO ISO file.
# vm install winguest virtio-installer.iso
-
A CD device can be added to the guest and pointed at the ISO file
disk1_type="ahci-cd" disk1_dev="custom" disk1_name="/full/path/to/virtio-installer.iso"
Regarding CPUs
Some versions of Windows (most desktop versions) do not support more than one physical CPU. By default, bhyve configures every virtual CPU and a separate package.
The hw.vmm.topology.cores_per_package
sysctl can be modified to tell bhyve to create multiple cores per CPU, rather than separate packages. For example, setting this sysctl to 4 will cause a guest with 8 vCPUs to have 2 x 4 core packages.
hw.vmm.topology.cores_per_package
must be set in /boot/loader.conf (and a reboot to take effect).
On FreeBSD 12, when using vm-bhyve 1.3, it's possible to control CPU topology for each guest using configuration options -
cpu=8
cpu_sockets=2
cpu_cores=4
cpu_threads=1
About NVMe Support
As FreeBSD 12.1R, bhyve supports NVMe emulation. and for the vm-bhyve config, follow the following options: -
disk0_type="nvme"
disk0_name="disk0.img"
disk0_opts="maxq=16,qsz=8,ioslots=1,sectsz=512,ser=ABCDEFGH"
You can even install Guest to physical NVMe Disk without a virtual disk. here is an exmaple
loader="uefi"
graphics="yes"
xhci_mouse="yes"
cpu=2
memory=8G
network0_type="e1000"
network0_switch="public"
utctime="no"
passthru0="4/0/0"
4/0/0 is a passthru NVMe SSD.
Currently, NVMe boot support Windows 8.1 and latter Windows OS, if you want to boot Windows 7 from NVMe disk, follow the follwing steps:
- using ahci-hd controller to install windows 7 guest just like normal procedure.
- post installation, attach an extra disk1.img with nvme controller.
- install the Microsoft nvme patch, which is
Windows6.1-KB2990941-v3-x64.msu
andWindows6.1-KB3087873-v2-x64.msu
, make sure nvme controller and disk1 appear within windows 7 guest's device manager. - power off guest, exchange disk0.img and disk1.img in guest config. boot again.
- power off guest, remove ahci contorller and disk1.img. left the nvme controller with disk0.img, boot again. Now Windows 7 guest device manager will only have the nvme controller. no ahci controller.