Notes on setting up vm-bhyve 04 May 2024

I'm replacing my general/util server at home and want to manage vm's on the new host with vm-bhyve. Setting it up is well documented, but running linux VM's still steers folks towards grub, which is not really great. These are just my notes (for later, after I forget) on using cloud images and uefi. This is a supplement to the docs, not a replacement!

I created a template, creatively named brian-linux.conf:


I'm running on ZFS, so can use sparse-zvol for storage to make disk space only soft allocated, letting me overcommit.

Now, the commands to make things happy and run some cloud images:

# Additional dependencies for vm-bhyve
pkg install cdrkit-genisoimage    # to use cloud-init
pkg install qemu-tools            # to use cloud images
pkg install bhyve-firmware        # to use uefi

# Download some cloud images to use for our VMs
vm img
vm img

vm create                               \ # C-k off comments if you copy this
    -t brian-linux                      \ # our template, from above
    -i noble-server-cloudimg-amd64.img  \ # the cloud image
    -s 50G                              \ # disk size override
    -c 4                                \ # cpu count override
    -m 32G                              \ # memory override
    -C -k ~brianm/.ssh/       \ # cloud-init ssh pubkey
    v0001                                 # vm name

Docs cover these, but reminding myself of how I configured it beyond defaults:

vm switch vlan public 4     # use vlan 4 for VMs
vm set console=tmux         # tmux for console access

Nice side effect of using cloud-init is that it logs the DHCP assigned IP address as well, so I can fire up the console and go search for it (C-b C-[ C-s Address)! Probably should write a script to extract it, to be honest.