# pre-flight check
VBoxManage list ostypes | grep FreeBSD
# new VM
VM=FreeBSD
zfs create tank/vm/vkotal/$VM
VBoxManage createvm --basefolder /tank/vm/vkotal --name $VM --ostype FreeBSD_64 --register
# CPU
VBoxManage --nologo modifyvm $VM --cpus 8
# ~5GB HDD
VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage createhd --filename /tank/vm/vkotal/$VM/$VM.vdi --size 5120 --format VDI --variant Fixed
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd \
--medium /tank/vm/vkotal/$VM/$VM.vdi
VBoxManage list hdds | grep $VM
# DVD with the ISO
wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/13.0/FreeBSD-13.0-RELEASE-amd64-disc1.iso
VBoxManage storagectl $VM --name "IDE Controller" --add ide
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive \
--medium FreeBSD-13.0-RELEASE-amd64-disc1.iso
# boot order
VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
# RAM size
VBoxManage modifyvm $VM --memory 4000 --vram 16
# '--type gui' fails with:
# VBoxManage: error: The virtual machine 'FreeBSD' has terminated unexpectedly during startup because of signal 6
# VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
#
# running with '--type headless' executes the machine
# this was caused by empty $DISPLAY (lack of X11 forwarding in SSH)
VBoxManage startvm $VM --type gui
# once the install is over, power off the machine and detach the DVD:
VBoxManage controlvm $VM poweroff
VBoxManage storagectl $VM --name "IDE Controller" --remove
# or change the boot order:
VBoxManage modifyvm $VM --boot1 disk --boot2 none --boot3 none --boot4 none
# assign non-default RDP port
ln -s /tank/vm/vkotal/FreeBSD /var/vm/port/55665
VBoxManage modifyvm $VM --vrdeport 55665 --vrdemulticon on --vrde on
# start by using rdesktop/console
VBoxManage --nologo startvm $VM --type headless
VBoxManage --nologo controlvm $VM vrde on
# Getting the RDP port
VBoxManage --nologo showvminfo $VM | grep "VRD" | grep 'enabled'
# connect to the console
rdesktop -r clipboard:PRIMARYCLIPBOARD -k en-us vbox-machine:<PORT_NUMBER>
# Setup SSH forwarding
SSHPORT=59948
ln -s /tank/vm/vkotal/FreeBSD /var/vm/port/$SSHPORT
VBoxManage --nologo modifyvm $VM --natpf1 "ssh,tcp,,$SSHPORT,,22"
Last active
January 3, 2022 17:26
-
-
Save vladak/c938e6f1becdbe9c30a865aa5bf21dd6 to your computer and use it in GitHub Desktop.
FreeBSD on VirtualBox
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment