Last weekend I installed FreeBSD on a 6th generation ThinkPad (released in 2018) and I was surprised to learn 2 things: first, how easy it is to install it on this machine, and second, how enjoyable and stable FreeBSD is as a computing environment.
And I wanted to verify if what Jason Dixon said in 2007 was still true, that is, that BSD was dying. Long story short: it isn’t.
This post contains some notes I took during the process of installing FreeBSD; they may sound redundant or uninteresting to those who are familiar with the system, but I am a complete noob in the subject.
Before the Installation
I dutifully downloaded the image for USB drives called FreeBSD-14.0-RELEASE-amd64-memstick.img
.
I then proceeded to burn the image file using the usual command required to do that (on Fedora 40 at least):
# dd if=FreeBSD-14.0-RELEASE-amd64-memstick.img \
of=/dev/sda bs=1M conv=sync
Of course, at my first try I made the mistake of burning it into a partition (/dev/sda1
), instead of the whole drive (/dev/sda
), which made the device non-bootable 🤦🏼♂️.
Most importantly, I kept a browser window on my Fedora laptop, showing the FreeBSD Handbook at all times. Let me be clear: as far as documentation goes, the FreeBSD Handbook is a beacon of hope; it’s one of the greatest, best-written, most comprehensive manuals I’ve seen in a while.
Installation
Insert the USB drive, boot the machine, and press Enter when prompted to launch the boot menu. Press F12
to use other booting devices, and select the USB drive.
I installed FreeBSD using the defaults, as well as adding access to my Wi-Fi network and creating a user for myself (henceforth referred to as $USERNAME
). Nothing out of the ordinary.
After the installation (which took less than 2 minutes) the machine rebooted, and I was greeted with a laconic prompt. As expected.
After the Installation
I logged as root
and tried to install some packages. I was quickly greeted with a cryptic error, and after some online searching I found out I could solve it by editing a configuration file and changing the pkg+http
option into simply http
in the url
field:
# vi /etc/pkg/FreeBSD.conf
I proceeded to install some packages for a decent CLI experience:
# pkg install sudo tmux bash zsh vim git bat eza \
htop orpie gohugo mc tig hs-pandoc \
the_silver_searcher python fpc go rust dotnet \
podman restic musikcube freecolor
(Yes, there’s a preview version of Podman for FreeBSD! Even if, sadly, it does not support rootless mode yet.)
The FreeBSD package manager is extremely fast and provides some neat features, such as searching packages using pkg search
.
I added my personal user to the video
and wheel
groups:
# pw groupmod video -m $USERNAME
# pw groupmod wheel -m $USERNAME
You can verify the changes to make sure everything’s fine:
# id $USERNAME
# pw group show video
# pw group show wheel
Use the visudo
command to give sudo
rights to the wheel
group (towards the bottom of the file).
I then logged out as root
and continued with my own $USERNAME
.
I changed my shell to zsh and installed oh my zsh and TPM.
$ chsh -s $(which zsh)
Finally, I also installed pip3
with Python, but this installed it in ~/.local/bin
, so I needed to add that to the PATH
variable:
$ python -m ensurepip --upgrade
Desktop Environment
I wanted to install a GUI desktop environment, but I did not want to spend ages on the process, nor to end up with a behemoth eating all of my laptop resources. So I decided to stick to X11 instead of Wayland, and to install Xfce instead of GNOME or KDE. This combination proved faster to install, simpler to configure, and very lightweight in general. I have been installing and using Xfce in various systems since 2006, and I really like its minimalism.
First, I installed some required packages and added the Intel driver to the boot process:
# pkg install xorg drm-kmod xfce lightdm lightdm-gtk-greeter
# sysrc kld_list+=i915kms
I then followed the very detailed instructions to configure Xfce, including adding it to /etc/rc.conf
.
Reboot the machine, login, and voilà! You’re in Xfce. I added some more apps, for screenshots and screen recordings:
# pkg install simplescreenrecorder xfce4-screenshooter xfce4-taskmanager
If available, Xfce automatically launches xfce4-screenshooter
when you press the “Print Screen” key on your keyboard.
And some mandatory productivity applications:
# pkg install firefox keepassxc libreoffice gimp inkscape \
filezilla signal-desktop mplayer vlc ghostwriter chromium \
lazarus-gtk2 calibre dosbox abiword transmission font-manager
Ghostwriter is a neat Markdown editor from the KDE project. And I was very pleased to find so many common apps available for FreeBSD!
(Yes, I also regularly use Word for DOS, Lotus 1-2-3, and Turbo Pascal 7 on DOSBox. No comments.)
I also set some shortcuts on the “Keyboard” tab of the “Applications / Settings / Window Manager” settings screen, to display the desktop, move between workspaces, and such, matching my previous GNOME mental muscle memories.
Finally, I selected a new theme for my desktop from this list called Skeuos. Oh, and I added this item to the Xfce panel to switch light and dark themes easily.
Tips and Tricks
Here go some tips and tricks that helped me work more efficiently on FreeBSD.
Screen Brightness
The screen brightness buttons weren’t working off-the-box, so I tried to figure out how to change that. I first learned that there is a command to modify the screen brightness, conveniently named backlight
:
$ backlight -f /dev/backlight/backlight0 100
$ backlight -f /dev/backlight/backlight0 0
It works, but let’s be honest, it’s not very practical. And I have a few dedicated buttons for that on my keyboard, so why not use them?
One of the answers of this question prompted me to create two scripts: ~/.local/bin/bright-up.sh
and ~/.local/bin/bright-down.sh
with the following contents:
#!/usr/bin/env bash
backlight + 5
and
#!/usr/bin/env bash
backlight - 5
Then I went to “Applications / Settings / Keyboard” and in the “Application Shortcuts” tab added new entries, to be associated to the proper keyboard shortcuts.
An important thing to remember: when adding these items, do not use ~/.local/bin
as a prefix but the full path, otherwise Xfce won’t find the scripts and the trick won’t work. Also, remember you might need to log out and in from Xfce to apply changes.
Sleep & Wake
To my astonishment, it worked out-of-the-box. However, for some reason, every time I woke up my computer, the “Display” settings screen would appear. A quick DuckDuckGo later brought up a solution that immediately worked.
Wi-Fi
Most of the Wi-Fi configuration can be done on the terminal, even if it is a bit cumbersome. Modify the Wi-Fi network connections by editing the /etc/wpa_supplicant.conf
file, and then call the service netif restart
command. You can also scan for networks using the ifconfig wlan0 scan
command.
However, to get a visual indication of my Wi-Fi status, I installed pkg install networkmgr
and rebooted the computer. Xfce now displayed a handy icon showing the strength of the signal and other goodies.
Audio
The installation detected everything on my laptop (proof of that was that the beep
command on the terminal did, indeed, beep), but Xfce missed adding the on-screen volume controls, however, and for that I installed some plugins (which required a reboot):
# pkg install xfce4-pulseaudio-plugin-0.4.8_2 \
xfce4-mixer-4.18.1_4 xfce4-volumed-pulse
And now the volume buttons on my keyboard also work as required.
Visual Studio Code
I followed these instructions to install Visual Studio Code, and it worked.
Visual Studio Code uses Electron, which is a dependency currently banned from FreeBSD packages. This means you must build it from scratch using ports. But I didn’t select the ports infrastructure when installing FreeBSD, so I had to bootstrap the whole thing from scratch:
# pkg install portsnap
# portsnap fetch
# portsnap extract
# cd /usr/ports/editors/vscode
# make install clean
It takes a looooong time (we’re talking about 8 hours of grinding here), mostly due to the sheer number of dependencies to download (including Electron, Chromium, and, I kid you not, I even saw a tarball of the Linux kernel being downloaded at some point), but hey, it just works.
Muscle memory warning: the CLI command is vscode
instead of code
.
Joplin
I tried to install the terminal version of Joplin, my preferred note app, but without success at the moment of this publication. Again, it’s an Electron app, so it might have the same issues as VS Code at this point in time.
Trivia
I learned that the BSD watch
is not the same as the GNU watch
: I had to pkg install gnu-watch
to get the one from Linux on FreeBSD system (source).
Something similar happens with the make
command; the Makefiles I’ve traditionally created and used on Linux require the GNU version, available as the gmake
package on FreeBSD; install it and just remember to gmake stuff
instead.
You can start Signal Desktop directly on the tray by using the signal-desktop --start-in-tray
command.
The vcpkg package manager for C and C++ can be installed and built on FreeBSD 14 off-the-box. This means that I can compile and run my Conway C and C++ implementations without any changes!
I also found out you can format USB drives with FAT32 using this command:
# newfs_msdos /dev/da0s1
Vim Configuration
OK, not really a FreeBSD-specific thing, but after installing Vim, a few tweaks on .vimrc
made it even better:
" Drop vi compatibility
set nocompatible
" Show line numbers
set number
" Cursor line highlight
set cursorline
" Syntax highlighting
syntax on
" Better searching
set incsearch
set ignorecase
set hlsearch
" Color
color blue
" Backspace behavior
set backspace=indent,eol,start
Next Steps
Stuff that I will be trying next:
Conclusion
In general, I found FreeBSD very enjoyable to use: solid, stable, snappy, fast, and lightweight: a full system with Xfce requires less than 3 GB of RAM, and the whole thing uses around 10 GB of disk space including productivity apps and ports!
I’ve been using it as my daily driver for a whole week now, and so far I’m loving it.