For best results:
- Use only a single core per VM (cpus setting). This is critical, more causes problems.
- Set the sysctl.conf settings below
Add to /etc/sysctl.conf
and reboot
# VIRTUALBOX aio(4) SETTINGS
# https://vermaden.wordpress.com/2022/04/
vfs.aio.max_aio_queue_per_proc=65536
vfs.aio.max_aio_per_proc=8192
vfs.aio.max_aio_queue=65536
vfs.aio.max_buf_aio=8192
then reboot.
Install and configure Virtualbox as follows:
pkg install virtualbox-ose
service vboxnet enable
(sudo) pw groupmod vboxusers -m <username>
mkdir -p /usr/local/etc/vbox
vi /usr/local/etc/vbox/networks.conf
(add, with asterisk; this is extremely broad)
* 0.0.0.0/0
Symlink to expected file (may be fixed in future)
mkdir -p /etc/vbox
ln -s /usr/local/etc/vbox/networks.conf /etc/vbox/networks.conf
Add to /etc/rc.conf because the host needs to be a router for private networks in Virtualbox to get internet access
gateway_enable="YES"
Restart networking (may pause ssh session for a bit)
sudo service netif restart && sudo service routing restart
Start virtualbox networking
service vboxnet start
Note: these directories could be ZFS datasets!
mkdir /iso
mkdir /vms
Download install media
fetch https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/FreeBSD-13.1-RELEASE-amd64-disc1.iso -o /iso/FreeBSD-13.1-RELEASE-amd64-disc1.iso
VBoxManage createvm --ostype FreeBSD_64 --register --basefolder /vms --name "servername"
VBoxManage modifyvm "servername" --memory 8192 --ioapic on --cpus 1 --chipset ich9 --nic1 bridged --nictype1 virtio --bridgeadapter1 re0
VBoxManage createhd --size 40000 --filename "/vms/servername/servername.vdi"
VBoxManage storagectl "servername" --name "SATA Controller" --add sata --portcount 4 --bootable on
VBoxManage storagectl "servername" --name "SATA Controller" --hostiocache on
VBoxManage storageattach "servername" --storagectl "SATA Controller" --port 1 --type hdd --medium "/vms/servername/servername.vdi"
VBoxManage storageattach "servername" --storagectl "SATA Controller" --port 2 --type dvddrive --medium "/iso/FreeBSD-13.1-RELEASE-amd64-disc1.iso"
VBoxManage modifyvm "servername" --vrdeproperty VNCPassword=password
VBoxHeadless --startvm "servername" --vrde on --vrdeproperty TCP/Ports=5001
Using a VNC client, connect to hostip:5001
and login with password.
Proceed to follow the steps in the BSD installer.
During user creation, the prompt to invite user to additional groups, set wheel
here
Before reboot, exit to shell when prompted, then download your SSH public keys to:
/root/.ssh/authorized_keys
/home/username/.ssh/authorized_keys
and chown to your user, set 600 perms.
For example
mkdir .ssh
cd .ssh
fetch http://your.host.name/keys.txt -o authorized_keys
chown youruser authorized_keys
chmod 600 authorized_keys
cd ..
chmod 700 .ssh
During reboot, watch for bios level boot screen in VNC, and at that moment run the following in another terminal session
VBoxManage storageattach servername --storagectl "SATA Controller" --port 2 --medium emptydrive
Virtualbox is broken on FreeBSD-13.2, re-install virtualbox from ports is only option to get it working again