OpenBSD on the Thinkpad X220
Recently I’ve installed OpenBSD on my laptop. I was curious about what the world of *BSD had to offer and I was planning on wiping the drive anyway. Here are some of my thoughts and tips.
Enabling the middle mouse button
Immediately after installing dwm I noticed that the middle mouse button was not working. The solution is adding these three lines into your .xinitrc. Your device might be named differently, so make sure with xinput -list.
xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation" 1 xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Button" 2 xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Axes" 6 7 4 5
While on Linux I had always disabled the touch pad with xinput too, I could not figure it out on OpenBSD (the track point is much more comfortable to use). So what I did was disable it in the BIOS, which is a perfectly fine solution too.
Configuring ‘doas’
OpenBSD uses doas instead of sudo. You must configure it before using it, at /etc/doas.conf. Here’s what I use to allow my user to run commands as root:
permit persist keepenv nuke as root
See doas.conf(5) for more information.
doas is very configurable. For example, you could allow users to only execute specific commands as another user. Before you paste this line, which you obviously got from a total stranger from the internet, into your file, at least skim the man page. Documentation can’t hurt!
Using ports
A lot of software is not available on OpenBSD. That’s why we have “ports”. These are a collection, commonly referred to as the ports tree, of Makefiles that do everything from fetching the source code and dependencies to compiling and testing it.
The official FAQ which is located at https://www.openbsd.org/faq/ports/ports.html shows you how to use this system pretty well. But I had two problems.
- Depending on what mirror you have selected pkg_add may not find the portslist package. Try a different mirror, the official openbsd.org ones work.
- If you use the default /etc/mk.conf you’ll soon find complaints about /usr/obj/ports not being on a wxallowed filesystem. This is due to a recent security update. Change the working object directory to point to /usr/local which is mounted on a wxallowed filesystem by default:
WRKOBJDIR=/usr/local/obj/ports
Mounting a USB drive
Due to OpenBSD’s disk notation being different than Linux, you might be a tad confused. Here are the steps.
- You might notice that fdisk -l does not work. Use dmesg or use sysctl hw.disknames to find the device name. Use disklabel sdX to make sure it’s the correct one.
- Using disklabel sdX you can list all the partitions on the drive. The output will look something like this:
# size offset fstype [fsize bsize cpg]
c: 7835648 0 unused
i: 7833600 2048 ext2fs</pre>
BSD uses different disklabels. Therefore to mount the i partition, do mount /dev/sd2i DIR