======================================= freebsd virtualbox guest --------------------------------------- FreeBSD condo 13.1-RELEASE-p7 FreeBSD 13.1-RELEASE-p7 GENERIC amd64 NOTE: 99% of failures where the virtual machine has suddenly "aborted" is fixed with 4GB SWAP minimum. ======================================= scenario --------------------------------------- // host server is only accessible from the private network igb0: private network 192.168.52.201 igb1: public network up // guest virtual machines will use both network interfaces bridged vtnet0: private network 192.168.52.211 vtnet1: public network 222.222.222.211 ======================================= HOST install virtualbox --------------------------------------- https://www.genunix.com/o1/freebsd_virtualbox_host.txt ======================================= HOST install freebsd guest virtual machine "mojito" --------------------------------------- zfs create tank/iso cd /export/iso wget https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/freebsd-13.1-RELEASE-amd64-dvd1.iso vboxmanage --version vboxmanage list ostypes vboxmanage list bridgedifs vboxmanage list systemproperties | grep folder # create zfs volume for this virtual machine zfs create tank/vm/mojito # create the virtual machine (always keep in mind that the disk used for booting should be the one that appears first on any machine) vboxmanage createvm --name mojito --ostype freebsd_64 --register vboxmanage storagectl mojito --name SAS --add sas --portcount 30 vboxmanage createhd --filename "/export/vm/mojito/mojito-disk1.vdi" --size 30000 vboxmanage createhd --filename "/export/vm/mojito/mojito-disk2.vdi" --size 30000 vboxmanage storageattach mojito --storagectl SAS --port 0 --device 0 --type hdd --hotpluggable on --medium "/export/vm/mojito/mojito-disk1.vdi" vboxmanage storageattach mojito --storagectl SAS --port 1 --device 0 --type hdd --hotpluggable on --medium "/export/vm/mojito/mojito-disk2.vdi" vboxmanage storagectl mojito --name IDE --add ide vboxmanage storageattach mojito --storagectl IDE --port 0 --device 0 --type dvddrive --medium "/export/iso/freebsd-13.1-RELEASE-amd64-dvd1.iso" VBoxManage modifyvm mojito --nictype1 virtio --nic1 bridged --bridgeadapter1 igb0 VBoxManage modifyvm mojito --nictype2 virtio --nic2 bridged --bridgeadapter2 igb1 vboxmanage modifyvm mojito --memory 4048 --cpus 2 --vram 8 --pae on --hwvirtex on --nestedpaging on --pagefusion on --apic on --acpi on --audio none --usb off vboxmanage modifyvm mojito --vrde on --vrdemulticon off --vrdeport 5911 --vrdeproperty VNCPassword= vboxmanage showvminfo --machinereadable mojito vboxmanage startvm mojito --type headless ======================================= HOST hotplugging disks while vm is running --------------------------------------- vboxmanage createhd --filename "/export/vm/mojito/mojito-disk3.vdi" --size 30000 vboxmanage storageattach mojito --storagectl SAS --port 1 --device 0 --type hdd --medium none vboxmanage storageattach mojito --storagectl SAS --port 1 --device 0 --type hdd --medium "/export/vm/mojito/mojito-disk3.vdi" ======================================= connect vnc client to 192.168.52.201:5911 to connect to guest console --------------------------------------- - freebsd install - hostname mojito - zfs single disk stripe disk1 - boot bios+uefi - no ntpd - vtnet0: 192.168.28.211 - vtnet1: 222.222.222.211 - shutdown power off ======================================= HOST /etc/rc.conf --------------------------------------- # list of virtual machines vboxheadless_mojito_name="mojito" # space separated list of virtual machines to start at boot vboxheadless_machines="mojito" ======================================= HOST cleanup --------------------------------------- # eject installer iso vboxmanage storageattach mojito --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium emptydrive # start guest vboxmanage startvm mojito --type headless ======================================= connect vnc client to 192.168.52.201:5911 to access guest console --------------------------------------- pkg update pkg upgrade pkg install virtualbox-ose-additions VBoxService --version ======================================= GUEST /etc/rc.conf --------------------------------------- # virtualbox vboxguest_enable="YES" vboxservice_enable="YES" ======================================= GUEST configure zfs zroot and tank --------------------------------------- zpool set autoexpand=off zroot zfs set atime=on zroot zfs set checksum=sha512 zroot # create data storage zpool create -f -m /export -o autoexpand=off -O compression=lz4 -O atime=on -O checksum=sha256 tank ada1 zpool status zpool get all zfs get all zfs snapshot -r zroot@0 zfs snapshot -r tank@0 zfs list -t all ======================================= GUEST /etc/hosts --------------------------------------- 192.168.52.211 mojito 222.222.222.211 mojito.example.com mojito ======================================= GUEST install whatever else is needed --------------------------------------- # setup ssh # install packages # setup ipfw https://www.genunix.com/o1/freebsd_ipfw.txt # setup fail2ban https://www.genunix.com/o1/freebsd_fail2ban.txt ======================================= :0) =======================================