shithub: wiki.9front.org

Download patch

ref: 54d32e12a99a1a18f16177836db32232708b49e0
parent: b0f24297767facd6e57d8f227b9bf61e62ee1d6c
author: Christos Margiolis <christos@margiolis.net>
date: Sat Nov 27 15:24:34 EST 2021

FreeBSD bhyve: Update article

--- a/freebsd-bhyve.md
+++ b/freebsd-bhyve.md
@@ -1,26 +1,94 @@
-Running 9front under FreeBSD Bhyve
-===================================
+Running 9front using bhyve(8) on FreeBSD
+========================================
 
-9front works with bhyve through the use of TianoCore uefi firmware.
+Required ports:
 
-Refer to the [FreeBSD wiki page](https://wiki.freebsd.org/bhyve/UEFI) for general
-information.
+	sysutils/bhyve-firmware
+	sysutils/uefi-edk2-bhyve
+	sysutils/uefi-edk2-bhyve-csm
+	net/tigervnc-viewer
 
-Example invocation of bhyve for running 9front:
+Add the following lines to `/etc/rc.conf`. Replace `re0` with your own
+network interface. It's good practice to assign each VM a unique `tap`
+interface in case you need to run multiple VMs at the same time. For
+simplicity's sake, this setup uses only one `tap`:
 
-	bhyve -c 2 -m 4G -w -H \
+	if_bridge_load="YES"
+	if_tap_load="YES"
+	cloned_interfaces="bridge0 tap0"
+	ifconfig_bridge0="DHCP addm re0 addm tap0"
+	ifconfig_bridge0_alias0="inet 10.0.0.1/24"
+
+Reboot your machine and then grab a [9front ISO](https://9front.org/releases/).
+
+Make a directory where you'll store everything 9front-related.
+I usually keep all my
+[bhyve(8)](https://www.freebsd.org/cgi/man.cgi?query=bhyve&sektion=8)
+VMs under a
+[ZFS dataset](https://docs.freebsd.org/en/books/handbook/zfs/):
+
+	$ cd /path/to/vms/
+	$ mkdir 9front
+	$ mv /path/to/9front_iso 9front.iso
+
+Create an empty file to be used as the VM's hard drive. 10G
+will be more than enough:
+
+	$ truncate -s 10G disk.img
+
+Make a startup script. Feel free to tweak the variable values to match your
+own setup. Obviously, when you're done installing 9front from the ISO, you'll
+be running the script without the `-s 3,...` line:
+
+	$ cat 9front_start
+
+	#!/bin/sh
+
+	name="9front"
+	cpu="2"
+	mem="2G"
+	iso="9front.iso"
+	disk="disk.img"
+	tap="tap0"
+
+	ifconfig ${tap} up
+
+	bhyve -c ${cpu} -m ${mem} -wH \
 		-s 0,hostbridge \
-		-s 3,ahci-cd,/path/to/9front.iso \
-		-s 4,ahci-hd,disk.img \
-		-s 5,virtio-net,tap0 \
+		-s 3,ahci-cd,${iso} \
+		-s 4,ahci-hd,${disk} \
+		-s 5,virtio-net,${tap} \
 		-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \
 		-s 30,xhci,tablet \
+		-s 31,lpc \
 		-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-        9front
+		${name}
 
-This will start a 9front VM and start a VNC server on port 5900 for access to
-the graphical display of the guest. When prompted for setting the monitor type
-I've found the xga driver to work the best.
+Make a shutdown script in order for bhyve(8) to close properly:
+
+	$ cat 9front_stop
+
+	#!/bin/sh
+
+	name="9front"
+	tap="tap0"
+
+	ifconfig ${tap} down
+	bhyvectl --force-poweroff --vm=${name}
+	bhyvectl --destroy --vm=${name}
+
+
+Make the scripts executable and start the VM:
+
+	$ chmod +x 9front_start 9front_stop
+	# ./9front_start; ./9front_stop
+
+
+Run vncviewer(1) to connect to the VNC display:
+
+	$ vncviewer 0.0.0.0
+
+When prompted for the monitor type during boot, choose `xga`.
 
 ## Notes