FreeBSD install!!

  ```                        ` 
 s` `.....---.......--.```   -/
 +o   .--`         /y:`      +.
  yo`:.            :o      `+- 
   y/               -/`   -o/  
  .-                  ::/sy+:. 
  /                     `--  / 
 `:                          :`
 `:                          :`
  /                          / 
  .-                        -. 
   --                      -.  
    `:`                  `:`   
      .--             `--.     
         .---.....----.        

So I decided to install FreeBSD on a thinkpad T480 as my primary desktop. This document describes my first few days.

What?

BSD is a family of free and opensource operating systems based on the original UNIX code. Unlike Linux distributions, each BSD is it's own OS, binary incompatible with the others. They are still quite similar to Linux tho, in that they are UNIX-likes.

FreeBSD is the most popular of current BSDs.

Why?

Why BSD

Mostly curiosity. I heard some nice things about BSDs and I wanted to see how do they differ from Linux and if I like them more.

Linux is a kernel and it can't do much by itself. Many stuff are handeled by GNU tools, but despite what some basement-dwelling FSF enthusiast would like you to believe, you need a lot of other stuff as well. Systemd for init (and who knows what), alsa/pipewire for sound, ifconfig/iproute2 for networking (or network-manager on many desktops)...

This makes things quite complicated. In BSD, you either have their own programs, of if they use external tools (like ifconfig), they are integrated with the other tools, so it all feels more united and as one stable system.

Also they are supposed to be more lightweight that your avarage Linux. And I probably like lightweightness a bit too much...

Why FreeBSD

At first, I actually wanted to try NetBSD. However I just finished ptts, which is written in crystal. Crystal only supportes FreeBSD and OpenBSD, and I didn't manage to make it run with compat_linux in a VM, so that was a no for NetBSD. OpenBSD doesn't do VMs. I want to have access to a Linux VM for development purposes (and I might need Windows at some point as well), so it's FreeBSD for me.

How it went?

First steps and planning

After doing some research and testing in a VM, I decided for FreeBSD. But I also want a Linux partition. While FreeBSD has linuxulator, which is basically Wine for Linux instead of Windows, it still needs linux libraries and is not perfect. Some programs may not run in it and in some cases when performance matteres, it would be preferable to run on a actual hardware, instead of in a VM. Also what is better source of Linux libraries than an actal Linux distro?

I chose debian GNU/Linux, as I want something that I can update once in a while and then forget about it for a few months.

Turns out FreeBSD refuses to boot from Ventoy. Not a problem, as I had a unused thumbstick at hand.

Install and booting

At first, I went through FreeBSD instalation and gave it 300GB of disk space. The installer is a simple curses-based one and does the job. Some of its parts like the time zone setter or the wifi manager can be run as regular programs on a finished install, so that's nice.

I used UFS instead of ZFS for two reasons. First, in a VM it said something about running ZFS with under 8GB of RAM. 8GB is how much I have. I don't know how much does ZFS have to do with RAM, but I don't want to figure out once it's too late. Also I had ZFS on OpenSUSE I ran before the switch, but I never used any of it's features, so in the spirit of minimalism, UFS it is.

Now Linux! regular Linux install. FreeBSD bootloader cannot use boot to other OSes, so GRUB it is. Grub doesn't see FreeBSD however. After some try and error, this edit to '/etc/grub.d/40_custom' proved to work for me:

menuentry "FreeBSD" {
   set root='(hd0,2)'
   chainloader (hd0,2)/boot/loader.efi
}

hd0,2 means third (0-based indexing) partition of the first drive. The second line makes it load the FreeBSD bootloader.

This took some time tho and the first day reached its end... I did however managed to get one last compulory screenfetch:

X

On the second day I installed X.org. I decided to stick with evilwm as my window manager. While it is in ports, I compiled it from source, as I would like to make a few changes to it later. To compile it, I needed to use gmake instead of the classical make that ships with the system.

I needed to add myself to the 'video' group. Unlike on Linux, on FreeBSD everything user and group related is handeled by the 'pw' command. I cannot judge it yet, as this is all I used it for, but from the manual, it seems quite powerfull.

I followed the handbook and installed driver for my graphics card. When I called 'startx', i got this error message:

Fatal server error:
(EE) no screens found(EE)

After some searching, it turned out that I also had to install the 'xf86-video-intel' driver, which was not mentioned anywhere in the manual!

Or maybe I am just blind IDK. Anyhow, now I have a working X server, so that's nice.

Time to restore

I started by copying my dotfiles and scripts. Some needed to be rewritten for FreeBSD, as they relied on Linux stuff.

Turns out that mounting drives is harder? You have to specify the partition type, some are seperate command, some are flags. You have to either know or use external too to find out. I'm not sure how I feel about this. Well, at least ext4 is supported... as the '-t ext2fs' flag...

Also Mason for nvim doesn't work, so I will have to install LSP servers manualy. Other plugins work as intended.

I installed the SLiM login manager. It works how it should and it even comes with branded theme! X server runs on tty8, accessed by F9. ttys are numbered from 0.

I think I should also mentioned, that FreeBSD commands have no 'help' flag. It's all manpages. I'm not gonna say it's bad or anything, it's just a different approach. I often ended reading the manual anyways, so I don't really care.

One not so nice thing is that the FreeBSD grep is not the Linux grep. One of the differences is that there is no support for perl regex, so instead of one complex regex, I have to chaim multiple, maybe mix with sed or awk or something... Nothing dealbraking tho.

Graphical hell

Now it's time for graphical applications. Oh, boy!

First, GTK and QT are a LOT of packages. Not very minimal at all! Second, I spent a while trying to make a Kanagawa GTK theme, just to fail and revert to stock Dracula. QT at least has QT5ct, where you can make new theme, set colors and all just works. GTK has no such app as far as I know and it is split into multiple versions. I don't like GTK is what I'm saying.

Also I wanted a decent pdf viewer and screenshot tool. Only ones that I deemed usable were KDE Okular and Spectacle. First, that is a lot of KDE packages for installing a QT app with no desktop. Second, theming. Okular uses Kvantum theme, which is its own thing, but works and Spectacle tries to load the QT theme and fails miserably. I don't care as I barely use it, but I'm putting it here as one of the reasons I prefer working in the terminal.

I will try to not use any more KDE or GNOME apps, unless all alternatives suck.

As for the good stuff qview image viewer! Minimal, and it just works.

I ended the theming somewhere in day Three.

I installed i3lock as a screen locker. Not much to add, it just works.

Control panel

As you may have noticed, I don't use any bar. I only ever used the systemtray part, so I made a custom GTK comtrol panel in the D language to hold the few parts I care about. It relied on a lot of Linux commands, so I had to fix that.

Login

killall evilwm

shutdown

I added the following to '/usr/local/etc/sudoers':

%wheel ALL=NOPASSWD: /sbin/poweroff

It allows for all 'wheel' members to use the 'poweroff' command without the need for passowrd.

Monitor brightness:

# read
backlight -q

# set
backlight <value 0-1000>

It does not stay between reboots. I fixed this by saving the value to '~/.prev-brightness' and I set it in my '.xinitrc'.

Volume

# read speaker volume
mixer vol.volume
# read mic volume
mixer rec.volume

# set speaker volume
mixer vol.volume=<value 0-1>
# set mic volume
mixer rec.volume=<value 0-1>

Same hack as before.

The volume is not separated between headphones and speakers, so I added a key binding for muting in '.xbindkeysrc'.

This part is a bit weird however. Only mute-volume, volume-up and volume-down are recognised. The mute-volume button lights up when pressed, but it desn't do anything. It stays lit between reboots. It doesn't respond to the actual muting via:

mixer vol.mute=toggle
mixer rec.mute=toggle

Well, I just make a toggeling script that also changes the LED and I disable it at startup. Well, I first needed to eable 'acpi_ibm' in 'rc.conf' to access the LED. Then I can still change them only as a superuser. I tried to go past this via UID bits (refer to chmod(1) for more info), But to no success. I ended up doing the same thing as with 'poweroff'.

# toggle-mute-vol.sh

#! /bin/sh

mixer vol.mute=toggle
sudo vol-led.sh "$(mixer vol.mute | grep -o "[a-z]*$")"


# vol-led.sh

#! /bin/sh

if [ "$1" == "on" ]; then
   sysctl dev.acpi_ibm.0.mute=1
else
   sysctl dev.acpi_ibm.0.mute=0
fi


# .xinitrx

sudo vol-led.sh off

Keyboard backlight

There is actually no way of controlling this from the terminal, but it turns out that 'Fn+Space' cycles through backlight levels on thinkpads, so no problem there.

Sure, it is all a bit hacky, but I believe if you install some DE like KDE, it would all work out of the box. Any hey, It isn't really my system, unless its all held together by a bunch of hacks.

Some more differences

Also I don't know where to put this, but part of the bootloader is written in FORTH!

Conclusion

so this is where I'm now. I still have to port some of my projects, more on that in their respective b-logs.

I will document my further progress in further posts. I think it might be a good way to learn things.