Skip to content

Virtual Machines

Lucas Holt edited this page Feb 25, 2025 · 19 revisions

Running MidnightBSD as a guest

Proxmox

MidnightBSD 3.2+

For mouse integration: Install misc/utouch-kmod first then in Promoxmox go to Options, and uncheck Use Tablet for the pointer option.

VMWare

MidnightBSD is known to work with VMWare ESXI 7.x and 8.x, VMWare Fusion, and VMWare Workstation products.

This has been tested with MidnightBSD 2.0, 2.1, 2.2, and 3.0. We recommend you use the following settings:

Disk space: at least 30GB. For desktops, 100GB is recommended.
You can run on much less, but it limits installing packages, etc.

RAM Recommended: 3GB on i386, 4GB+ on amd64. Again, you can run on much less, but desktop use and package installs go a lot smoother with more. RAM Minimum: 1G?

For MidnightBSD 2.x, use the "FreeBSD 11" setting for the appropriate architecture. For MidnightBSD 3.x, use the "FreeBSD 12" setting for the appropriate architecture. Older versions can use the "FreeBSD 10" setting.

Install the xorg driver if you plan to run Xorg

mport install xf86-video-vmware  xf86-input-vmmouse

Also install the open-vm-tools

mport install open-vm-tools

or if not using Xorg

mport install open-vm-tools-nox11

Only VMWare fusion, sometimes you need to enable ums to get the mouse to work

In /boot/loader.conf

ums_load=“YES”

you should also add this in /boot/loader.conf

kern.hz=100

VirtualBox

VirtualBox is touchy with MidnightBSD. It can work, but you might need to tinker with settings to get the best experience. MidnightBSD 2.2.x and 3.x will run on VirtualBox 6.1. 3.2.x works on Virtualbox 7.x

Example settings: (freebsd 64bit) RAM: 1024MB Chipset: ICH9 EFI: enabled Acceleration: VT-x/AMDV, Nested Paging Audio: ICH AC97 IDE controller: sata (16GB or more) Network: Intel PRO/1000MT desktop (NAT) USB: OCHI Video: VMSVGA 16GB (legacy) or 32MB (EFI)

Install Virtualbox OSE additions

mport install virtualbox-ose-additions

Add to /etc/rc.conf

vboxguest_enable="YES"
vboxservice_enable="YES" 

Host time sync setting. Disable if you are using ntpd in the VM.

vboxservice_flags="--disable-timesync"

Xorg configuration:

Section "Device"
	Identifier "Card0"
	Driver "vboxvideo"
	VendorName "InnoTek Systemberatung GmbH"
	BoardName "VirtualBox Graphics Adapter"
EndSection

Section "InputDevice"
	Identifier "Mouse0"
	Driver "vboxmouse"
EndSection

If the driver doesn't work, you may also need to install the xf86-video-vmware package. (it seems counterintuitive by name)

mport install xf86-video-vmware

If you create a shared folder with the host system, you can mount it like this:

mount_vboxvfs -w hostsharename /mnt

bhyve

MidnightBSD will boot in bhyve on MidnightBSD hosts or FreeBSD 12.x/13.x hosts. It is extremely touchy about disk configuration, though since FreeBSD doesn't know about MidnightBSD GPT partitions. We recommend MBR/UFS2 disks.

Learn more about bhyve at https://bhyve.org/

CPU Requirements

bhyve requires a CPU that supports Intel® Extended Page Tables (EPT), AMD® Rapid Virtualization Indexing (RVI), or Nested Page Tables (NPT). Linux® guests or FreeBSD guests with multiple vCPUs require VMX unrestricted mode support (UG).

vm-bhyve

Example MidnightBSD i386 client config for vm-bhyve:

loader="bhyveload"
cpu=3
memory=4096M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
uuid="a uuid here"
network0_mac="a value here"

vm-bhyve is the recommended management software, although other solutions like cbsd should work. (untested though) https://github.com/churchers/vm-bhyve
vm-bhyve is in mports on MidnightBSD and FreeBSD ports.

Guest Operating Systems

MidnightBSD 2.x and 3.x have been widely tested on bhyve with success. 1.2.x is also known to work but can be touchy.

FreeBSD 11.x and 12.x have been booted with success. Newer versions also likely work.

On FreeBSD hosts, many additional operating systems have been tested, including Linux, OpenBSD, etc. They may work on MidnightBSD, although they have not been tested by the author. FreeBSD has a guide on setting up Linux on their virtualization docs https://docs.freebsd.org/en/books/handbook/virtualization/#virtualization-host-bhyve

Manual Configuration

Change nic below (ix0) with your nic

kldload vmm

ifconfig tap0 create
sysctl net.link.tap.up_on_open=1
ifconfig bridge0 create
ifconfig bridge0 addm ix0 addm tap0
ifconfig bridge0 up

Create a guest

truncate -s 32G guest.img
fetch https://midnightbsd.org/ftp/MidnightBSD/releases/amd64/ISO-IMAGES/3.1.0/MidnightBSD-3.1.0--amd64-disc1.iso
sh /usr/share/examples/bhyve/vmrun.sh -c 1 -m 1024M -t tap0 -d guest.img -i -I MidnightBSD-3.1.0--amd64-disc1.iso midnightguest

Restart the guest as needed

sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 1024M -t tap0 -d guest.img midnightguest

View running guests

ls -al /dev/vmm

Kill Guest

bhyvectl --destroy --vm=midnightguest

To persist across reboots

Edit /etc/sysctl.conf and add this

net.link.tap.up_on_open=1

Add the following to /etc/rc.conf

cloned_interfaces="bridge0 tap0"
ifconfig_bridge0="addm ix0 addm tap0"
kld_list="nmdm vmm"
Clone this wiki locally