11.08.2020 08:31
17.07.2016 10:57

Playing with FreeBSD

Linux world is taking a direction that is getting somewhat away from my aim. It is getting too complicated and with every wall (=problem that I am not able to find explanation) I hit I am thinking of what am I going to use next. You know - here is a lowlevel, every level of complexity above it is prone to errors. This is my diary of trying the FreeBSD from POV of long time Linux admin. I do not expect everything to be perfect, but I'd like to document the good, the bad and the ugly. I have a number of desktops and even higher number of servers on Linux, this is not that I am going to switch all that now. But I want to see if there is a way to use BSD.

Installation

Downloaded the memstick image of 10.3 from freebsd.org.

Text based install without any fancy partitionshit, just the number of file systems is a bit limited compared to Linux.

ATM UFS and ZFS for default installs.

Bit concerned about NTFS and Linux Ext support I'll definitely need. The NTFS seems to be supported by fuse ntfs-ng, doc declares support for ext2 and ext3 (without journal), ext4 is read only. To test the FreeBSD first you may try:

qemu-system-x86_64 -localtime -net user -net nic -m 512 -hda FreeBSD-10.3-RELEASE-amd64-memstick.img -hdb hda.qcow2

BSD install side by side with other OS is bit troublesome as native BSD is using disklabel instead MBR, installing with other OS is then possible only when you have at least one free primary partition record.

I freed one primary record, then installation was fluent - mostly just pressing the Enter. In Linux grub2 I hand added the entry

menuentry "FreeBSD" {
        set root=(hd0,4)
        chainloader +1
}

First boot

first problem met - as installation was done at secondary disk, the boot can not find the root file system. Kernel drops me into "mount root file system" shell that is able to list all partitions and you simply type

ufs:/dev/ada0p2

and system mounts the root and boots. If you miss, it just returns with message the root was not there.

What the heck, no kernel panic - can not mount root and repeated attemtps to boot thru grub to find out what the root partition is, no kernel parameter writeup root=. No cryptic UUIDs, LVMs or other bloated path names... - are you able to remember the UUID of your root partition?

After boot I just edited the /etc/fstab, changed ada1 to ada0 and reboot. It works! Magic, no dracut initramfs regeneration needed? Well this used to work same way on Linux... used to.

Setup

I never understood precisely the system of ports in BSD. Now it is pretty straight forward - there are ports, these are package definitions to build the package from source by yourself (similar what Gentoo or GuixSD does). The ports tree is installed by default on FreeBSD in /usr/ports.

There are also prebuild packages too - the "pkg" utility is used to install them. At first attempt to use the pkg I got the the notice there is no pkg tool if I want to install it - simple "y"es fixes this.

pkg info

lists packages installed from pkg

Installing bash

pkg install bash

and add a recommanded line to /etc/fstab for bash. Switching the shell to bash for the user is thru vipw, it is not enought to edit /etc/passwd - acctually the correct why is to use chsh.

pkg install mc

mc can not be started as user with default sh shell "mc unimplemented subshell type 1" - bash is ok.

I also enabled moused for console mouse driver - the graphical "arrow" looks weired in text mode thou, same applies to console fonts. I also found a very weired sideeffect - when moused is enabled and firefox is started in Xorg then mouse wheel scroll back is going back in the history - the mouse scroll is interpreted as kind of incorrect button press. Found something in this Virtualbox ticket - disabling the moused and start Xorg fixes this.

pkg install xorg icewm; echo "exec icewm-session" > ~/.xinitrc; startx

Xorg is running at F9 console. Stoping Xorg or attempt to switch back to text console results in a blank screen on my HW. It is not possible to get back to text console after Xorg is started.

No text console scroll back buffer so far.. weiredly the text consoles have TERM set to xterm. Logging with ssh to any linux then ncurses based programs show garbage... needs to set locale, I did that in ~/.login_conf

me:\
    :charset=utf-8:\
    :lang=cs_CZ.UTF-8:

OK - I changed the console type to a graphical "vt" in /boot/loader.conf

# Use new graphical console driver
kern.vty=vt

and things are much better. I'd say the console is very nice now. No issues switching to Xorg and back.

pkg install sysinfo dmidecode

to find out something about HW.

pkg install firefox

brings 542MB of packages including some icon themes, cups, colord... and the firefox needs DBus cancer when installed from this package, it won't start without it. Add dbus_enable="YES" into rc.conf, service dbus start. Youtube, sound works out of the box.

Change network device - edit /etc/rc.conf change ifconfig_name="DHCP" name

service netif restart

Virtualization - comfortable host from BSD could be made with VirtualBox - its in pkg repository.

freebsd-update fetch

upgrades the base system (see Note).

Mounting linux filesystems is only possible in ext2 mode. I rather mount ext4 read only.

kldload ext2fs; mount -o ro -t ext2fs /dev/ada0s3 /mnt/linux

Now compare this on BSD and Linux today:

mount | wc -l
       4
mount | wc -l
37

Which is Linux and which is FreeBSD?

cpufreq control for AMD - it seems the default cpu frequency control is disabled (powerd message says "powerd: no cpufreq(4) support -- aborting: No such file or directory"), need to enable it via change in /boot/device.hints and set it to

hint.acpi_throttle.0.disabled="0"

then powerd is showing cpu frequency scaling

# powerd -v
powerd: unable to determine AC line status
load   0%, current freq  848 MHz ( 4), wanted freq  821 MHz
load  25%, current freq  848 MHz ( 4), wanted freq  821 MHz
load   3%, current freq  848 MHz ( 4), wanted freq  795 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  770 MHz
load   5%, current freq  848 MHz ( 4), wanted freq  745 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  721 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  698 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  676 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  654 MHz
load   0%, current freq  848 MHz ( 4), wanted freq  633 MHz
changing clock speed from 848 MHz to 636 MHz
load   0%, current freq  636 MHz ( 5), wanted freq  613 MHz
load   4%, current freq  636 MHz ( 5), wanted freq  593 MHz
load   0%, current freq  636 MHz ( 5), wanted freq  574 MHz
load   0%, current freq  636 MHz ( 5), wanted freq  556 MHz

To read a temperatures from cpu need to load amdtemp module

kldstat #list modules
kdlload amdtemp
sysctl -a | grep cpu | grep temp

to add it permanently edit /boot/loader.conf

amdtemp_load="YES"

Even thou I was able to enable cpu throttling this AMD A8-5545M APU is still too hot in idle - arouch 60C, while Linux sits at 43C. I thought it could be due to integrated graphics, but switching to VESA driver in X had not possitive impact. So far this is annoying, as the fans are spinning loud.

Seems from ref. 4 the freq throttling is not very effective. It is much better to not use throttling and enable C2 cpu state in /etc/rc.conf:

performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"

With this temperature drops much lower - to 48C. Good, but could be better.

To enable NFS clients, set this option in each client's /etc/rc.conf:

nfs_client_enable="YES"

Then, run this command on each NFS client:

# service nfsclient start

Problem is the groups and user ID are not the same on BSD as on Linux.. well BSD now starts at UID 1000 same as Linux, but old days were different.

No special keyboard keys do work by default on BSD, probably uhidd is a solution.

For some reason the Alt+key in xterm types various UTF-8 chars. It seems the xterm needs to have set the option "Meta sends Escape" - start xterm with

-xrm "xterm*VT100.metaSendsEscape: True"

Suspend and hiberation are not succesful - acctually, both do work, but resume ends badly. acpiconf -s 3 or -s 4. Interestingly the test for S3 works, but real S3 does not.

Additional packages to install

pkg install vlc libreoffice

Notes

Interesting is how the FreeBSD threats the base system and third party software. The FreeBSD itself is the base that is maintained directly by FreeBSD project - this is not just the kernel, but also init, basic system and network utilities, the commandline interface etc. I.e. what is in /bin, /lib, /usr directly is base system, everything third-party is in /usr/local.

Documentation - this is really worth meantion that the documentation is overall GREAT. Just seldom out of date. What is fantastic is that searching the net reveals the right solution most of the time at the first hit. This is probably also due to environment stability. This is something that drives me nuts with Linux - it changes so much every few month that most of articles are outdated. Here I have to mention especially the systemd MESS. Just check my page Why I do not like systemd.

Donwside is the number of supported file systems. This is really limiting FreeBSD usage. This could also be taken as advantage as they just focus on those few that left there in FreeBSD 10 (may file system were dropped in 10).

Upgrade to FreeBSD 11.0-RELEASE

freebsd-update fetch
freebsd-update install
freebsd-update upgrade -r 11.0-RELEASE
freebsd-update install
shutdown -r now
freebsd-update install
shutdown -r now
freebsd-update install

After upgrade the xterm looked completele broken. I found it printed out a message:

Warning: locale not supported by Xlib, locale set to C

I found the solution in this bug

Upgrade to FreeBSD 12.1-RELEASE

The process of update of a base system is the same as fo 11.0, just after that I've hit and issue that pkg was not working with
ld-elf.so.1: Shared object "libssl.so.8" not found, required by "pkg"
as in the meantime I changed also the HW I had to reconfigure ethernet card in /etc/rc.conf from re0 to em0.

The normal pkg-static install -f pkg does not work either as there was and error
pkg: repository meta has wrong version 2
I had to go thru ports
portsnap fetch
portsnap extract
cd /usr/ports/pkg-mgmt/pkg
make install clean
make deinstall
make reinstall
the obviously to upgrade all packages
pkg upgrade -f

I had to switch to intel graphics
pkg install drm-kmod
then add a kld_list="/boot/modules/i915kms.ko" to /etc/rc.conf and switch /etc/X11/xorg.conf to Driver "intel".

Refs:

BSD Now
1
2
3 - bsd desktop
4 and 5 - power saving
6 - mounting linux ext4 RO with ext4fuse

Email comment