FreeBSD on a ThinkPad

My laptop was at the end of its life. 3 years old only, but the keyboard was used by the cat to sleep, the FreeBSD support was not really good and I wasn’t very kind with it.

So I decided to change. After asking the Facebook FreeBSD User Group I decided to buy a Lenovo X280 with a 500GB SSD, 16GB of memory and an Intel Corei7 8th generation, 4.00Ghz.

The package

The computer is very well packed, with no fioriture like Apple did. Standard EU power Supply with USB-c connector. Nothing more, no CD/DVD. The computer is delivered with Windows 10.

Very good point, there is a hard webcam cache (a small slider, to cover the lens).

Windows 10 Backup

With the previous machine, I learned that we should always copy of the original OS. It’s the only way to make the firmware update for example.

Microsof provide a tool, on his website in order to make a rescue usb key. In fact, It’s only an ISO image of Windows to put on the USB volume.

Be sure to boot with this support before break everything.

UEFI update whitout Windows

It seems possible to update the UEFI by downloading a bootable ISO image, here.

I did not try by fear to lose everything. If you decide to do it, make backups.

Downloading FreeBSD 12.0-RELEASE

In order to download the right image please visit the official FreeBSD website. I used to do this download on my old laptop (wich was already on FreeBSD) to use tools that I really know to make a bootable USB key.

The main command to copy an image to another support is dd(1):

# dd if=/path/to/image.img of=/path/to/support

Unfortunately, dd(1) does not provide any feedback. It’s frustrating and you can ask yourself if the process is not broken. The command pv(1) can help us.

  I was using dd for a long time. The new version has now a status=progress parameter.

# pv -tepb FreeBSD-12.0-RELEASE-amd64-memstick.img | dd of=/dev/da0 1% [= ]

Configure UEFI/BIOS on ThinkPad

The FreeBSD-12.0-RELEASE usbstick and the OS itself could boot on UEFI. Be sure that the boot sequence is [UEFI first then BIOS]

Once you did it, boot on the USB key and start the installation. Pick the options you want/need. I choose to install a encrypted ZFS. A passphrase will be asked during the installation process and asked every time the system boot.

The installation process is pretty fast.

You will ask to choose a root password. The install process will also ask for creating another user in order to NOT work as root.

  I choosed the same uid/gid as my user on GNU/linux at work in order to exchange files with no owner difficulties.

Remember to invite your user in the wheel group.

Once the installation finished, it’s time to reboot and remove the USB key.

Well it’s booting, and after

Log in and you’ll notice that we don’t have a lot of things that works, especially no WiFi.

The WiFi connection

We need to find which hardware is on the computer in order to find the right driver to load in the kernel.

# pciconf -lvc
iwm0@pci0:59:0:0:   class=0x028000 card=0x00108086 chip=0x24fd8086 rev=0x78 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Wireless 8265 / 8275'
    class      = network

Here is the answer, it’s an intel wireless 8265/8275 wireless card. The first third letter give us the driver to use, iwm.

The /boot/loader.conf file

In this file we will put a lot of information about the boot sequence and the driver to load in the kernel.


The /etc/rc.conf file

In this file, we describe which services to start automatically at boot.

Here we’re gonna make an alias for the driver put in /boot/loader.conf file. We also define the option for the WiFi device had to use in order to work. Therefore we say it to find it’s IP Address using DHCP:

ifconfig_wlan0="WPA SYNCDHCP powersave"

The DHCP request in background allow to not slow down the other boot processes if there is no responding DHCP server. It’s the same for SYNCDHCP. The option WPA is used to prepare the encrypted connection with the WPA protocol. We will use another file to describe the connection itself.

The /etc/wpa_supplicant file

In this file we will have the informations for all the known WiFi connections. At home, at work, in the train, at the hotel, etc. Starting with the nearest network.

Each network block is a different network.



When the daemon wpa_supplicant starts, it’s gonna scan the Wi-Fi networks around you and look if one is already known. If it is the case, the connection will be esthablished automatically.

A small test

It’s time to test your configuration by relaunching all the necessary parts. In fact, restarting the network itself will launch wpa_supplicant to and the request for an IP address to a DHCP should work if you have a fonctional server.

# service netif restart

The ifconfig command give us information about our connections:

# ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether a1:b2:c3:d4:e5:f6
    hwaddr a1:b2:c3:d4:e5:f6
    inet netmask 0xffffff00 broadcast
    media: IEEE 802.11 Wireless Ethernet DS/2Mbps mode 11g
    status: associated
    ssid Home-Sweet-Home channel 11 (2462 MHz 11g) bssid aa:bb:cc:dd:ee:ff
    regdomain FCC country US authmode WPA2/802.11i privacy ON
    deftxkey UNDEF AES-CCM 2:128-bit powersavemode CAM powersavesleep 100
    txpower 30 bmiss 10 scanvalid 60 protmode CTS wme roaming MANUAL
    groups: wlan

It looks like a WiFi connection is established.

System update

Once network is working, you have to update default installed software.

bootstrap of the Package Manager System

It’s mantadory for the package manager (pkg(7)) to know which packages are available in binary format, if this is the way you want to install softwares.2

# sudo pkg

Update of the already installed packages

The update use the same pkg(7) command:

# sudo pkg upgrade

The bluetooth

Despite all my efforts and searches, I cannot find a way to make it working. This is a security hole fixed!

The graphic card

Nowadays it’s really difficult to not use a graphical interface (even though this blog is written with vim(1) and I use mutt(1) to manage my emails.

In fact, the graphic card installation with Xorg works almost by itself. I chose the mate (ex gnome2) desktop environment.

# sudo pkg install mate-common

Xorg configuration

This is the most complicated part of the installation. During a long time I used the vesa(4x) driver. This driver is very slow and does not allow the computer to be used at is full potential. Fortunately there is another driver, i915kms. You just have to load it at the machine boot. This is done by inserting a new line in /etc/rc.conf:


In the /usr/local/etc/X11/xorg.conf.d we have to add a configuration file for the driver,

Section "Device"
        Option          "AccelMethod"
        Option          "TripleBuffer"
        Option          "HotPlus"
        Option          "TearFree"
        Identifier      "Card0"
        Driver          "intel"
        BusID           "PCI:0:2:0"

The file will be used at the next reboot or, if you already loaded the i915kms3 driver, the next time you restart the graphical interface4

bash login

Mate doesn’t provide any graphical login interface. The only working software is an abandonned software named SLiM. Fortunately it is still in the *BSD ports. We just have to install it:

# pkg install slim-freebsd-themes slim-themes

We install themes at the same time.

The configuration file is /usr/local/etc/slim.conf. The only modification we have to do is the theme choice. The themes are in /usr/local/share/slim/themes. Almost every one of them provide a preview image letting you choose the one your prefer5.

You also need to ask the system to launch the slim daemon during the boot. You can do it by adding the line slim_enabled="YES" in the /etc/rc.conf file or by using the command sysrc(8).

# sysrc slim_enabled="YES"

  There are other display managers like gdm, xdm, sddm. I let you discover them.

The TouchPad

In fact, the Touchpad work out of the box. But it’s very strange to not have a control panel for it. In order to have an optimal configuration we will change some kernel parameters and values in Xorg configuration.

Load the driver into the kernel

Add this line into your /boot/loader.conf file:


Xorg additionnal configuration

For this configuration we are going to copy the defaults provided file /usr/local/share/X11/xorg.conf.d/70-synaptics.conf in the /usr/local/etc/X11/xorg.conf.d/ folder:

# sudo cp /usr/local/share/X11/xorg,d/70-synaptics.conf /usr/local/etc/X11/xorg.conf.d/.

Then modify it for our use:

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"

Section "InputClass"
        Identifier "touchpad ignore duplicates"
        MatchIsTouchpad "on"
        MatchOS "Linux"
        MatchDevicePath "/dev/input/mouse*"
        Option "Ignore" "on"

Section "InputClass"
        Identifier "enable synaptics SHMConfig"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "SHMConfig" "true"

Section "InputDevice"
        Identifier "Mouse0"
        Driver "mouse"
        Option "Protocol" "auto"
        Option "Device" "/dev/sysmouse"
        Option "ZAxisMapping" "4 5 6 7"

  ZAxisMapping 4 5 6 7 are the mouse bouton and vertically scrolls

  In order to have the ¨Natural Scrolling¨, you can add another fonfiguration file called /usr/local/etc/X11/xorg.conf.d/20-natural-scrolling.conf:

Section "InputClass"
        Identifier "Natural Scrolling"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Option "VertScrollDelta" "-1"
        Option "HorizScrollDelta" "-1"
        Option "DialDelta" "-1"

The “specials” keys

On my X280 keyboard there are special keys to manage sound (increase/decrease/muted) and the screen brightness. Those functions work the shortcut Fn+F(muted), Fn+F2 (decrease), Fn+F3 (increase), Fn+F5/Fn+F6 (brightness).

In the graphical interface

Unfortunately those shorcuts does not work out of the box. We need to add the port graphics/intel_backlight and test it with a very simple command:

# sudo pkg install intel_backlight
# intel_backlight decr 15

The bightness of your screen decrease by 15%. Use the last command several times to see if it really changes. To increase brightness just replace decr by incr.

If it works, you just have to configure those shortcuts in the graphical interface.

In the same time configure the sound keys.6


You can, in the UEFI/BIOS switch Function keys to get utility shortcuts without Fn key rather than F-X keys. It could be interesting.

Suspend and resume

Ww use laptop because it’s so easy to close it, move, re-open it and continue the job whitout rebootin the machine. This feature is call “Suspend and Resume” and di not worl well on my installation before I found the Gawens' blog who explain very clearly how-to configure this feature.

I will not repoduice the blog post here, it will be useless.

Access to Audio CD

We need to make change in /etc/devfs.conf file:

link    cd0     cdrom
link    cd0     dvd

perm    cd0     0666
perm    xpt0    0666
perm    pass0   0666

Then restart devfs:

# service devfs restart

To conclude

FreeBSD on a Thinkpad X280, it works, Just three little things annoys me:

  • I don’t find a way to automatically disable the touchpad when I use the keyboard. Therefore the cursor sometimes goes away to another line;
  • the Bluetooth does not work.

Update on november 9th 2019

I made the kernel update to 12.1-RELEASE and it don’t work as expected.

The i915kms.ko module

At loading this module, the machine reboot without any message. This not what I want.

After exposing my trouble to the freebsd-hardware mailing list, it appears that is a known bug, with a workaround. You just have to recompile the module from the sources. Here is how-to do that:

First you need to choose 2 - Single User in the boot menu, to avoid the loading of the superior elements of the system.

One you gave the root password and choose the shell you want to use (just hit the return key for this question), you wil have a minimalist prompt #.

We are going to mount the filesystem in read/write mode (it’s read only by default) and mount the ZFS datasets:

# mount -u /
# zfs mount -a

Then we’re going to edit the /etc/rc.conf file and comment the line # kld_list="/boot/modules/i915kms.ko"

By using the exit command, the boot sequence will continue.

Once again we have to login as root et it’s time to recompile the kernel module.

# cd /usr/ports/graphics/drm-fbsd12.0-kmod
# make install clean

A lot of incomprensive lines will be displayed. To care about them.

Once you have the prompt again (#), edit the /etc/rc.conf file again and uncomment the line kld_list="/boot/modules/i915kms.ko".

Reboot and see the smile on your face, you have the graphical interface.

This installation is mine and is ok for me. I am not an expert and some may have other methods, other tricks.

External Link

Maybe it’s a good idea to download and keep on backup this document:

  1. Don’t be silly the informations are not real and are not about a network I know. ↩︎

  2. this what I will use in this post ↩︎

  3. with the command # sudo kldload i915kms ↩︎

  4. with the shortcut CTRL+ALT+Effacement ↩︎

  5. I thin your do it with your wonderfull pictures ↩︎

  6. Thanks to my friend Bertrand who guide me inm this configuration, and to Porkepix for he’s reread, suggestions and fix. ↩︎

powered by FreeBSD