2021-03-23

Review: OpenBSD 6.8 on 8th Gen Lenovo ThinkPad X1 Carbon 13.3"

10 days ago, I bought this X1 Carbon. I immediately installed OpenBSD on it. It took me a few days to settle in and make myself at home, but here are my impressions.

This was the smoothest experience I've had getting OpenBSD set up the way I like it. The Toshiba NB305 in 2011 was a close second, but the Acer I used between these two laptops required a lot more tweaking of both hardware and kernel to get it to feel like home.

The bad news

Let's start with what doesn't work flawlessly on the ThinkPad under OpenBSD-STABLE (6.8 with all patches to date applied), roughly in the order I noticed them. At the moment, the issues with the TrackPad and browser webcam are the only outstanding annoyances. Everything else was easily addressed with basic configuration adjustments.

The resolution is just too high. 

First world problems. While I admire cramming a full-blown 4K UHD into this diminutive portable workstation, at 3840x2160 on a 13-inch-class display, everything was too small to read. Windows and MacOS both handle the ever-growing number of pixels on a display by having a "scale" item in the display properties. While display managers designed for BSD and Linux, such as XFCE or GNOME, do have the ability to scale items, these scale settings don't work globally across all applications in a predictable way.

The high-DPI display was most problematic during installation, wherein the kernel modesetting used the native screen resolution for the text-mode installer, with each line of text being barely a millimeter tall. I literally wore a headset magnifier to install OpenBSD on this thing. After install, the console was a reasonable size. I don't know why the installer used such a high resolution, but suppose it could be related to firmware for the on-board graphics adapter that's not present in the install media but is present after a full install and fw_update.

Upon logging in to X and opening a terminal window, I had to bump up the font size just to see what's going on. I opted to just decrease the resolution of my display to solve this problem. Using xrandr to experiment with different 16x9 resolutions, I settled on 2048x1152, though plain old 1080p is also quite pleasant. I added this lovely gem to my .xinitrc file before calling the desktop environment:

xrandr --output eDP-1 --mode 2048x1152


The touchpad occasionally goes non-responsive. 

I think this may be hardware-level wrist-detection stuff at work, but backing completely off the computer and trying to use the touchpad doesn't fix it. I often have to use two or three fingers at a time and repeatedly tap the touchpad to get it to come back. Thinking about it now, I should probably see if it works after I just leave it alone for a few seconds. In the meantime, I disabled the trackpad in the BIOS and I'm trying my very best to embrace the TrackPoint "Eraser Head" pointer. If you know what's going on with the touchpad, let me know.

 

The TrackPoint doesn't scroll by default under X.

On Windows, you can scroll by holding the center TrackPoint button while moving the TrackPoint head. This didn't work by default -- center button is "paste" by default under X. I was able to make some more additions to the beginning of my .xinitrc file to get it right, where clicking the center button pastes the clipboard contents, and holding it allows you to scroll with the TrackPoint:

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

 

Audio quality with the default settings

The audio sounded a little tinny and not all that loud when I first played audio over them. Part of the backstory of my admiration of the ThinkPad X1 line is that I pay attention to OpenBSD developers and what they say about hardware. ThinkPads get a lot of praise from the developers I follow, and in one of jcs@'s recent-ish blog posts about the previous generation of X1 Carbon, there was some concern about the audio output. I noticed that while sound was coming out of the "bass" speakers on the bottom of the wrist rest and the "treble" speakers on top near the screen hinges, the tone of the sound coming out of all of the speakers seemed amiss -- and muting the small speakers made it sound better. It turned out to be the same problem as jcs@ noted on the 7th gen X1 Carbon, and adding this line to /etc/mixerctl.conf fixed it, while providing crystal-clear sound through all 4 speakers:

outputs.spkr2_source=dac-0:1

When this laptop's audio is firing on all cylinders, it sounds positively amazing given its size. I've had big old chunky gaming laptops with big old woofers inside them that didn't sound this good. What it has in audio quality, it lacks, just a little, in maximum volume, but it's more than loud enough to fill my workspace with sound, whether I'm in the back of my camper-van or hacking away in my home office.


Webcam support in the browser

YouTube, Discord and some other sites will TRY to use the webcam and microphone - and take note of the kern.audio.record (and upcoming kern.video.record) sysctl options. On Discord's web app, I briefly see my webcam video as the webcam activity LED illuminates, then the LED turns off and Discord returns an error. On YouTube, I never see my own video, but the webcam activity LED blinks briefly. Video capture tools such as ffmpeg and vlc work quite well with the webcam. Given that, I believe there's probably a simple fix to make it work flawlessly, I just haven't found it yet. I'm looking forward to a time, hopefully soon, when I can use an official package or port of OBS Studio, maybe even with working virtual camera support.

 

The fingerprint reader isn't supported

jcs@ also noted the same of the 7th generation X1 as of 2019. It doesn't bother me in the least. Maybe it'd be neat to log in to OpenBSD with a fingerprint, but I've been using OpenBSD for 21 years without it, so I don't miss the functionality and it's only barely worth mentioning.  


No Bluetooth

Bluetooth has been unsupported by OpenBSD for many years. I don't miss it, but if you decide to try OpenBSD, you might notice that there is no Bluetooth stack.

The good news

What works? Basically everything else. 

  • The function keys for volume, mute, brightness, and keyboard backlight worked without any hassle
  • The built-in ethernet port (which requires a dongle to use) has full support in the kernel via em(4) without requiring a firmware blob.
  • After loading firmware, the on-board Intel WiFi6 adapter is fast and functional via iwx(4). 
  • Sleep/suspend/wake works well via zzz(1) or simply closing the laptop lid. Similarly, using sysctl to disable sleep when the laptop is closed works and it will stay running while closed.
  • WebGL applications, such as some of my favorite online games, work fine now. About a year ago, none of them worked. It could just be that my old laptop didn't have enough resources for these web applications.
  •  YouTube, Social media applications, Google Drive, etc... all good.
  • Even the USB microscope that I use for small electronics work and examining small mechanical parts such as those found in locks and analog watches works great with VLC once I'd created /dev/video2 and set up device permissions.

Battery life seems good. I have been using this laptop for about 3 and a half hours before and during the writing of this review, with moderate screen brightness, several "hungry" tabs open in Firefox and with pianobar (a CLI Pandora client) blasting my "Orbital" inspired playlist. I have two OpenBSD virtual machines running in vmm, though I'm not currently doing anything intense with them. I've been on battery the whole time and I've got 43% battery remaining, with an estimated run time of about 2.5 hours remaining. I can deal with 6 hours of untethered run-time under my usual working conditions.

The system temperature has hovered in the 40-60*C range most of the time, though it got a little warmer when certain browser tasks get rolling. The cooling fan has remained off almost the entire time, but when it's running, it's still very quiet.

I was a little worried that I'd have a "never meet your heroes" moment when I bought this laptop, and that it might not live up to the expectations that I had. So far, it's everything I need and then some.

2021-03-17

Multi-booting OpenBSD and Windows 10 on modern hardware with rEFInd

I recently purchased a 13.3" 8th Gen Lenovo ThinkPad X1 Carbon. Frankly, the X1 series has been my dream machine for years. I like small laptops, and this one is light, powerful and is similar to what's used by many of the OpenBSD core developers, so I knew it would probably be well-supported. My previous laptop -- the Acer I upgraded to an i5 for VMM years ago -- was set up for dual-boot, but somewhere along the way, the Windows boot manager stopped booting OpenBSD so I'd been using a modified OpenBSD install image on an SD card to load the OpenBSD kernel from the internal SSD, I set the BIOS to prioritize the SD card for booting, and I just remove the SD Card from my Acer if I need to boot Windows. That laptop is growing long in the tooth, but it's served me well for the past 5 years.

I decided to try properly dual-booting Windows and OpenBSD again with my new ThinkPad. And that's where things got ugly.

The steps to get Windows and OpenBSD working together, as outlined in the OpenBSD Multibooting FAQ seem to not work at all on recent Windows 10 versions, and especially on modern PCs with EFI and GPT disks. I tried several times without any luck, and I also rendered my system unbootable a number of times in my quest. Fortunately, I had made recovery media so I could blow away my X1 Carbon to factory defaults when things went sideways. That's a 45 minute process each time.

Start with a Windows install, and have good backups, including, if possible, external recovery media from the manufacturer. Several times, the drive partition table was so screwed up that the recovery partition was missing as well, leaving me with the recovery USB stick as my only way forward.

Create a Live USB of GParted.

On another USB stick, write the contents of the OpenBSD installXX.img. This link references install68.img from OpenBSD 6.8, which may be out of date or a broken link when you read this.

Boot into the gparted live distro. On modern EFI/UEF systems, you will probably need to adjust secure boot and/or legacy boot options in your system's BIOS to continue.

Shrink the main Windows partition by some amount to make room for OpenBSD. I gave myself 120GB. That's how much room I have dedicated to OpenBSD on my Acer, and it seems to be a good size. I also usually create another FAT32 or Exfat partition that I can store files on to be accessed from both OpenBSD and Windows, but that's beyond the scope of this write-up.

Create a new partition for OpenBSD in the empty space. GParted doesn't know about OpenBSD partition types, so you'll have to then close GParted and launch a terminal window from the live environment. You'll have to launch gdisk via sudo and address your drive's device. For example:

sudo gdisk /dev/nvme0n1

Use the "p" option to print a list of partition entries. Find the one you created and use the "t" option to change the partition type to "A600" which is what OpenBSD expects to use for its disklabel entries. "w" will write the GPT and exit. You may also want to use the "b" option before you exit to make a backup of your partition tables just in case you mess something up. You'll have to store it to a USB drive, but you can probably store it on the same USB stick you booted GParted from.

At this point, I decided to reboot and make sure Windows still works. Thankfully, it did. Reboot into the OpenBSD installer using the USB stick you created. I won't walk through the whole installer process, but pay very close attention to the disk partitioning options. When prompted for the disks to install OpenBSD to, you should see an "OpenBSD Area" option and that should be the default disk partition to install to. If that option doesn't exist and you choose "gpt" or "whole disk" you will destroy the GPT record on your drive. Your system will not boot. You can probably use gdisk and your backup of the GPT to recover the partition table, or you may have to reinstall Windows and start all over again, and that isn't fun. Trust me. I've done that four times this week. Don't let the system do an auto-layout. Choose "custom." Unless you know what you're doing, just make one big disklabel partition for OpenBSD's root drive.

Once OpenBSD is installed, exit to the shell. You will need to copy the EFI boot executable to some other media so you can access it from Windows. I inserted a USB stick that was formatted for FAT32. It showed up as sd1 and the first non-BSD partition typically shows up as "i"

mkdir /usb
mount /dev/sd1i /usb
cp /mnt/usr/mdec/BOOTX64.EFI /usb/bootx64_openbsd.efi
umount /usb

Go ahead and reboot. It should boot into Windows. Fingers crossed!

Now, go download rEFInd and unzip the archive. I followed the Windows manual install instructions to get rEFInd working. I rebooted again, simply because I'd become so accustomed to bricking my shiny new laptop. To my surprise, rEFInd presented me with a boot menu. Windows showed up, and an additional menu item called "Fallback boot" also appeared. This menu option booted me into OpenBSD. That could be pretty much the end of it, but I wanted an actual OpenBSD menu option.

To accomplish this, I borrowed some mojo from this somewhat dated blog entry on FunctionallyParanoid

You have to access the EFI system partition from a privileged command shell (hearkening back to the instructions to manually install rEFInd from Windows), so I copied the refind.conf file off to my Documents folder, edited it with notepad, then saved it and copied it back over to the EFI system partition.
I added this clause near the end of the refind.conf file:

menuentry “OpenBSD”
{
icon \EFI\refind\icons\os_openbsd.png
loader \EFI\boot\bootx64_openbsd.efi
}

Make sure to download the OpenBSD icon and place it in the \EFI\refind\icons folder, too. Once I did that and rebooted, rEFInd still had the "fallback" menu item, but OpenBSD showed up with its own logo alongside the Windows logo. Both operating systems boot, and my mission was finally accomplished.