To install a Linux virtual machine (VM) on FreeBSD using bhyve and ZFS, follow these steps:
bhyve
and bhyve-firmware
packages from the package manager:pkg install bhyve bhyve-firmwareSourceww:w.lautturi.com
vm-name
with the desired name for your VM and disk-size
with the desired size of the disk:zfs create -V disk-size -s -b $(getconf PAGESIZE) -o compression=lz4 -o logbias=throughput -o sync=always -o primarycache=metadata -o secondarycache=none -o dedup=off -o copies=1 zroot/vm/vm-name
fetch http://releases.ubuntu.com/20.04/ubuntu-20.04-live-server-amd64.iso
vm: name: vm-name vcpus: 1 memory: 512M disks: - name: disk0 size: 20G zvol: zroot/vm/vm-name iso: /path/to/linux.iso bootloader: grub vnc: true vnc_port: 5900 vnc_password: password
Replace vm-name
with the name you chose for your VM, /path/to/linux.iso
with the path to the Linux ISO image you downloaded, and password
with a password for the VNC console.
bhyvectl
command to create the VM and start it:bhyvectl --create --vm=vm-name --config=vm.conf bhyvectl --start --vm=vm-name
localhost:5900
(replace 5900
with the vnc_port
specified in your configuration file). Use the password you specified in the configuration file to authenticate.Follow the prompts to install Linux on the VM. Once the installation is complete, you can use the VM like any other Linux system.
Note: Make sure to shut down the VM properly before shutting down or rebooting the host system. You can do this by connecting to the VNC console and shutting down the VM from within Linux, or by using the
bhyvectl --destroy --vm=vm-name
command.