Install FreeBSD-13.1 using zfsinstall

Advisory: the unattended bsdinstall process is more useful for quickly provisioning dedicated boxes.

5. Make sure user is root

Change to root.

sudo su -

6. Install FreeBSD-13.1

To install FreeBSD-13.1 run zfsinstall with configuration parameters.

/root/bin/zfsinstall [-h] -d geom_provider [-d geom_provider ...] [ -u dist_url ]
[-r mirror|raidz[1|2|3]] [-m mount_point] [-p zfs_pool_name] [-s swap_partition_size]
[-z zfs_partition_size] [-c] [-C] [-l] [-4] [-A]

Example invocations:

Single disk ada0

zfsinstall -d ada0 -s 4G -A -4 -c -p zroot

Mirror disks ada0 and ada1

zfsinstall -d ada0 -d ada1 -r mirror -s 4G -A -4 -c -p zroot

7. Complete post-install actions

Chroot to installed system.

chroot /mnt

Create a group and username, set ssh keys.

pw groupadd YOUR-USER
pw useradd -m -n YOUR-USER -g YOUR-USER -G wheel -h - -c "your name"
cd /home/YOUR-USER
mkdir .ssh && chown YOUR-USER .ssh && chmod 700 .ssh
cd .ssh
vi authorized_keys #paste in SSH pubkeys
chown YOUR-USER authorized_keys && chmod 600 authorized_keys
cd

Configure /etc/rc.conf for hostname, networking, SSH server.

A configuration suitable for Hetzner is listed below. Adapt to your settings:

vi /etc/rc.conf

hostname="yourhostname"
ifconfig_igb0_name="untrusted"
ifconfig_untrusted="up"
ifconfig_untrusted_ipv6="up"
ifconfig_untrusted_aliases="inet 1.2.3.4/32 inet6 1234::123:123:1234::2/64"
ipv6_activate_all_interfaces="YES"
static_routes="gateway default"
route_gateway="-host 6.7.8.9 -interface untrusted"
route_default="default 6.7.8.9"
ipv6_defaultrouter="fe80::1%untrusted"
sshd_enable="YES"
zfs_enable="YES"

Configure /etc/resolv.conf for DNS servers. Hetzner's are used in this example:

vi /etc/resolv.conf

search YOURDOMAIN
nameserver 185.12.64.1
nameserver 185.12.64.2
nameserver 2a01:4ff:ff00::add:1
nameserver 2a01:4ff:ff00::add:2

8. Reboot

Exit the chroot environment with ctrl-d.

Switch to the rescue console session and press ctrl-c to end qemu. Then type reboot.

9. Connect to your new server

After a few minutes to boot up, connect to your server via SSH:

ssh YOUR-USER@ip-address

Check DNS is available and then perform initial system configuration such as:

freebsd-update fetch
freebsd-update install