FreeBSD 12.0-RELEASE (amd64)

Hardware
Motherboard: ASRock Taichi X399M (P3.32)
CPU: AMD Threadripper 2950X
CPU Heatsink: Noctua NH-U12S TR4-SP3
CPU Fans: 2x Noctua NF-F12 PWM
RAM: 4x Kingston KVR24E17S8/8 DDR4-2400 8GB ECC
Video: MSI GeForce 1050 Ti Gaming X
Audio: Creative Sound Blaster Audigy RX
Storage: 2x Samsung 970 Pro 512GB
Storage Heatsinks: 2x Scythe GELID SubZero M.2
PSU: Corsair RM750
Case: Fractal Define Mini C
Exhaust Fan: 1x Fractal Dynamic X2 GP-12
Intake Fans: 2x Fractal Dynamic X2 GP-14
Keyboard: Realforce R2TLSA-US4-BK
Mouse: Corsair Harpoon
Speakers: Creative T15 Wireless
Headphones: Audio Technica ATH-SR50BT
Monitor: ASUS PG279Q
Foreword

FreeBSD 12.0 is the first to support NUMA out of the box.

The Taichi X399M is the only Micro-ATX Threadripper motherboard, although it has quite a few issues. The BIOS often freezes upon entering it, and there's some sort of issue with the ACPI AML that prevents shutting down the computer under FreeBSD.

BIOS

Set Memory Interleave to Channel to enable NUMA support.

Optional: disable IOMMU, HPET, CSM, unnecessary components. Note that many of the hardware disable options don't actually have an effect (HD Audio, Intel Wireless, Bluetooth, etc.)

Installation

Install the ports and src base packages.

Install using Guided-ZFS.

Do not enable any services on startup. Especially do not use powerd, as it will result in a ~30% performance degradation even under 100% load.

System hardening:

clear_tmp
disable_syslogd
disable_sendmail
secure_console

Add user to the system.

Configure IPv4 and DHCP using igb0.

Configuration

Edit /etc/pkg/FreeBSD.conf using vi. Use x to delete "quarterly", press insert, replace with "release_0", press escape, press :wq, press enter.

pkg install sudo nano bash
chsh -s /usr/local/bin/bash

Create ~/.bashrc:

set +H
export HISTIGNORE="&"
export LC_ALL="en_US.UTF-8"
export PATH="$PATH:$HOME/.local/bin"
alias reset="printf '\033\143'"
alias ls="ls --color=never -p -D '%Y-%m-%d %H:%M'"
PS1="\[\e[0;31m\][\w]#\[\e[m\] "
history -w
history -c

Create ~/.bash_profile:

source ~/.bashrc

Log out and back in.

pw usermod byuu -G wheel,operator

Add to /usr/local/etc/sudoers:

byuu ALL=(ALL) ALL

Add ZFS partition:

zfs create zroot/core
zfs set mountpoint=/core zroot/core
chown byuu /core
chgrp operator /core

Add to /etc/sysctl.conf:

kern.coredump=0
kern.ipc.shm_allow_removed=1
kern.sched.preempt_thresh=224
kern.sched.steal_thresh=1

steal_thresh is essential to prevent constant stuttering under load.

Add to /etc/rc.conf:

pf_enable="YES"
dbus_enable="YES"
hald_enable="YES"
kld_list="fuse nvidia-modeset"

Create /etc/pf.conf:

set block-policy drop
set skip on lo0
scrub in all
block in all
block in quick from urpf-failed
pass out modulate state

Add to /boot/loader.conf:

kern.vt.fb.default_mode="2560x1440"
kern.vt.fb.modes.LVDS-1="2560x1440"
hw.vga.textmode="1"
hw.efi.poweroff="1"
loader_logo="beastie"

Add to /boot/device.hints any devices you want to disable.

pkg install xorg xfce mate
cd /usr/ports/x11/nvidia-driver
make install clean

Uncheck all options in the configuration. Especially the LINUX option.

pkg install nvidia-xconfig nvidia-settings
nvidia-xconfig

Edit /etc/X11/xorg.conf:

Section "ServerFlags"
  Option "AutoAddDevices" "Off"
EndSection

Section "Screen"
  DefaultDepth 30
  SubSection "Display"
    Depth 30
  EndSubSection
  Option "metamodes" "2560x1440_120 +0+0 {ForceCompositionPipeline=Off, AllowGSYNC=Off}"
EndSection

I have yet to get G-sync to actually work. So instead, 120hz without G-sync is required for ultra low motion blur to work.

Remove login message:

rm /etc/motd
touch /etc/motd

The Intel Wireless driver auto-loads even when setting hint.iwm.0.disabled=1. So force it to not load. It's a buggy driver ... attempting to kldunload it will triple fault the CPU, forcing an instant reboot. Use a CAT6 cable and igb0 instead.

mv /boot/kernel/if_iwm.ko /boot/kernel/if_iwm.ko.disabled

User Setup

chsh -s /usr/local/bin/bash

Create ~/.bashrc:

set +H
export HISTIGNORE="&"
export LC_ALL="en_US.UTF-8"
export PATH="$PATH:$HOME/.local/bin"
alias reset="printf '\033\143'"
alias ls="ls --color=never -p -D '%Y-%m-%d %H:%M'"
alias pmake="gmake -j30"
PS1="\[\e[0;32m\][\w]$\[\e[m\] "
history -w
history -c

Create ~/.bash_profile:

source ~/.bashrc

Create ~/.xinitrc:

export GTK_OVERLAY_SCROLLING=0
/usr/local/bin/startxfce4 --with-ck-launch

Package Installation

pkg install fusefs-ntfs clearlooks-phenix-theme icons-tango
pkg install gmake gdb gcc8 pkgconf qt4-moc sdl2 openal-soft
pkg install ibus ja-ibus-anthy ja-ibus-mozc ja-font-sazanami
pkg install slock firefox audacious audacious-plugins mplayer
pkg install transmission-gtk leafpad xfce4-screenshooter-plugin
pkg install gtksourceview2 p7zip lsof cabextract
cd /usr/ports/x11-fonts/webfonts
make install clean

Check the options for cleartype fonts and extra fonts.

Fix Helvetica Anti-Aliasing

Create ~/.config/fontconfig/ and ~/.config/fontconfig/fonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family" qual="any">
      <string>Helvetica</string>
    </test>
    <edit binding="strong" mode="assign" name="family">
      <string>sans-serif</string>
    </edit>
  </match>
</fontconfig>

To fix overly padded menu items in GTK3 applications, edit /usr/local/share/themes/Clearlooks-Phenix/gtk-3.0/gtk-widgets.css:

menubar, .menubar { padding: 0px; }
menu menuitem, .menu menuitem { padding: 1px; }

To allow control over window button placements, to remove the application icon which does not render on 30-bit displays, edit /usr/local/share/themes/Clearlooks-Phenix/xfwm4/themerc:

#button_layout=P|HMC

To suppress warning messages when starting Xorg:

xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled -n -t bool -s false
xfconf-query -c xfce4-session -p /startup/gpg-agent/enabled -n -t bool -s false

Touch up Xfce somewhat ... you may not use a mail reader, the about entry is unnecessary, the keyboard icon doesn't exist in Tango, and Xfce's run dialog usually fails to start.

cd /usr/local/share/applications
rm exo-mail-reader.desktop
rm xfce4-about.desktop
nano xfce-keyboard-settings.desktop
  Icon=input-keyboard
nano xfce4-run
  Exec=mate-panel --run-dialog

Patch the kernel to power off the computer properly

ACPI hangs forever, with the BIOS debug LED displaying "05" for "entering S5 state."

No amount of disabling hardware in the BIOS and drivers in /boot/device.hints will allow the computer to shut down properly.

So instead, patch the computer to shut down using EFI runtime services instead.

Modify /usr/src/sys/dev/acpica/acpi.c:acpi_shutdown_final to call efi_reset_system() during RB_POWEROFF, before AcpiEnterSleepStatePrep(ACPI_STATE_S5) is called. Modify efi_reset_system() arg1 from EFI_RESET_WARM to 2 (EFI_RESET_SHUTDOWN, though it's not defined in efi.h)

Now build and install the custom kernel:

cd /usr/src
make buildkernel -j30
make installkernel -j30
reboot

Remaining Issues

There is no longer any decent text editor, now that gedit2 is gone.

Thunar crashes constantly when creating new folders.

Xorg fails to start sometimes after logging out and back in again. Have to use Ctrl+Alt+Fn to activate another tty and recover.