Ports¶
https://www.freebsd.org/doc/handbook/ports-using.html
download ports
portsnap fetch
extract downloads
portsnap extract
bring portsnap up to date
portsnap fetch update
Ports are installed in /usr/ports
Building a package, shown by example:
cd /usr/ports/net-mgmt/icinga2
make install
unattended install
cd /usr/ports/sysutils/screen
export BATCH=yes
make rmconfig
make install clean
Autostart¶
/usr/local/etc/rc.d
https://www.freebsddiary.org/startup.php
bhyve¶
In /boot/loader.conf
vmm_load="YES"
In /etc/sysctl.conf
net.link.tap.up_on_open=1
Then create the bridge and tap0 interface and attach it to the bridge.
It remains unclear how to do this properly, since I explicitly don't want an IP address on either the tap interface or the bridge.
Then create a ZFS device as storage for the guest. Size here is 30GiB and the zfs pool name is zroot.
zfs create -o quota=100G zroot/bhyveimages
FreeBSD Guest¶
Download FreeBSD image
cd /media/bhyveimages
fetchhttps://ftp.halifax.rwth-aachen.de/freebsd/releases/ISO-IMAGES/11.2/FreeBSD-11.2-RELEASE-amd64-bootonly.iso
Installation and starting the guest. When installation is finished, switch to the guest's shell before rebooting. Select reboot and in the bootloader choose the reboot option to break out of the shell script loop.
sh /usr/share/examples/bhyve/vmrun.sh -c 2 -m 4096 -t tap0 -d /dev/zvol/zroot/bhyveguest0 -i -I /media/bhyveimages/FreeBSD-11.2-RELEASE-amd64-bootonly.iso bhyveguest0
After successful installation, start the guest with:
sh /usr/share/examples/bhyve/vmrun.sh -c 2 -m 4096 -t tap0 -d /dev/zvol/zroot/bhyveguest0 bhyveguest0
How to start the system detached?
Unclear
iohyve¶
pkg install iohyve grub2-bhyve
iohyve setup pool=zroot
iohyve setup net=em0
iohyve setup kmod=1
vim /etc/rc.conf
iohyve_enable="YES"
iohyve_flags="kmod=1 net=em0"
iohyve fetchisohttps://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso
iohyve isolist
iohyve install bsdguest FreeBSD-12.0-RELEASE-amd64-disc1.iso
iohyve console bsdguest
exit console (~~.)
iohyve start bsdguest
iohyve stop bsdguest
iohyve set bsdguest description "VM description"
iohyve set bsdguest ram=512M cpu=1 boost=1
chyves¶
Networking is managed manually not by chyves.
chyves dataset tank install
create BSD guest¶
chyves bsdguest create 20G
cd /chyves/tank/guests/bsdguest/img/
fetchhttps://download.freebsd.org/ftp/releases/VM-IMAGES/12.0-RELEASE/amd64/Latest/FreeBSD-12.0-RELEASE-amd64.raw.xz
xz -d FreeBSD-12.0-RELEASE-amd64.raw.xz
chyves info -z
chyves network bridge0 private
chyves network bridge1 private
chyves bsdguest start
chyves bsdguest console
OpenWrt¶
chyves openwrt1 create 1g
chyves openwrt1 set loader=grub-bhyve
chyves openwrt1 set description="OpenWrt test"
mv /home/setup/openwrt-18.06.4-x86-64-combined-ext4.img /chyves/tank/guests/openwrt1/img/openwrt-18.06.4-x86-64-combined-ext4.raw
chyves network openwrt1 add tap50 bridge1
chyves network openwrt1 add tap51 bridge0
Format¶
Delete Partition¶
Example Delete partition 1 from disk ada0
gpart delete -i 1 ada0
Remove Partition Table¶
gpart destroy ada0
Create Partition Table¶
gpart create -s gpt ada0
Show Partitions¶
gpart show ada0
Create Partition (ZFS)¶
gpart add -t freebsd-zfs -b 2048 -a 4k -l log0 ada0
ZFS¶
Single Disk with ZFS¶
Add log (zil) Partition¶
Previously a partition called log0 was created with
gpart add -z freebsd-zfs -b 2048 -a 4k -l log0 ada0
Then add the write cache, this may take a while.
zpool add zroot log gpt/log0
Create Volume¶
Check if there are volumes that are no longer needed:
gpart show
Delete partitions with indices 1, 2, and 3 on device ada0
gpart delete -i1 ada0 gpart delete -i2 ada0 gpart delete -i3 ada0
Create a new ZFS partition
gpart add -t freebsd-zfs -l tank ada0
Create the ZFS pool on the new partition ada0p1
zpool create tank ada0p1
Create a ZFS volume on the pool
zfs create zroot/bhyveguest0 zfs set quota=100g zroot/bhyveguest0
Replace a Defective Disk¶
Disk wwn-0x5000039433b0843f no longer exists and should be replaced with wwn-0x500a0751e149d1e5
zpool replace tank wwn-0x5000039433b0843f wwn-0x500a0751e149d1e5
Network¶
Bridge¶
Using the example of network card alc0 and bridge name bridge0. Goes in /etc/rc.conf above the other configs
hostname="bsdrx1"
cloned_interfaces="bridge0"
ifconfig_bridge0="addm vtnet0 up"
ifconfig_vtnet0="up"
ifconfig_bridge0_ipv6="inet6 2a00:afe:3f:7::fee1 prefixlen 64 auto_linklocal"
sshd_enable="yes"
ipv6_activate_all_interfaces="yes"
ipv6_defaultrouter="2a00:afe:3f:7::3"
It is very important to append auto_linklocal, otherwise the bridge interface won't have a link-local address. This causes NDP to not respond to neighbor solicitations, which in turn means IPv6 connectivity won't work.
If you want to use DHCP on a bridge, remove this entry
~~ifconfig_bridge="DHCP"~~
and replace:
ifconfig_bridge0="addm vtnet0 up"
with
ifconfig_bridge0="addm vtnet0 SYNCDHCP"
Bridge + vlan without IP¶
Example with vlan 10 on bridge1 with physical NIC alc0
cloned_interfaces="bridge1"
ifconfig_bridge1="addm alc0_10 addm up"