Debian VM on FreeBSD
bhyve(8)
is a hypervisor available on FreeBSD. I personally use vm-bhyve(8)
to manage my virtual machines because I find it a bit easier.
pkg install vm-bhyve
You need dataset for virtual machines (if ZFS is being used).
zfs create zroot/bhyve
Update system configuration (rc.conf(5)
).
sysrc vm_enable="YES" sysrc vm_dir="zfs:zroot/bhyve"
Run vm init
to finish initialisation. This will create subdirectories inside the dataset.
vm init
To enable network for the VMs create virtual switch and attach network interface to it.
vm switch create public vm switch add public re0
Now you are ready to create Debian's VM. You can use sample config for this to make it easier.
cp /usr/local/share/examples/vm-bhyve/debian.conf /zroot/bhyve/.templates/
In my case I want to use debian template (-t
) and specify disk image size (-s
) to be 40G.
The following command will create directory with config, disk image and log. This is a good moment to edit VM's config file and set things like RAM.
vm create -t debian -s 40G debian_vm
VM is now created but nothing is yet installed on it. Installation image is needed, it can be downloaded with vm iso
(it will be placed inside /zroot/bhyve/.iso/
).
vm iso https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.9.0-amd64-DVD-1.iso
Install Debian on the VM.
vm install -f debian_vm debian-12.9.0-amd64-DVD-1.iso
After the installation VM is ready to be used.
vm start debian_vm vm console debian_vm
vm(8)
uses cu(1)
, to exit console back to the host use ~^D or ~.~
.