Run a FreeBSD VM Locally
2024-11-20
For a while I gave FreeBSD a good run as my daily driver on a laptop, but due to hardware support I eventually grew tired of it. I needed a dongle for everything. The real disadvantage being the wifi driver was just slow. Laptop support for FreeBSD has a way to go. I am happy to see the FreeBSD Foundation is taking this seriously as something they want to actively improve. In the meantime, I would recommend FreeBSD on hardware for a standalone PC and an Ethernet connection. If you don’t have that option like me, you can run FreeBSD in VM on your local machine. This post will go through the basic steps to get that working. I did this on a Debian machine, your results may vary for other distro’s.
Download FreeBSD
Download the FreeBSD ISO here.
Navigate to your architecture. Download the iso image.
Install Virtmanager
apt install virt-manager
I was getting an odd error on startup that was fixed with:
virsh net-autostart default
This way network will always be turned on at startup.
Setup FreeBSD VM
From here you can go through the normal VM installation process for virtmanager. Select the ISO you downloaded earlier and get to work. One note is that virtmanager might not have your version of FreeBSD if it is relatively new. The solution is just to select the latest version and go from there.
I would recommend creating a nonroot user on the VM.
Mouse Support
After installing Desktop GUI packages you might run into issues with mouse support.
To get a mouse working on QEMU make sure to install these packages
pkg install utouch-kmod xf86-input-evdev
Then add this line in /boot/loader.conf
utouch_load="YES"
Then reboot the guest OS.
SSH
Another way to develop on FreeBSD is to ssh into the VM instead of relying on a GUI. This is fast and convenient.
You will need to allow ssh with your FreeBSD VM.
You can find the IP address of the VM in virtmanager. Click the lightbulb icon and go to NIC. There you can find the IP address.
Finally ssh into the nonroot user you setup earlier and you are good to go. I think there is some default setting that doesn’t allow ssh into root. You can probably turn that off if necessary.
That is it! You are now able to dev on a FreeBSD machine virtually!