Install FreeBSD 13.3 on Thinkpad x250
01.06.2024 - [mss]_Cyclist - ~5 Minutes
Installation of FreeBSD with Wayland on Thinkpad x250
When my SSD died in my Thinkpad x250 it was time to replace it. All backups in place. Should be no problem. Wrong. Installation with ZFS on root went without problems. These came when I wanted to get i3 on xorg running. All drivers installed as documented in the handbook Yes, I wanted i3, but ended up with sway.
Step 1: Installation on ZFS
This step is straight forward. I do not think it is necessary to go into much details here. Just follow the installation instructions.
- Download FreeBSD 13.3 (I just did not want to upgrade to 14.0 right now).
- I went with the memstick because I did not have wired network. So I needed all components to be available offline.
- Follow the instructions of the installer.
- Upgrade FreeBSD
root@freebsd:~ # freebsd-update fetch install
....
root@freebsd:~ # reboot
Step 2: Wireless network
First identify the network cards:
root@freebsd:~ # pciconf -lv | grep -A1 -B3 network
em0@pci0:0:25:0: class=0x020000 rev=0x03 hdr=0x00 vendor=0x8086 device=0x15a2 subvendor=0x17aa subdevice=0x2226
vendor = 'Intel Corporation'
device = 'Ethernet Connection (3) I218-LM'
class = network
subclass = ethernet
--
iwm0@pci0:3:0:0: class=0x028000 rev=0x59 hdr=0x00 vendor=0x8086 device=0x095a subvendor=0x8086 subdevice=0x5010
vendor = 'Intel Corporation'
device = 'Wireless 7265'
class = network
The wireless card is iwm0.
So let’s configure this:
root@freebsd:~ # ifconfig wlan0 create wlandev iwm0
root@freebsd:~ # sysrc wlans_iwm0="wlan0"
root@freebsd:~ # sysrc ifconfig_wlan0="WPA SYNCDHCP"
Add your wireless credentials.
Edit /etc/wpa_supplicant.conf
network={
ssid="FreeBSD"
psk="PresharedKey"
}
In order to get it working
root@freebsd:~ # service netif restart
Step 3: Getting ports tree
We will use git to get the ports. First install git
root@freebsd:~ # pkg install git
Then clone the ports tree
root@freebsd:~ # git clone https://git.FreeBSD.org/ports.git /usr/ports
This will take a while to complete.
Step 4: Install video card drivers
First identify your graphic card
root@freebsd:~ # pciconf -lv|grep -B4 VGA
vgapci0@pci0:0:2:0: class=0x030000 rev=0x09 hdr=0x00 vendor=0x8086 device=0x1616 subvendor=0x17aa subdevice=0x2226
vendor = 'Intel Corporation'
device = 'HD Graphics 5500'
class = display
subclass = VGA
So we need to install the Intel HD Graphics 5500 driver. Install
root@freebsd:~ # cd /usr/ports/graphics/drm-kmod
root@freebsd:~ # make install
root@freebsd:~ # sysrc kld_list+=i915kms
Now it is time to reboot and check if the driver is loaded.
Step 5: Install xorg
Install xorg and add your non-root user to the video group
root@freebsd:~ # pkg install xorg xinit
root@freebsd:~ # pw groupmod -m video mss-cyclist
Step 6: Install i3
Installation of i3 is simple.
root@freebsd:~ # pkg install i3 i3lock-color i3status
Create a ~/.xinitrc
in your home directory
exec i3
Step 7: Try to start i3
This should not be too hard, should it? Until now everything went smooth. And now Murphy’s law kicks in trying to start xorg.
mss-cyclist@freebsd:~ % startx
Murphy around the corner
And now? A black screen shows up. A blank cursor in the uppper left corner. The fan of my Thinkpad goes wild. Nothing happens. The laptop is completely frozen. No luck in trying to kill xorg. No reaction to the keyboard. Only way to get around is to power it off the hard way.
I tried this several times without any success.
What is wrong?
Could be my trusted x250 died on me? Are these the wrong drivers? Nothing I tried seems to be working. Several hard resets further without any luck. Everything is working as expected - except xorg.
Ubuntu live cd
Just to make sure my Thinkpad is ok I downloaded Ubuntu and tried to start it as a live image. If Ubuntu will not run, then FreeBSD will certainly not run. To my relief Ubuntu started without any problems. Shortly after I was rewarded with a GUI. Some tests. Nothing wrong with my hardware.
GhostBSD
So when Linux is capable of running on my laptop, how can I get my beloved FreeBSD to get running? Next idea is to try a FreeBSD live cd. So I downloaded GhostBSD and run the live image. To my relief GhostBSD showed me the Mate desktop. So apparantly FreeBSD is capable to run on my x250 with GUI!
Back to the installation
Some fiddling around did not give any results. Screen still frozen, no way to start xorg. Several hard resets more leave me with the bitter thought to abandon FreeBSD (not really an option) or to buy a newer Thinkpad. Not the best prospects ahead.
Step 8: Wayland to the rescue
So there was still one option left which I did not consider. Give Wayland a try.
Installation of Wayland
root@freebsd:~ # pkg install wayland seatd
root@freebsd:~ # sysrc seatd_enable="YES"
root@freebsd:~ # service seatd start
The wayland compositor needs a runtime directory
root@freebsd:~ # mkdir -p /var/run/user
root@freebsd:~ # chown root:video /var/run/user
The runtime directory needs to be known in the XDG_RUNTIME_DIR
environment variable.
We will persist this later.
mss-cyclist@freebsd:~ % export XDG_RUNTIME_DIR=/var/run/user/`id -u`
Installation of Sway
Luckily Wayland has Sway as a drop-in replacement for i3. So it should be familiar to use.
# pkg install sway swayidle swaylock-effects alacritty dmenu-wayland dmenu alacritty
mss-cyclist@freebsd:~ % mkdir ~/.config/sway
mss-cyclist@freebsd:~ % cp /usr/local/etc/sway/config ~/.config/sway
Following the FreeBSD handbook there are some important changes to be made ~/.config/sway/config
...
input * xkb_rules evdev
set $term alacritty
...
Step 9: Starting Sway
Now let’s try if this works:
mss-cyclist@freebsd:~ % sway
And to my surprise: sway is working. I am greeted with the sway GUI. Lucky me: I do not need to ban neither FreeBSD nor my x250.
Step 10: Persist XDG_RUNTIME_DIR
Last but not least: let’s not to forget to persist XDG_RUNTIME_DIR
.
Edit ~/.cshrc
and add
setenv XDG_RUNTIME_DIR=/var/run/user/`id -u`