Xen FreeBSD 14



Installing and configuring the Xen hypervisor on the FreeBSD 14 operating system.

First we need to install the Xen hypervisor, we can install it from ports or packages with the following commands:


cd /usr/ports/emulators/xen-kernel/ && make install clean




pkg install -y xen-kernel xen-tools


Next, after installing Xen, add the following to /boot/loader.conf:



xen_cmdline="dom0_mem=2048M dom0_max_vcpus=4 dom0=pvh com1=115200,8n1 guest_loglvl=all loglvl=all"


Where dom0_mem is the amount of allocated memory and dom0_max_vcpus and the number of allocated processors.


In /etc/ttys add:


xc0 "/usr/libexec/getty Pc" xterm onifconsole secure


Also add the following line to /etc/sysctl.conf:




Then we will create a network bridge, for which in /etc/rc.conf add:



ifconfig_bridge0="addm re0"




Where re0 is our network interface, then reboot the system.


After that we need to create a virtual machine, let's start by creating a virtual disk


truncate -s 50G windows.img


Then create a virtual machine configuration file windows.cfg DomU, which looks like this:


type = "hvm"

name = "win10"

memory = 4096

vcpus = 4

vif = ['bridge=bridge0']

disk = [




boot = "c" # Boot to hard disk image

#boot = "d" # Boot to ISO image

vnc = 1


To load this DomU we execute:


xl create windows.cfg


and connect to DomU using the default vnc


View the list of virtual machines xl list


To destroy execute:


xl destroy windows.cfg


If you want to enable Nested Virtualization in Xen, add the following to the configuration file:






That's it, BSD is so easy and most importantly fun!