Unfortunately, Hetzner removed official support for installing FreeBSD some time ago, but hopefully in the future they will include it again given the rising interest and growing support this great BSD-family OS is receiving.
Fortunately, there are several options to install FreeBSD on Hetzner dedicated servers, which I use because of their advantageous pricing, especially for backup servers where FreeBSD shines thanks to its perfect integration and native ZFS support. For example:
<ul>
<li><strong>bsdinstall/zfsinstall</strong> via <a href=”https://depenguin.me/”>depenguin.me</a></li>
<li>Hetzner community guide to install FreeBSD from Linux Rescue: <a href=”https://community.hetzner.com/tutorials/freebsd-openzfs-via-linux-rescue”>OpenZFS via Linux Rescue</a></li>
</ul>
Both work perfectly and I have used them successfully. But this time, I felt like experimenting a bit: <strong>is it possible to use the Robot’s own vKVM to directly boot a FreeBSD ISO and install without external hacks?</strong>
The short answer: <strong>Yes, it is. And with very good results, as long as you take a few precautions.</strong>
<h2>What exactly is Hetzner’s vKVM?</h2>
Hetzner does not provide a real physical KVM unless you request it, and even then only for a limited time, but they do offer another clever way to provide a low-cost KVM-like solution. It is a “virtualized” session that boots your “server” as a guest inside a temporary <strong>QEMU</strong>; this temporary QEMU/KVM passes the real disks directly to the guest without virtualizing them, which effectively allows a “classic” remote KVM session (sorry for the overloaded use of the word KVM with different meanings), assuming the OS does not complain too much about the “hardware” change in a recovery situation. To achieve this, the physical server boots into a Debian rescue system, from which the virtualized VM is launched — and here’s the good part: you can also access this temporary “hypervisor” via SSH as if it were a rescue environment and relaunch QEMU at will. Strictly speaking, we could do the same thing from a traditional rescue boot, but since everything is already preconfigured with vKVM, it saves us the extra work.
We will use this ability to relaunch vKVM however we want in order to install FreeBSD from the original ISO.
I recommend taking a look at their <a href=”https://docs.hetzner.com/robot/dedicated-server/virtualization/vkvm/”>FAQ</a>.
Here are the basic steps:
<h2>1. Prepare the FreeBSD ISO inside the vKVM host</h2>
Activate vKVM from Hetzner Robot and SSH into the provided host (the port is usually 47772). There, simply download the ISO you want:
<pre><code>cd /root
wget https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.3/FreeBSD-14.3-RELEASE-amd64-disc1.iso
</code></pre>
<h2>2. Modify the script /opt/vkvm/startqemu</h2>
This is the main trick. Each time you kill the QEMU process, Hetzner’s setup will automatically relaunch it using this script, so the best option is to <strong>modify it directly</strong> and take advantage of Hetzner’s optimized configuration for network, firewall, and port handling.
Open the file:
<pre><code>vi /opt/vkvm/startqemu
</code></pre>
You will see a long line with the original QEMU command. You must pay close attention to it to add your downloaded ISO and adjust the boot order:
– removing “<code>-boot nc</code>”
– and adding: <code>-drive if=none,id=cd0,file=/root/FreeBSD-14.3-RELEASE-amd64-disc1.iso,media=cdrom,format=raw -device ide-cd,bus=ahci0.2,drive=cd0,bootindex=0</code>
This should leave something like (don’t take this as a literal example):
<pre><code>qemu-system-x86_64 \
-cpu host \
-monitor tcp:127.0.0.1:4444,nowait,server \
-device qemu-xhci \
-device usb-tablet \
-netdev socket,fd=200,id=vnet0 \
-vnc 127.0.0.1:1,websocket=5701 \
-device ahci,id=ahci0 \
-drive if=none,id=disk0,file=/dev/sda,format=raw \
-device ide-hd,bus=ahci0.0,drive=disk0,bootindex=2 \
-drive if=none,id=disk1,file=/dev/sdb,format=raw \
-device ide-hd,bus=ahci0.1,drive=disk1,bootindex=3 \
-drive if=none,id=cd0,file=/root/FreeBSD-14.3-RELEASE-amd64-disc1.iso,media=cdrom,format=raw \
-device ide-cd,bus=ahci0.2,drive=cd0,bootindex=0 \
-smp 12 \
-machine type=q35,accel=kvm \
-m 60083 \
-device virtio-net-pci,netdev=vnet0,mac=XX:XX:XX:XX:XX:XX</code></pre>
Save it and “restart” QEMU by simply killing it:
<pre><code>pkill qemu-system-x86_64
</code></pre>
In a few seconds, you will have the FreeBSD installer running in vKVM.
<h2>3. Normal installation… with one CRITICAL exception</h2>
The installation is standard except for one detail that may leave the server without network on first reboot.
<h3>Inside the installer, the network interface is <code>vtnet0</code></h3>
This is because QEMU provides a VirtIO NIC.
<pre><code>ifconfig -a
vtnet0: flags=8843<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
</code></pre>
<h3>BUT on the real physical server, the interface will be… the real one</h3>
You will need to know which network interface and driver your server uses and locate the appropriate one in FreeBSD. In this case, it is an Intel I219-LM, for which FreeBSD uses the <strong>em(4)</strong> driver.
If FreeBSD boots trying to configure <code>vtnet0</code>… you will be without network, without access, and without SSH.
<h3>Solution: before rebooting, edit /etc/rc.conf with the correct interface name</h3>
The installer will create something like:
<pre><code>ifconfig_vtnet0=”DHCP”
</code></pre>
Change it to:
<pre><code>ifconfig_em0=”DHCP”
</code></pre>
Now you can reboot safely.
<h2>4. Reboot… and enjoy FreeBSD on real hardware</h2>
Once you exit the installer and reboot (now without vKVM), FreeBSD will boot on Hetzner’s real hardware, use your Intel interface (em0), and you will have a clean and fully native FreeBSD installation.
<h2>Conclusion</h2>
This method does not replace the others; it is simply another option I wanted to try by making use of what Hetzner offers, and I found it simple and convenient.
Being able to see the QEMU instance launched by vKVM, modify it, and boot FreeBSD from your own ISO is extremely useful and gives you a lot of flexibility.
I don’t want to finish without thanking Hetzner for their great work, although please: add official support for FreeBSD!