FreeBSD Bhyve Virtualization
vermaden.wordpress.com
vermaden.wordpress.com
# vm list
NAME DATASTORE LOADER CPU MEMORY VNC AUTO STATE
access default bhyveload 2 8G - No Stopped
cicd default bhyveload 2 6G - No Running (33065)
feeds default grub 2 4G - No Running (35227)
gate default bhyveload 2 4G - Yes [1] Running (21012)
k8s-master0 default grub 2 4G - Yes [4] Running (1543)
k8s-node0 default grub 6 64G - Yes [5] Running (9988)
mail default bhyveload 3 8G - Yes [3] Running (87082)
ml default grub 4 24G - No Running (64236)
registry default bhyveload 2 2G - No Running (47712)
repos default bhyveload 2 2G - No Running (14767)
web default bhyveload 2 4G - Yes [2] Running (92365)
Other than that, I use bhyve on my laptop daily since around 2015-2016. It was somewhat painful at first. I had to bake a CD key into Windows ISO for headless install but now VNC support exists and it's easy to output any graphical installer via VNC.bhyve doesn't offer API and has not the most user-friendly interface (vm-bhyve[1] for the rescue!) but overall, I couldn't be happier with its - typical for FreeBSD - set-and-forget stability.
In previous company we pretty much went from Proxmox to bare tools once we got the hang of it.
> I was able to start FreeBSD 13.2 installation … but it got frozen at the kernel messages and nothing more happened.
If you notice at the bootloader screen, it says something like "5. Cons: Dual (Serial primary)"
Pressing the 5 key at the bootloader screen will toggle the output from "Serial primary" to "Video primary" or something to that effect. Once you toggle this setting, it should fix the output hanging and you should get a login prompt.
The other way to fix this problem, is through the virt-manager menu, you can simply switch the view from Graphical Console, to the Serial Console. Under View -> Consoles -> Serial 1
Hope this helps make your experience a little better under virt-manager.
If it will work out I will update the article and maybe even probably add another dedicated virt-manager/libvirt Bhyve article.
Regards, vermaden
Probably when I would force that upon the FreeBSD loader(8) maybe it will work - but there are other issues.
The Network Type 6 is not supported - so I was not able to create a NAT.
I could start a VM without any networks - but that would render then unusable for me.
I will try again in the future when the libvirt(8) driver for Bhyve is better implemented and more complete.
Regards, vermaden
Bhyve virtualization is of special interest to me, as I'm in the process of writing my own little (small-time, amateur-use only) wrapper for bhyve. Essentially a re-implementation of a subset of churchers/vm-bhyve in python.
I was under the impression that virtio-blk + zvols were the best option for storage (although I didn't do any tests so far, just a naive assumption)! Will definitely explore the nvme + raw-file route now.
Too bad I don’t know nearly enough about rust, bhyve, openbsd or illumos to ever come close to get this working.
Thanks for the heads up. Will probably ditch this effort.
Really want to play around with some of the oxide stuffs but it’s hard with illumos not supporting nested virt.
I guess the reality is in a year or two I'll land on fedora and proxmox or something. I have seen plenty of interesting content on proxmox and PCIE passthrough, but very little showing actual pro users with this kind of set up so the MacOS workstation VM idea might not be as practical as I'm hoping.
I heard the apple silicon platform is a bit tighter but that can't really be virtualized on x86.
Dropping the links below:
To my slight surprise, PCIe passthrough was device dependent, ie not all PCIe devices were supported. I'm running TrueNAS which runs a slightly older FreeBSD kernel, and from what I could gather GPU passthrough would not work there. IIRC the latest FreeBSD has some support for that.
But network cards should work, and NVMe's definitely work.
However it wasn't straight sailing. Using the approach from the wiki[1] did not work directly, I had to mask the devices using a pre-init boot script with
devctl set driver -f nvme1 ppt
[1]: https://wiki.freebsd.org/bhyve/pci_passthruI can create a jail, pass bHyve to it, allocate resources limits, assign a virtual nic enabling the jail to utilise firewalls. And then hand the jail IP to a client. Enabling them to create as many virtual machines their resources allows.
Using Jails this itself enables another level of security.
As if a VM hack breaks free, itself is then only isolated to the jail. And, if I was to be truely paranoid I could create a fortress jail with sub jails with a jail in the sub jail allowing bHyve to operate within.
Backups are only a matter of backing up the jail. ZFS does this without sweat.
Another hack was one where you could use tcsh shell and /etc/login launching an application as a man in the middle to limit and launch a process with cpu limits.
[0] https://klarasystems.com/articles/controlling-resource-limit...
Otherwise, a super and very complete guide. Well worth bookmarking if you want to do virtualised os on FreeBSD.
And some of the complex multiple network device configurations, I had iohyve administered virtuals with a backend filestore network as well as a front door.
Iohyve used zfs environment vars embedded in the FS to hold configuration which was clever, arguably too clever.
- /dev/zvol/zroot/iohyve/VMNAME/disk0
So the migration would be:
- create your new VM with disk of the same size
- check your new VM disk place at 'vm-bhyve':
# vm info VM | grep system-path
system-path: /vm/VM/disk0.img
- copy contents of 'iohyve' disk into VM disk # dd bs=1m if=/dev/zvol/zroot/iohyve/VMNAME/disk0 of=/vm/VM/disk0.img
- start your new VMThis should work.
Same with libvirt/virt-manager - just copy your VM image from /var/lib/libvirt/images/ dir and it should work the same.
Hope that helps.
Hope that helps.
If you read https://github.com/openzfs/zfs/issues/11407
It should be in there somewhere.
Dataset plus raw file will almost always be faster though due to the rest of the issues mentioned