[ home ]

Running OpenBSD 6.5 (and possibly 6.6) on your laptop is really hard (not)

23rd Oct 2019: The OpenBSD devs released OpenBSD 6.6 on the 17th Oct 2019. I suspect that the instructions below will work ok on 6.6 having tried a snapshot with some success but with a few issues with the packages. Will update this page towards beginning November, after which the weaponised Comic Sans will revert to something more staid.

I have used the instructions in this page to install amd64 OpenBSD 6.5 with the xfce4 desktop, graphical login, automatic mounting of USB sticks, with a basic set of applications on a Thinkpad X220 (legacy boot) laptop with 8 Gb RAM and a 100Gb SSD. Some of the links in this page relate to OpenBSD 6.4, they will be updated soon.

Performance: On a Thinkpad X61s with 2Gb ram and a mechanical hard drive both major Web browsers (Firefox and Chromium) were core dumping fairly often on popular Web sites. We have reached the point in Late Capitalism where running a Web browser and accessing a popular news site is one of the most processor intensive things that you can do. The X220 with 8Gb and an ssd is much more responsive. Battery life on both devices is an hour or two less than with a popular Linux distribution.

Below are some links to other pages about using OpenBSD on laptops.

I suggest that you print and read this page before proceeding.

Install OpenBSD according to the instructions in FAQ

Background reading: FAQ 4: The OpenBSD installation guide.

The steps below assume that you have successfully installed the base OpenBSD system from the USB stick installer (install65.fs) or the CD-ROM image (install65.iso).

Connect to the Internet

Background reading: OpenBSD FAQ 6.2.1, 6.13.

Jack into your router with a cable and...

# dhclient em0
DHCPDISCOVER on em0 - interval 3
DHCPOFFER from (00:1b:2f:42:41:42)
DHCPACK from (00:1b:2f:42:41:42)
bound to -- renewal in 43200 seconds.

Then install any non-free firmware that your laptop might need...

# fw_update

Pull the cable out and set up a wifi connection. Most Thinkads have Intel wifi cards...

$ su -l
# ifconfig -a # shows a list of all the interfaces 
# ifconfig iwn0 up
# ifconfig iwn0 scan
# ifconfig iwn0 nwid connection_name wpakey password wpaprotos wpa1,wpa2 
# dhclient iwn0 
DHCPREQUEST on iwn0 to # lots more output

Warning: You need to use the wpaprotos option with argument wpa1 to enable connections using wpa1. The wpa1 protocol is now considered insecure.

Use a hostname.if file to automatically join wifi networks

Background Reading: FAQ 6 Configuring Your Wireless Adapter section of Wireless Networking, man hostname.if

My hostname.iwn0 file looks like this...

foo$ cat /etc/hostname.iwn0
# line below connects to my home wifi (no need for wpaprotos)
join myhomewifi wpakey wifi_password # wpaprotos keyword not supported at present
# line below connects to central reference library's open wifi
join Visitors_Library_of_Birmingham 
# line below requests IP address and DNS details

I found that OpenBSD would automatically connect to an open wifi access point without an entry in the hostname.iwn0 file. Future releases may change this behaviour.

At the time of writing, the join feature has limited parsing of lines in the hostname.iwn0 file, in particular, the wpaprotos keyword is not supported, so you can't automatically join a wpa1 network.

When populating your hostname.iwn0 file, the commands below can be used to remove existing settings, and then restart networking without rebooting the machine...

# ifconfig iwn0 down
# pkill dhclient
# sh /etc/netstart

Set up a package mirror and install a package

Background reading: OpenBSD FAQ 15.2.

The pkg_add command reads the URL of the package mirror from the /etc/installurl file which is set to the OpenBSD content distribution network by default when installing version 6.5

To install applications, you need to become root and run pkg_add.

$ su -l
foo# pkg_add nano
quirks-3.124 signed on 2019-04-15T12:10:16Z
quirks-3.124: ok
nano-4.0:libiconv-1.14p3: ok
nano-4.0:gettext- ok
nano-4.0: ok
# exit

Once the command returns, exit root and try editing a text file with nano.

Install the xfce4 desktop environment and some applications

I like the xfce desktop and the packages below will install Firefox, a pdf reader, an image organiser, a music player and an office package.

# pkg_add -v consolekit2 xfce xfce-extras evince firefox shotwell audacious audacious-plugins libreoffice

The consolekit2 package is needed to allow the user to shut down or reboot from within xfce4 without using terminal commands.

pkg_add will stop when it reaches the document reader Evince and offer you a choice of two versions of the package, each compiled with different configuratons...

# pkg_add evince
quirks-2.114 signed on 2015-08-09T15:30:39Z
Ambiguous: choose package for evince
a       0: <none>
        1: evince-3.16.1p0
        2: evince-3.16.1p0-light
Your choice: 2

Option 1 will pull in a large number of Gnome libraries. Option 2 has been provided by the packager for those of us who wish to use Evince to read pdf files with a different desktop or window manager.

Some of the more complex packages come with readme files installed to /usr/local/share/doc/pkg-readmes/. It is best to read these to complete configuration of the package.

Don't reboot yet. You need to configure the graphical login and set up some daemons. See below...

Use /etc/rc.conf.local to enable apmd and graphical log-in

Background reading: Comparison of Desktop Environments, ConsoleKit Github readme with definitions, xenodm man page and the package_readme for consolekit2 at /usr/local/share/doc/pkg-readmes/consolekit2-1.0.2p1 . Note that as of OpenBSD 6.5, you can no longer start an X session using startx as a user, you have to enable xenodm to start an X session.

As root add some lines to /etc/rc.conf.local to enable power management (apmd) so that you can use Fn-F4 to suspend your thinkpad, and to enable the graphical log-in manager xenodm. Xenodm is an OpenBSD fork of the venerable xdm.

# nano /etc/rc.conf.local
multicast_host=YES       # Some avahi shenanigans
apmd_flags="-A"          # Laptop power saving
xenodm_flags=""          # Starts xenodm graphical login
pkg_scripts="messagebus" # Enables dbus/ConsoleKit stuff

Then as user add an .xsession file with a line that will start consolekit so that you can shutdown &c from within xfce4.

$ cat .xsession
exec ck-launch-session startxfce4

From OpenBSD 6.5, you need to add your user to the operator group to be able to shutdown from within xfce4...

# usermod -G operator $USER

...where you replace $USER with the name of your user account.

Memory limits in /etc/login.conf

My Thinkpad X220 has 8Gb of RAM. Firefox (and Chromium) like lots of RAM. By default, OpenBSD enforces limits on the largest amount of RAM that a user level program can use to around 1.5Gb, and if it exceeds that limit, the OOM killer will terminate the process. Your user will be part of the staff group and you can edit /etc/login.conf to increase the default limit. Mine is set as follows...

# Staff have fewer restrictions and can login even when nologins are set.

Reboot and you'll get the xenodm login greeter. When you log in, Xfce4 will ask you to specify a layout, and then show you the desktop.

Use /etc/doas.conf to allow user mounting of an external USB stick

Background reading: OpenBSD FAQ sections 10 (doas), 14 (File Systems Intro) as well as man doas and man mount.

You must use doas and a few lines in /etc/doas.conf to allow user mounting of USB sticks. My /etc/doas.conf file looks like this...

$ cat /etc/doas.conf
# http://daemonforums.org/showthread.php?t=9774
permit nopass keith as root cmd mount
permit nopass keith as root cmd umount

Then you can mount a USB stick like this...

$ mkdir ~/usb				# make a directory to mount to
$ doas mount /dev/sd1i /home/keith/usb 	# mounts my USB on ~/usb

The mount command tells me what partitions and disks are mounted...

$ mount
/dev/sd0a on / type ffs (local)
/dev/sd0k on /home type ffs (local, nodev, nosuid)
/dev/sd0d on /tmp type ffs (local, nodev, nosuid)
/dev/sd0f on /usr type ffs (local, nodev)
/dev/sd0g on /usr/X11R6 type ffs (local, nodev)
/dev/sd0h on /usr/local type ffs (local, nodev, wxallowed)
/dev/sd0j on /usr/obj type ffs (local, nodev, nosuid)
/dev/sd0i on /usr/src type ffs (local, nodev, nosuid)
/dev/sd0e on /var type ffs (local, nodev, nosuid)
/dev/sd1i on /home/keith/usb type msdos (local, uid=1000, gid=1000)

Once mounted, you can use a graphical file manager like Thunar to copy and paste files to and from your storage stick. You can't unmount the USB stick from Thunar, remember to use the umount /dev/sd1i command before removing the USB stick...

doas umount /dev/sd1i 			# un-mounts the drive

Use xfce4-mount-plugin and an /etc/fstab entry to allow graphical mount/unmount of a USB thumb drive

Background reading: xfce4-mount-plugin page on the Xfce Web site.

A note on how disks get numbered: There are two possibilities for a simple installation on a laptop with a single main hard drive...

The rest of this section assumes that you have an OpenBSD install on sd0. Just increase the drive numbers by 1 for an installation using whole drive encryption.

The xfce4-mount package is installed as part of the xfce4 package set. Add an icon for the plugin to the XFCE4 panel by right-clicking on the panel and selecting Panel | Add New Items and searching for 'mount'.

By default, xfce4-mount-plugin lists all the devices including the default local hard drive including all the partitions on sd0. I can set options to prevent that and to use a custom mount command. Right click over the xfce4-mount icon and select Properties | File Systems tab. Add the pattern /dev/sd0* to the Exclude specified file systems textbox so the local drive is not listed.

Right-click on the xfce4-mount icon, and selected Preferences | Commands and write the following in the Custom Commands textboxes, after ensuring that the Custom Commands checkbox was ticked...

doas mount %m
doas umount %m

Now to ensure that a USB stick is listed in the xfce4-mount-popup list, you have to add a line for the device to /etc/fstab. My extra line looks like this (adapted from the examples in man fstab...

/dev/sd1i /home/keith/usb msdos rw,noauto 0 0

Using an fstab entry like this means that only one vfat formatted USB thumb drive will be listed and available with mouse clicks.

Set up updates

Background reading: pages about following the -stable branch or following the -current branch, and the OpenBSD 6.5 Errata page.

The syspatch command provides binary updates to the core system. Running the syspatch command without arguments on OpenBSD 6.4 gave... (illustration only, see errata page for OpenBSD 6.5 for the downloads to expect)...

$ su
foo# syspatch                                                           
Get/Verify syspatch64-001_xserver... 100% |*************|  1227 KB    00:04    
Installing patch 001_xserver
Get/Verify syspatch64-002_syspatc... 100% |*************|  4627       00:00    
Installing patch 002_syspatch
syspatch updated itself, run it again to install missing patches
foo# syspatch 

M:Tier sponsors OpenBSD and has provided binpatches for the packages in the stable release for use together with the openup script. They recommend using openup to upgrade packages that you have installed in addition to the base system. I have yet to try openup on OpenBSD 6.5

Install OpenBSD with whole drive encryption (advanced)

Background reading: OpenBSD FAQ sections 14.1, 14.2 and 14.3.

In OpenBSD 6.4 I used the commands detailed in the FAQ to create an encrypted softraid device and then install OpenBSD within that device. I omitted the command to over-write the disk with random numbers because of time.

Because I install from a USB stick, the drive numbering is 'off by one' compared to the example commands in the FAQ, so the fixed disk in the laptop is sd0 and the USB stick that I am installing from is sd1. The softraid device I install OpenBSD to is therefore sd2. The commands I actually used in the installer shell session are shown below.

Boot from the installer USB stick and then select [S]hell to get a command prompt...

# fdisk -iy sd0		# MBR not GPT
# disklabel -E sd0
>a a
size:[the size of your drive]
FS type:[4.2BSD] RAID
No label changes
# bioctl -c C -l sd0a softraid0
New pass phrase:
re-type passphrase
# cd /dev && sh MAKEDEV sd2
# dd if=/dev/zero of=/dev/rsd2c bs=1m count=1
# exit

The exit command starts the installer script and you type in the root password, your user and the user password and so on. Then you select sd2 as the disk to install to. You also have to specify [disk] as the location of the package sets and then answer 'no' when asked if the disk is mounted, select sd1, mount the a partition. The installer script should then find the package sets.

When you reboot into the new installation, you will be asked to enter the pass phrase for the encrypted disk, and then OpenBSD should show the usual boot dialogue. You will see a message about renumbering the operating system disk as sd1, because the USB stick I installed from has been removed. The /etc/fstab file shows UUIDs for each partition, so the boot loader can find the partitions.

Keith Burnett, 6th June 2019: Updated for OpenBSD 6.5, and again on 23rd October 2019 for OpenBSD 6.6