A tour of FreeBSD in 2022
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
sysrc
andservice foo <start,stop,status>
pkg
for packages (notapt
,pacman
,yum
,pkgtool
,dnf
,rpm
,dpkg
,emerge
, …)cd /usr/ports && make search name=lsof
to search portssysctl
not/proc
kldload
notmodprobe
kldstat
notlsmod
pciconf
notlspci
/var/run/dmesg.boot
for boot logsgeom disk list
notlsblk
camcontrol devlist
andgeom disk list
notlsblk
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/dwm
andmake extract
- Head into the unpacked
work
scratch dircd work/dwm-6.3
- Create copies of all the files you want to patch giving them
orig
extensions:cp dwm.c dwm.c.orig
- Start patching
dwm.c
such aspatch -p1 -i dwm-warp-6.2.diff
and so on. cd
to root of the portcd ../..
make makepatch
will make a single patch based on differences between*.orig
and the patched versions. As I only patcheddwm.c
it make a patch calledfiles/patch-dwm.c
make clean
generated 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-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
:
- Run
make
in thex11-wm/dwm
base, this will unpack a./work/dwm-6.3
work dir. - Get all patches together. I bundle all my
config.h
and the raw patches from suckless.org into its own repo - Go to the port
/usr/ports/x11-wm/dwm
andmake extract
- Head into the unpacked
work
scratch dircd work/dwm-6.3
- Create copies of all the files you want to patch giving them
orig
extensions:cp dwm.c dwm.c.orig
- Start patching
dwm.c
such aspatch -p1 -i dwm-warp-6.2.diff
and so on. For convenience I bundle myconfig.h
and the raw patches from suckless.org into a standalone repo cd
to root of the portcd ../..
make makepatch
will make a single patch based on differences between*.orig
and the patched versions. As I only patcheddwm.c
it make a patch calledfiles/patch-dwm.c
make clean
generated 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/sterm
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