vm-bhyve Pfsense
December 30, 2021
Install vm-bhyve
:
pkg add https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/vm-bhyve-1.4.2.pkg
pkg add https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/uefi-edk2-bhyve-g20210226,2.pkg
pkg add https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/uefi-edk2-bhyve-csm-0.2_3,1.pkg
pkg add https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/bhyve-firmware-1.0_1.pkg
Add to /etc/rc.conf.local
:
vm_enable="YES"
vm_dir="zfs:tank/vms"
vm_delay="5"
Create zfs tank/vms
:
zfs create tank/vms
Initialize vm
:
vm init
This should be run once after each host reboot before running any other vm commands
Create switch in pfSense
first and then using:
vm switch create -t manual -b bridge0 public
in this case
bridge0
is the name of the bridge created from the GUI interface
or crete one:
vm switch create public
vm switch add public ixl1.20
Create ubuntu template: /tank/vms/.templates/ubuntu.conf
:
loader="uefi"
cpu=2
memory=2G
network0_type="virtio-net"
network0_switch="public"
disk0_name="disk0"
disk0_dev="sparse-zvol"
disk0_type="virtio-blk"
graphics="yes"
Download ubuntu:
vm iso https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
Create VM using template ubuntu:
vm create -t ubuntu -s 40G m1
Install VM using the iso
vm install m1 ubuntu-20.04.3-live-server-amd64.iso
Use VNC client :5900
To stop/start:
vm stop m1
vm start m1
or using bhyvectl
:
bhyvectl --destroy --vm=debian
To enable on boot the VM:
sysrc vm_list="m1"
If you have multiple VM's:
sysrc vm_list="m1 m2 m3"
To get a list of VM's:
vm list