I wanted to experiment with the then upcoming FreeBSD 15 and decided to install it as virtual machine with bhyve on an already running bare-metal install of FreeBSD 14.2. I grabbed the latest FreeBSD-15.0-ALPHA3-amd64-ufs.raw.xz disk image and uncompressed it:
# fetch https://download.freebsd.org/snapshots/VM-IMAGES/15.0-ALPHA3/amd64/Latest/FreeBSD-15.0-ALPHA3-amd64-ufs.raw.xz # unxz FreeBSD-15.0-ALPHA3-amd64-ufs.raw.xzThen, I created this shell script to boot the virtual machine:
# cat >>vmrun15.sh <<EOF #!/bin/sh echo "Start in another terminal: cu -l /dev/nmdm0A" kldload -n nmdm bhyveload -c /dev/nmdm0B -d /root/FreeBSD-15.0-ALPHA3-amd64-ufs.raw -m 1280M -e autoboot_delay=3 fbsd15 ifconfig tap0 create ifconfig bridge0 addm tap0 bhyve -A -H -P -c 2 -m 1280M -s 0:0,amd_hostbridge -s 1:0,lpc -s 2:0,virtio-blk,/root/FreeBSD-15.0-ALPHA3-amd64-ufs.raw -s 3:0,virtio-net,tap0 -l com1,/dev/nmdm0B fbsd15 ifconfig bridge0 deletem tap0 ifconfig tap0 destroy bhyvectl --destroy --vm=fbsd15 EOFThe network interface bridge0 pre-existed on the host and comprises two physical ethernet LAN ports.
# chmod 0755 vmrun15.sh # ./vmrun15.shConnect to the virtual serial console using the shown command cu -l /dev/nmdm0A, login to the guest, and set a root password.
As the provided disk image is quite small, you might want to increase it. First, shutdown the virtual machine:
# shutdown -p nowThen, on the physical host, resize the disk image:
# truncate -s 20G FreeBSD-15.0-ALPHA3-amd64-ufs.rawEdit the vmrun15.sh script and instruct bhyveload to boot into single user mode:
bhyveload -c /dev/nmdm0B -d /root/FreeBSD-15.0-ALPHA3-amd64-ufs.raw -m 1280M -e autoboot_delay=3 -e boot_single=YES fbsd15Now, start vmrun15.sh and connect to the serial console again. Simply press enter when asked which shell you want to use:
Trying to mount root from ufs:/dev/gpt/rootfs [rw]... Enter full pathname of shell or RETURN for /bin/sh: root@:/ #Refresh the disk's size, and then resize the last partition to the maximum size:
# gpart recover vtbd0 # gpart resize -i 4 vtbd0Check the filesystem before you resize it:
# fsck /dev/vtbd0p4 # growfs /dev/vtbd0p4Now boot into multi-user mode:
# exitEdit vmrun15.sh and remove the option -e boot_single=YES again to avoid booting into single user mode next time.
In case you prefer a graphical console that you can connect to over the network, switch to VNC. Unfortunatelly, this requires the UEFI mode of bhyve for which you have to install the required firmware first:
# pkg install bhyve-firmwareThen, edit vmrun15.sh, comment out bhyveload, and give VNC a higher precedence than the serial console, i.e. assign a lower virtual PCI slot to the framebuffer device than the serial console:
#bhyveload -c /dev/nmdm0B -d /root/FreeBSD-15.0-ALPHA3-amd64-ufs.raw -m 1280M -e autoboot_delay=3 fbsd15 ... bhyve -A -H -P -c 2 -m 1280M -s 0:0,amd_hostbridge -s 4:0,lpc -s 2:0,virtio-blk,/root/FreeBSD-15.0-ALPHA3-amd64-ufs.raw -s 3:0,virtio-net,tap0 -l com1,/dev/nmdm0B -s 1:0,fbuf,rfb=0.0.0.0:5900 -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd fbsd15You might want to restrict access to VNC to your local network only. Thus, either replace 0.0.0.0 with you physical host's LAN ip address, or set up some firewall rules.