FreeBSD on a desktop, part one

Introduction and first impressions


It's been a couple of years since I've left Windows for Linux at work. I enjoy playing some of the older games, so it was much harder to ditch it at home, but ultimately I managed to do that with the help of my older laptop to run Linux on. I still keep a PC workstation with Windows around to have some fun from time to time, but I don't consider Windows to be viable option for any of the programming work I'm doing, especially considering my command line addiction.

I've been aware of BSDs existence for some time now, but haven't really considered running one myself. I think it is beneficial to know some basic stuff about them, as they have some very sweet perks that Linux don't have (like ZFS in FreeBSD kernel) or had it ported over (dtrace). In fact, the systems happily steal from each other, so the existence of BSDs (even just as a platform to research new system features) is beneficial to everyone.

In this article I'll try to give an overview of the system and point out the great things about this. I'll often reference Linux as the closest thing the reader may be familiar with.

Before the installation

Lets start with the community on the IRC, as you'll likely want to ask for some recommendations and help before or during the installation. There are close to 900 people connected to the FreeBSD and OpenBSD channels on freenode and they are very active (among the most active channels I've seen). I asked a couple of questions, some technical and some very subjective, and got satisfying responses. There seems to be a healthy competition between these two systems, but sometimes it seems to be more of a symbiosis, since the focus of these systems is completely different.

BSDs tend to have amazing documentation in form of handbooks to aid you in installation, configuration and troubleshooting. They often cover edge cases, point you to manual entries (which are great as well) and contain step-by-step instructions that are easy to follow (example: setting up jails).

Some say the system is primairly geared towards being a server OS. That is not entirely true, but even if it was, with my focus shifting towards server administration it became a nice excercise to do in a spare time. In the end, I'll need to replace my CentOS 6 on VPS sooner than later. A valid concern here is the hardware compatibility, and while it is a threat indeed, some laptop models are very well supported (mainly Lenovo Thinkpads). If your laptop is unsupported, it's not worth wasting your time trying to turn it into a desktop driver.

I've tried both OpenBSD and FreeBSD and the choice between the two was easy for me, as OpenBSD does not support my wireless card. There are also very tempting stuff on FreeBSD that I will partially discuss later, namely jails and bhyve. OpenBSD has very impressive security features tho (e.g. randomizing kernel addresses or audio recording disabled in kernel by default) so it was quite disappointing that it does not fully support my laptop. It also seems to be better suited to be used outside the server, judging from the ACPI implementations and out of the box Xorg with a dedicated X display maneger, xenodm. I won't dedicate more space in this article for discussing OpenBSD, as I've only used it for a couple of hours. From now on, let's focus on FreeBSD.

Into the inferno

The system installer is fully text-based dialog boxes but rather intuitive. You're guided through the installation smoothly and the steps are mostly straightforward. The partitioner lets you view disk changes before commiting them, so you're less likely to wipe any existing partitions in the process. A very pleasant find was the programmer Dvorak keyboard layout built in and available on the first step of the installation. One of the last steps lets you review most of your selections so that you can correct any mistake made earlier.

After the installer is finished you're greeted with the terminal password prompt, logging you in to a shell of choice specified during installation, most likely the Bourne shell or the C shell. The base system is not package dependant at all, so you'll have none installed at this point in time. A consequence of this is that it's rather hard to make the system unusable with the packages alone - even if you wipe all of them, you'll still have a system that boots just fine. This is not true for Linux distributions, which keep the kernel as a package - I've broke one last month just by updating kernel along with other stuff and it was not able to boot anymore.

The selection of software you get by default is quite limited - there's no bash, no sudo, not even vim - the vi is available, but it's the original vi you can read about in the Learning the vi Editor book from the 90s. The system utilities are all very minimalistic and focused on their tasks, like the rc to control system services, sysctl interface to kernel state or ifconfig network management tool. The last one I'm especially happy about, as it's the one I was taught at my university a couple of years back. I can't really grok the new ip tool on Linux, so I was happy to see the older tools still rolling on the system.

Taming the demon

The very first thing to do is to get familiar with the pkg, which is FreeBSD's own package management utility. The good news is it works just the way you expect it to work from the experience with other such tools. pkg search searches, pkg install installs, easy. pkg audit lets you scan installed packages for known vulnerabilities and pkg autoremove removes all packages that were installed as dependencies but are not needed anymore. The tool is lightweight and responsive, and feels modern.

You can get sudo, but most people seem to settle for doas on BSDs, which is an alternative coming from OpenBSD (by the way, a lot of awesome stuff that we use daily come from OpenBSD - check them out). The great thing about doas is that its configuration syntax is so easy that the general use case fits in a single line - permit username as root. A slightly less great thing is the lack of ability to remember the password for some time, unless you use OpenBSD.

Now, it's time to install software. You might wonder if your favourite software is available on the system. The answer to that depends heavily if the software you use is open source. If it is, it's most likely available - FreeBSD porters work really hard to keep the software available and maintained. If it's closed source, then it may be unavailable - depends on the developers. For example, Dwarf Fortress is not available on FreeBSD, but you can easily get dosbox. There's also something called Linux binary compatibility which I haven't explored yet that can address some of these concerns.

The most basic combination of programs to start working with the system would be the display server, desktop environment / window manager and the browser. You won't find many differences to Linux here - you can easily get the rather standard Xorg, Gnome and Mozilla Firefox. My road was a bit more bumpy, as I was setting up my own handcrafted environment based on dwm. I am still tuning some little things here and there, and had to make a couple of compromises along the way, like settling for side scroll with the touchpad instead of two-finger scroll, which was laggy.

The key userland differences

The system feels like Linux, which isn't surprising given that both are grouped together as Unix-like (*nix) nowadays. The differences only start to get in your way once you do some configuration and programming.

Probably the most visible and frequently mentioned difference is the directory structure. On Linux, /etc is the common place to find all the system configuration. On FreeBSD, /etc only contains configuration of the base system, while installed packages are often configured in /usr/local/etc. /sys does not contain all the kernel files, but you can get this type of data using the sysctl utility.

The total amount of packages in the system is a lot higher on Linux - my comparable OpenSUSE installation has over 2400 packages, which is four times more. There are hardly any *-dev packages on FreeBSD, libraries just come with their header files.

There's no ALSA and no systemd on FreeBSD. You get some very nice utilities for controlling sound (mixer), checking battery life (apm) and a dedicated, hardware control of backlight level for Intel graphics (intel_backlight). Some little stuff that are quite tricky to do on Linux work out of the box here, like playing mp4 in Firefox which requires some funky libraries to be installed there (and I never actually remember which ones).

Overall, there aren't really drastic changes in how you would use the parts common for both OS-es. The real difference is the design and project decisions, the implementation (which is apparently much better in BSDs) and in platform specific tools available. If you want a detailed list of pros and cons I'm sure you'll find one online with ease.

That's it for the first part, as I don't want the article to become too big and cover too many topics. For the second part I'll talk a bit more about jails and bhyve, the virtualization tools available for FreeBSD.


Comments? Suggestions? Send to feedback@bbrtj.eu
Published on 2020-07-25