Want to run Ubuntu or another Linux distro virtualized in FreeBSD?
What if I told you that VirtualBox isn't needed for this?
This quick guide will run you through the necessary steps to quickly setup bhyve using
FreeBSD: vm-bhyve steps for installing Ubuntu
Here are the installation steps I used in order:
doas pkg install vm-bhyve(optional:
kldload if_bridge if_tap nmdm vmm
doas sysrc vm_enable="YES"
doas sysrc vm_dir="zfs:zroot/vms"
doas zfs create -o mountpoint=/vms zroot/vms
doas vm init
cp /usr/local/share/examples/vm-bhyve/* /vms/.templates/
vm switch create public
vm switch add public em0(change em0 to whatever your network device is)
doas vm iso https://releases.ubuntu.com/20.04.4/ubuntu-20.04.4-desktop-amd64.iso(insert URL to your distro's image here)
doas vm create ubuntu
doas vm configure ubuntu
doas vm install -f ubuntu ubuntu-20.04.4-desktop-amd64.iso(change this to your image filename)
vncviewer 127.0.0.1:5999(adjust port according to your configuration)
doas sysrc vm_list="ubuntu"(autostarts at boot)
doas vm start/stop/restart ubuntu
Configuration (adjust accordingly)
Here's the configuration I use for my setup:
loader="uefi" cpu=8 memory=16G network0_type="virtio-net" network0_switch="public" disk0_type="virtio-blk" disk0_name="disk0.img" graphics="yes" graphics_port="5999" graphics_listen="0.0.0.0" graphics_res="1600x900" graphics_wait="auto" bhyve_options="-s 20,hda,play=/dev/dsp4,rec=/dev/dsp7" xhci_mouse="yes"
A few notes:
- I couldn't get Ubuntu to install with the grub loader, so I switched to
uefi. Your case might be different if you use a different distro.
- The bhyve options are necessary to passthrough your audio. Adjust accordingly.
- The xhci mouse isn't necessary, but will enable your mousewheel.
- Graphics resolution can be adjusted to your needs.
- If you're running multiple virtual instances, you will need to use unique ports.
Unfortunately, you won't be able to use your GPU passthrough at this time (not yet supported according to docs).
There may be a way around this but I haven't figured it out yet.
This means that you're using fbuf which is fine for most tasks, but you won't be able to run anything graphics-heavy (video editing, gaming, etc.).
If this changes, I'll update this post.