|
|
Subscribe / Log in / New account

PostmarketOS: Linux for phones and more

July 3, 2024

This article was contributed by Koen Vervloesem

In 2016, Oliver Smith reached a point of frustration with the short lifespan of updates for his Android phone. Taking matters into his own hands, he began developing postmarketOS, a Linux distribution for mobile phones. Eight years later, the core team and trusted contributors have grown to twenty individuals, while the latest release, v24.06, now shows support for over 250 devices. Although postmarketOS isn't usable as a day-to-day phone operating system on all of them, it can also enable repurposing devices into compact servers or kiosk machines.

On its web site, postmarketOS is described as a "real Linux distribution for phones and other mobile devices". Unlike mainstream mobile operating systems, this means that users have full control over postmarketOS. It gives them the freedom to tinker, back up and restore their complete home directory, turn their phone into a second display or other USB gadget, and to be able to choose from multiple interfaces (what would be called "desktop environments" on non-mobile systems).

PostmarketOS is based on Alpine Linux, a lightweight Linux distribution that also serves as a popular base for Linux containers. The recently announced v24.06 release is built on Alpine Linux 3.20. All of the interfaces have received an upgrade since the v23.12 release from December 2023. In particular, KDE Plasma Mobile 6 provides a lot of new functionality, including the introduction of a new home screen that allows users to customize pages with apps, folders, and widgets.

Device support

As with any mobile Linux distribution, the primary concern of prospective users is probably device support, since it can't be expected that postmarketOS will support any arbitrary phone. The project's wiki has an automatically generated page with supported devices, grouped into three categories according to their support status: main, community, and testing.

Understanding these categories is vital to adjust expectations prior to installing postmarketOS onto a device. A newly ported device starts out in the testing category. It's only promoted to the community category once certain requirements are met. These requirements are not related to the feature set, but rather pertain to the maintenance of the port. This includes well-documented installation instructions, a (close to) mainline kernel, automatic kernel upgrades, and an active maintainer participating in the release process. There are dozens of devices in the community category, including phones, tablets, Arm-based laptops, and even some single-board computers. When considering one of these, always consult the feature matrix to know what to expect, and thoroughly read the device-specific wiki page for any potential caveats.

A port is elevated to the highest category only if it's actively maintained by at least two people and can be fully used as a phone. This includes having a functional user interface, working phone calls, and support for many other features users expect on a phone: SMS messages, mobile data, WiFi, audio, battery charging, and Bluetooth. Note that a working camera is not listed among the required features. Currently, only two phones are in the main category: the PINE64 PinePhone and the Purism Librem 5, both of which have all of the main features operational but only have a partially functional camera. LWN looked at the PinePhone back in February 2022.

Installing postmarketOS

Two primary installation methods are available for postmarketOS. The first method entails downloading a pre-built image and flashing it onto the phone. The images on the download page are largely main and community devices, along with a few devices in the testing category. This is the easiest method, albeit one lacking customization options.

The second method, available for all devices, requires building a customized image using pmbootstrap. Even for devices that have a pre-built image available, this is an interesting method, since it allows choosing the user interface, pre-installing specific packages, and performing other customizations.

Pmbootstrap works by setting up a chroot environment with Alpine Linux and installing the desired packages within it, similar to Debian's debootstrap. It requires at least 10GB of free space and runs on most Linux distributions that have Python 3, OpenSSL, and Git installed. Pmbootstrap is available in various distribution repositories, but using the package from Ubuntu 24.04 immediately failed for me, due to its 2.1 version being outdated, prompting me to install the latest version from Git.

An invocation of "pmbootstrap init" initializes the working environment after asking some questions, such as the update channel to get packages from, the device vendor, and the device name. It also allows choosing a user name, the WiFi backend (wpa_supplicant or iwd), and the user interface. For my PinePhone, I selected Phosh, which was originally developed by Purism for its Librem 5; it is a phone shell based on GNOME and Wayland. Subsequently, any additional packages to be installed can be specified as a comma-separated list, and the time zone, locale, and host name can be set. The initialization process also allows copying an SSH public key to the device to log into it later.

[Phosh on postmarketOS]

Following this preparation, "pmbootstrap install --sdcard /dev/DEVICENAME" command builds the custom image for the phone and writes it to the microSD card specified. Creating an image with full-disk encryption requires appending the --fde option to the install command.

The command first prepares the chroot and creates the root filesystem for the device. The login password prompt allows choosing between only numeric characters (since a PIN code is easier to input) and alphanumeric characters for more security. Finally, pmbootstrap writes the boot and root filesystems to the microSD card. The device-specific wiki page provides more information for those devices requiring it. A "pmbootstrap shutdown" command cleans up the process, and the microSD card can then be inserted into the phone. The entire procedure went smoothly during a test installation on my PinePhone.

An alternative to writing an image to a microSD card is to generate the image with "pmbootstrap install" and then flash it to the connected device with "pmbootstrap flasher". The exact steps can be found on the device's wiki page.

Working with Phosh on postmarketOS doesn't differ that much from interacting with the same shell on any other mobile Linux distribution, such as Mobian, which we covered here in April 2023. Most of the applications are the same; installing and updating software is done with GNOME Software. It is configured for installing packages from the Alpine and postmarketOS repositories, as well as Flatpaks from Flathub. The same packages can also be installed using Alpine's command-line package manager apk or the flatpak command in the GNOME Console app.

Naturally, development of Phosh hasn't stagnated since we looked at it in Mobian last year. The new Phosh 0.39.0 in the latest postmarketOS release has added some nice features. This includes the capability to select the WiFi network in the quick settings by long-pressing the WiFi icon, and opening the on-screen keyboard using a long press on the bottom bar.

Further development

Just like its parent distribution Alpine Linux, postmarketOS uses OpenRC as its default init system. However, running GNOME or KDE on OpenRC presents certain challenges, since parts of systemd had to be reimplemented to support those desktop environments:

In order to get KDE and GNOME working at all, we use a lot of systemd polyfills on top of OpenRC. So while we are technically "not using systemd", in practice we already do use a large chunk of its components to get KDE and GNOME running, just different versions of those components.

For instance, openrc-settingsd reimplements systemd's hostnamed, localed, and timedated. Other adaptations reimplement parts of systemd-logind, systemd --user, and journald. A major issue is that some of the code chunks adapting to systemd ("polyfills"), such as those for systemd.timer and systemd-coredumpd, are unmaintained. So, the developers made the decision to begin developing postmarketOS on top of systemd, at least for GNOME and KDE. Users building their own image with pmbootstrap will retain the option to select OpenRC. Images of postmarketOS with the minimalist Sxmo interface will stay with OpenRC.

Initial systemd support targets the next release, v24.12, due in December of this year. While systemd officially only supports the GNU C Library (glibc) and postmarketOS and Alpine Linux are based on the lightweight musl libc, the developers don't consider the required changes to be a big problem, based on an LWN comment. The announcement also noted that systemd facilitates some new features in postmarketOS. For instance, socket activation enables printing from the phone without having CUPS running all the time. One caveat is that switching a phone with postmarketOS to systemd will require a reinstall.

Another change that postmarketOS is planning is a switch to PipeWire. For now, PulseAudio is still the distribution's default sound server, but the recent postmarketOS release has removed a hard-coded dependency on PulseAudio in numerous packages, allowing developers to experiment with PipeWire. In the long term, the project is also exploring the prospect of releasing an immutable version of the operating system.

Conclusion

While PostmarketOS may not be a mobile operating system suitable for all, it is certainly usable for Linux enthusiasts. The devices with the best support, the Librem 5 and the PinePhone, unfortunately aren't the greatest in terms of battery life and performance. However, Phosh is a capable mobile user interface on these devices, including functional phone calls and SMS messages.

Combined with the fact that this is a real Linux distribution that you can mold to your liking, install Linux packages on, and back up with tools such as rsync, postmarketOS undoubtedly serves a niche that includes many non-phone use cases. For instance, you could build your own image with the Wayland kiosk compositor Cage. This displays a single maximized application, which is a perfect solution to repurpose an old phone into a control panel for a home-automation system.


Index entries for this article
GuestArticlesVervloesem, Koen


to post comments


Copyright © 2024, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds