Why

Mostly curiosity. I’ve been a GNU/Linux and free software enthuiatist since the late 90’s and that’s not about to change. More concrete reasons:

  • GNU/Linux won the war. However…
  • The Berkeley Software Distributions are family of open UNIX-like operating systems with lineage back to AT&T UNIX
  • They come as complete and cohesive systems, not a distribution of disparate pieces
  • The BSD license is wonderfully permissive
  • Bill Joy (the father of Sun, BSD, vi, RISC)
  • Marshall Kirk McKusick
  • ZFS, DTrace and Clang
  • It feels so damn neat, tidy and robust
  • It wont be my daily driver, however it’s nice to be aware of what {Free,Open,Net}BSD each bring to the table

Handy resources

Talks

Factoids

  • The term daemon comes from Greek mythology and represents an entity that is neither good nor evil, and which invisibly performs useful tasks. This is why the BSD mascot is the cheerful-looking daemon with sneakers and a pitchfork.

Things that feel different

My Linux biases are deep rooted. It’s so fascinating to learn how the BSD’s have gone about things differently.

  • No GNU core utils, break the addiction today and get comfortable with the BSD variants
  • No systemd instead use sysrc and service foo <start,stop,status>
  • pkg for packages (not apt, pacman, yum, pkgtool, dnf, rpm, dpkg, emerge, …)
  • cd /usr/ports && make search name=lsof to search ports
  • sysctl not /proc
  • kldload not modprobe
  • kldstat not lsmod
  • pciconf not lspci
  • /var/run/dmesg.boot for boot logs
  • geom disk list not lsblk
  • camcontrol devlist and geom disk list not lsblk

Software management and ports

pkg is the way to manage binaries. Easy.

The Ports Collection is the way to manage source based builds. Its slick.

  1. Setup ports tree git clone https://github.com/freebsd/freebsd-ports.git /usr/ports
  2. Depending on what version of FreeBSD, Use the quarterly branch that matches.
  3. Dive into a package (such as x11-wm/dwm) and get building make clean install

Ports patching

RTFM which I didn’t and got frustrated.

The patch tango:

  1. Go to the port /usr/ports/x11-wm/dwm and make extract
  2. Head into the unpacked work scratch dir cd work/dwm-6.3
  3. Create copies of all the files you want to patch giving them orig extensions: cp dwm.c dwm.c.orig
  4. Start patching dwm.c such as patch -p1 -i dwm-warp-6.2.diff and so on.
  5. cd to root of the port cd ../..
  6. make makepatch will make a single patch based on differences between *.orig and the patched versions. As I only patched dwm.c it make a patch called files/patch-dwm.c
  7. make clean generated patches are persistent, don’t worry
  8. make DWM_CONF=~/git/suckless/dwm/config.h install clean

In terms of config.def.h you run make extract to extract the port. Then you copy the unmodified config file to config.def.h.orig. Now you apply the changes to config.def.h. Then go to the root of the port which should be /usr/port/x11/sterm and run make makepatch which generates a patch file in files/. The next time make patch is involved it will apply the patch for you.

Custom patches can be placed into the files dir within the port. Test the patches with make patch

init system

Poor systemd gets ragged on too much. As a Linux user that enjoys using lots of different distros (Arch, Debian, Slackware, Gentoo, Redhat, Fedora, Alpine, etc) systemd has ultimately saved me time, allowing me to focus on more interesting things like writing code.

TODO

coreutils

TODO

Scheduling

Of course there’s a crond but what’s periodic all about?

TODO

Block devices

TODO

My setup

Mostly on old T-series ThinkPads.

NFS

While FreeBSD can support ext2,3,4 family of file systems, it just felt like an anti-pattern. For example the ext2 kernel module port had GNU core utils as a dependency, which I want avoid for now. Instead use NFS today.

  • I have a rock solid Debian Buster server on my network for this kind of thing. Install nfs-kernel-server and follow the handbook for /etc/exports
  • Back on FreeBSD use the handbook
service enable nfsclient
service start nfsclient
mount busterbox:/nfs /nfs

xorg

pkg install drm-kmod
pkg install xorg xf86-input-evdev xf86-video-intel
pw groupmod video -m ben || pw groupmod wheel -m ben
echo 'kern.vty=vt' >> /boot/loader.conf
pkg intall urwfonts

Stop of quickly at the x11-font/nerd-fonts port and build it.

dwm

twm comes default with the xorg infrastructure, as it has since 1987. Respect.

Started in 1987 by Tom LaStrange, it has been the standard window manager for the X Window System since version X11R4. The name originally stood for Tom’s Window Manager

I use dwm with some patches. Unlike on a GNU/Linux distro don’t try to build from the suckless source.

The “BSD way” is to use the port x11-wm/dwm:

  1. Run make in the x11-wm/dwm base, this will unpack a ./work/dwm-6.3 work dir.
  2. Get all patches together. I bundle all my config.h and the raw patches from suckless.org into its own repo
  3. Go to the port /usr/ports/x11-wm/dwm and make extract
  4. Head into the unpacked work scratch dir cd work/dwm-6.3
  5. Create copies of all the files you want to patch giving them orig extensions: cp dwm.c dwm.c.orig
  6. Start patching dwm.c such as patch -p1 -i dwm-warp-6.2.diff and so on. For convenience I bundle my config.h and the raw patches from suckless.org into a standalone repo
  7. cd to root of the port cd ../..
  8. make makepatch will make a single patch based on differences between *.orig and the patched versions. As I only patched dwm.c it make a patch called files/patch-dwm.c
  9. make clean generated patches are persistent, don’t worry
  10. make DWM_CONF=~/git/suckless/dwm/config.h install clean

st

Same deal as dwm embrace the Ports Collection.

  1. x11/sterm
  2. make ST_CONF=/home/ben/git/suckless/st/config.h reinstall

powerd++

Reduced power management, when on a thinkpad.

pkg install powerdxx
sysrc powerdxx_enable=YES

ntp

ntpdate -v -b in.pool.ntp.org

fonts

pkg install mkfontscale
curl -L https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip -o cc.zip
unzip -d cc cc.zip
rm -f ./cc/*Windows*
cp ./cc/*.ttf /usr/local/share/fonts/TTF/
cd /usr/local/share/fonts/TTF
mkfontscale
fc-cache -f
fc-list | cut -f2 -d: | sort -u | less    # list of X11 usable font names