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
- FreeBSD Handbook
- FreeBSD Porters Handbook
- FreeBSD Wiki
- Freshports the place for ports and most recent commits
- bsd-hardware.info
- papers.freebsd.org the collected works of the FreeBSD community as presented at various conferences and summits
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
sysrcandservice foo <start,stop,status> pkgfor packages (notapt,pacman,yum,pkgtool,dnf,rpm,dpkg,emerge, …)cd /usr/ports && make search name=lsofto search portssysctlnot/prockldloadnotmodprobekldstatnotlsmodpciconfnotlspci/var/run/dmesg.bootfor boot logsgeom disk listnotlsblkcamcontrol devlistandgeom disk listnotlsblk
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.
- Setup ports tree
git clone https://github.com/freebsd/freebsd-ports.git /usr/ports - Depending on what version of FreeBSD, Use the quarterly branch that matches.
- Dive into a package (such as
x11-wm/dwm) and get buildingmake clean install
Ports patching
RTFM which I didn’t and got frustrated.
The patch tango:
- Go to the port
/usr/ports/x11-wm/dwmandmake extract - Head into the unpacked
workscratch dircd work/dwm-6.3 - Create copies of all the files you want to patch giving them
origextensions:cp dwm.c dwm.c.orig - Start patching
dwm.csuch aspatch -p1 -i dwm-warp-6.2.diffand so on. cdto root of the portcd ../..make makepatchwill make a single patch based on differences between*.origand the patched versions. As I only patcheddwm.cit make a patch calledfiles/patch-dwm.cmake cleangenerated patches are persistent, don’t worrymake 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-serverand 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:
- Run
makein thex11-wm/dwmbase, this will unpack a./work/dwm-6.3work dir. - Get all patches together. I bundle all my
config.hand the raw patches from suckless.org into its own repo - Go to the port
/usr/ports/x11-wm/dwmandmake extract - Head into the unpacked
workscratch dircd work/dwm-6.3 - Create copies of all the files you want to patch giving them
origextensions:cp dwm.c dwm.c.orig - Start patching
dwm.csuch aspatch -p1 -i dwm-warp-6.2.diffand so on. For convenience I bundle myconfig.hand the raw patches from suckless.org into a standalone repo cdto root of the portcd ../..make makepatchwill make a single patch based on differences between*.origand the patched versions. As I only patcheddwm.cit make a patch calledfiles/patch-dwm.cmake cleangenerated patches are persistent, don’t worrymake DWM_CONF=~/git/suckless/dwm/config.h install clean
st
Same deal as dwm embrace the Ports Collection.
x11/stermmake 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