FreeBSD on my workstation



About an year ago I tried to use FreeBSD on my laptop. The installation went just fine, I’ve installed the 13.0 release with encrypted root-on-ZFS. Then I went on configuring everything, getting a graphical window manager, a browser, the email client, etc. Unfortunately, even before I finished all that, I started to see occasional system freezes that would require an hard reboot to recover.

At that time I suspected of a bug either on the graphics card driver or on the wireless driver, but I wasn’t really sure. And, worst of all, I didn’t had that much free time to learn how to debug and fix these sort of issues – my experience was mostly on the penguin side of the world. I also have a vague recollection of finding a bug report in bugzilla from someone complaining with a similar problem on a similar hardware. But life runs fast and I had to re-install my laptop with something I could use immediately, and that brought my OpenBSD back.

This week I finally took some time to try again setting up a FreeBSD box that I could use regularly. I didn’t tried my laptop again (it’s still running OpenBSD); instead I’ve used a workstation that has been sitting under my desk for a while without much use. Took me some time to set it up; FreeBSD is way more difficult to install and configure than OpenBSD! But it’s up and running now. And, for future reference, here’s a summary of what I’ve done.

Basic installation

Going through the bsdinstall(8) process was painless, probably because I didn’t had any odd requirement or any obscure hardware. Once again, I wanted the root-on-ZFS option. And since I was using the full disk for FreeBSD (there’s a second hard-drive in that box that I intent to use later for backups but hasn’t been setup yet), I simply selected “Auto (ZFS)” in the menu. Also, I’ve changed the “Encrypt Disk?” option to “YES”.

The real fun begun after the reboot. First thing: I forgot that there was no sudo(8) or doas(1) in FreeBSD base. Thus, I had to use the good old su(1) for getting the privileges required to install software and configure the system. Here’s the first thing I’ve done:

$ su -
# freebsd-update fetch
# freebsd-update install

Actually, before doing that, I’ve done the following:

# sysctl kern.vt.enable_bell=0
# echo kern.vt.enable_bell=0 >> /etc/sysctl.conf

That’s right, that terminal bell was really getting under my skin!

I did a reboot after installing those updates. And then it was time to start installing packages (I’ll eventually try ports too, but binary packages are fine for now). For doing this, FreeBSD has pkg(7), which isn’t installed in the base system either. It needs to be bootstrapped when running it for the first time:

# pkg bootstrap
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:

Then I just had to update the local copy of the repository catalogues and start installing my favourite software:

# pkg update
# pkg install tmux xorg...

Configuring X Window System

Running the X Window System obviously requires the installation of the video driver for the graphic card(s) in the system. In my case I have an old Radeon card, as I could find out by using pciconf -lv. In order to use it, here’s the runes I’ve used:

# pkg install drm-kmod
# sysrc kld_list+="radeonkms"
# echo "kern.vty=vt" >> /boot/loader.conf

With the first line all the video card device drivers were installed. I’m sure I could have saved some disk space installing only the Radeon ones, but at that time I wasn’t sure yet which was the correct driver to pick. Then, the second line makes sure my driver is loaded at boot time. Finally, that the last line, which changes the /boot/loaded.conf file, ensures that the system uses the new FreeBSD vt(4) virtual terminal console driver. Using this driver works around an issue that the old driver had, which was to leave us with a blank screen when the X Window System is closed. Anyway, that line does the magic.

Before rebooting again with the new X system running (hopefully!), I’ve also added the following:

# sysrc xdm_enable="YES"

This is because I’m running the old xdm(8) display manager. I don’t really use a desktop environment, so there’s no need for anything fancier.

Another thing I always do in all my systems is to turn the Caps Lock key in my keyboard into an extra Control key (that’s right, I’m an Emacs user!). Long time ago I used to do this with xmodmap(1) but I found a better way for doing that. In the /usr/local/etc/X11/xorg.conf.d directory, I simply create a file with a name ending in .conf (I tend to use 01-keyboard.conf), with the following content:

Section "InputClass"
     Identifier      "system-keyboard"
     MatchIsKeyboard "on"
     Option          "XkbLayout" "pt"
     Option          "XkbModel" "pc105"
     Option          "XkbOptions" "ctrl:nocaps"

And that’s it: when X starts it will load the correct keyboard layout and will give me an extra Control. No more pain in my pinky.

After a reboot, I could enjoy my new FreeBSD system. So far it’s been working flawlessly and I even had already a video call meeting using it [1]. I’m planning to try it again in my laptop to see if the issue I had is sorted out.