DragonFly BSD
DragonFly BSD is the often forgotten BSD within the family tree. While it does have some really interesting technologies behind it, such as Hammer2, it just does not have the same popularity as the other BSDs. DragonFly BSD’s main appeal are the performance metrics that it hits compared to any of the other BSDs; and while I do not feel confident enough to attempt to explain why that is, there is a page about performance on their website. It does honestly feel faster too. My installation of DragonFly BSD is running on a 2.5’’ spinning rust drive on a Thinkpad T430; and while it does feel slow, it is almost certainly because of the hard drive. Even with the spinning disk though, it does not feel that slow. I can tell it is not as snappy as any of my machines as an SSD, but that’s not really a fair comparison. It does certainly run better than my FreeBSD install on the same laptop with a similar 2.5’’ spinning rust drive though.
Installation
I had trouble booting into the install media on my T430, and after
doing some digging online I tried using the USB 3.0 ports for the
install media rather than the USB 2.0 which allowed it to boot. While
it’s a strange issue that I wasn’t really expecting, it allowed me to
get into the installation of DragonFly. The installation process is a
rather straightforward one, especially for users with any experience in
Linux or any of the BSDs. When partitioning the disk, I chose the
Hammer2 file system as it is one of the big features touted by
DragonFlyBSD’s website, however, I did run into an issue while trying to
use encrypted partitions for the file system. This was likely an issue
on my part as I did not try very hard to correct the issue, and looking
back, attempting to encrypt the efi
partition likely would
have caused issues that DragonFlyBSD may have detected and prevented. I
decided to just go with an un-encrypted file system, as I was planning
on using the machine to learn more about DragonFly and DragonFly
development rather than use it as a primary computer. The rest of the
installation process went rather smoothly without any hiccups.
System Configuration
In a lot of ways DragonFlyBSD is similar to FreeBSD and many of the
same concepts of running a FreeBSD machine will apply to DragonFly BSD.
Initially, the biggest issue was lack of WiFi, which required
downloading and enabling wpa_supplicant
, then adding the
following lines to /boot/loader.conf
to load the correct
wireless NIC drivers:
if_iwm_load="YES"
iwm3160fw_load="YES"
iwm3168fw_load="YES"
iwm7260fw_load="YES"
iwm7265fw_load="YES"
iwm7265Dfw_load="YES"
iwm8000Cfw_load="YES"
iwm8265fw_load="YES"
iwm9000fw_load="YES"
iwm9260fw_load="YES"
From here, you can configure the NIC in
/etc/rc.conf
:
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA DHCP"
The next steps for me were installing some standard tool that I like using:
# including intel video driver as it is necessary for X to work
pkg install doas neovim xorg xf86-video-intel
# configure doas
echo "permit persist :wheel" > /usr/local/etc/doas.conf
# I also downloaded my suckless tools as my 'normal' user at this point
mkdir -p ~/.config/suckless && cd ~/.config/suckless
git clone https://codeberg.org/fac3plant/st.git
git clone https://codeberg.org/fac3plant/slstatus.git
git clone https://codeberg.org/fac3plant/dwm.git
git clone https://codeberg.org/fac3plant/dmenu.git
git clone https://codeberg.org/fac3plant/slock.git
I started out only compiling dwm and st as those are the two most
important ones that are difficult to work without. Neither of them were
particularly difficult after getting the correct libraries installed and
making sure the config.mk
was set up properly. Finally put
exec dwm
in ~/.xinitrc
.
Then I was able to run xinit
normally
(xinit
was used over startx
as the
startx
command wouldn’t work for some reason), and… the
keyboard does not work while X is running. The trackpoint appears to
work, and it can click, however, I cannot use the keyboard. I also
cannot get out of my window manager as it is keyboard driven, so the
only option is a hard reset.
After messing with Xorg configs and installing several keyboard drivers, this blog post gave me the secret sauce for a working keyboard:
pkg install xf86-input-evdev
# I'm not sure why, but the keyboard only works after putting this value in /etc/sysctl.conf
echo kern.evdev.rcpt_mask=3 >> /etc/sysctl.conf
From here, the keyboard had no issues when using X.
More Suckless Utils
Most of the other Suckless utilities compiled without much issues
after modifying the config.mk
file, which is normally
something that has to be done on FreeBSD anyway as many of the library
files are located at /usr/local/lib
or
/usr/local/include
rather than /usr/X11R6/lib
or /usr/X11R6/include
. However, slstatus was rather
difficult to get working properly; specifically the
components/cpu.c
and components/battery.c
files were particularly annoying. The trick that made them compile
correctly was to modify both files at the line:
// Original line
#elif defined(__OpenBSD__)
// Modified line
#elif defined(__DragonFly__)
From here, the programs seemed to compile properly, and even run. Huzzah! Now we can install the rest of the applications that I like using:
pkg install -y firefox-esr qutebrowser emacs feh mpv groff mupdf
and proceed to configure the applications more or less the same as any other Linux distro or BSD.
Power saving
Battery life is an important aspect to any mobile device for me, so
naturally getting the most life out of the battery was appealing.
Thankfully there is a section concerning battery life on this
blog post that shows how to get some more CPU efficiency. Simply add the
following lines to /etc/sysctl.conf
:
# CPU States
hw.acpi.cpu.cx.lowest=C3 # This will make the computer run slower, but save more power (fine for my uses)
# hw.acpi.cpu.cx_lowest=C2 # This will make the computer run faster, but consume more power (may be better for some users)
Additionally, adding powerd_enable="YES"
to
/etc/rc.conf
will help with battery life some.
Unfortunately, I could not get suspend and resume to work at time of
writing.
Building and Installing Custom Kernel
While compiling a custom kernel is completely unnecessary to using the OS, it is something that I have been interested in learning more about. It also has some more practical benefits, such as speeding up the boot process and memory efficiency. Building from source is also not quite as intimidating as it sounds initially.
# Download the source tree
cd /usr/
make src-create
cd /usr/src
# Building world is required first to get the appropriate toolchain
make -j4 buildworld # replace the '4' with the number of threads you have in your CPU
make installworld # using more than one core is not necessary nor recommended for the install step
# Now build the kernel, just to make sure it will build properly
make -j4 buildkernel # again, replace the '4' to match your machine's thread count
make install kernel # again, only one core is necessary
# Copy the current kernel config to a new file
cp sys/config/X86_64_GENERIC sys/config/MYKERNEL
# Then make the desired changes
${EDITOR} sys/config/MYKERNEL
# Now build the kernel
make -j4 buildkernel kernconf=MYKERNEL
make installkernel kernconf=MYKERNEL
# You can also use faster build methods
make -j4 quickkernel kernconf=MYKERNEL
make installkernel kernconf=MYKERNEL
# View the Makefile for all of the different build options,
# as it is outlined there in more detail
There is a lot of information in the kernel config and it can be a bit overwhelming, especially for someone new to building kernels from source. However, DragonFly BSD has a page to help explain what some of the options are and what they do. It will still require some thought and knowledge of the hardware that you are using, but it does make it a bit easier to understand the plethora of configuration items in that file.
Further TODOs
The big thing that I would like to get working is suspend and resume. I know that is something that tends not to work well even on Linux, however, I have a FreeBSD install on the same laptop and suspend and resume works quite well. It would be nice to see if I can get it working to some degree in DraognFly to save on some battery power when the lid is closed.
I also could not get the volume up and down buttons to work correctly, which is not really a big deal for me as I have volume up and down bound to a key combination in DWM that I like better anyway, but it would still be worth exploring why that did not work.
Resources
These are some of the resources that I used to solve many of my issues I had with this installation. Most of the issues were straightforward enough to solve, and others took a bit of thinking and playing around with (at least for me). I will likely continue to play around with DragonFly BSD as it is an interesting OS and does appear to perform very well considering the hardware it is installed on.
- DrgonFly on Laptops
- DragonFly BSD on a Thinkpad T480s: This blog post was a good place to get started with configuring my T430 as some of the sticking points were similar.
- DragonFly BSD documentation: Project documentation is always a good resource to keep in mind when working on resolving issues.