sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

commit c0452b403462e0bd13808815aa4946fbc69a2360
parent 02c0424c1edb9075f2a6e034ad0fd04d544b010a
Author: Divan Visagie <me@divanv.com>
Date:   Fri, 16 Oct 2026 02:35:35 +0200

An experiment between two bases: linux/ and freebsd/

The Ubuntu bootc build moves into linux/ unchanged, apart from compiling
bootc 1.17.1 into the image, which isn't tested yet (1.15.2 fails
upgrades that bring a changed layer: "Invalid splitstream content
type"). freebsd/ is a bsdt VM on FreeBSD 15.1 with a ZFS root, where
boot environments gave atomic updates, rollback and shipping a build as
a ZFS stream (2.9 GB whole, 5.1 MB incremental) with FreeBSD's own
tools, /home being a dataset already. The README says what the
experiment is.

ADR-0004 settles app.toml's format 1, and ADR-0005 the Mac model: apps
bring everything but a small, versioned platform; base images and the
runner (ADR-0002/0003) become the fallback.

Diffstat:
M.gitignore | 11+++++++----
DContainerfile | 90-------------------------------------------------------------------------------
MREADME.md | 67++++++++++++++++++++++++++++---------------------------------------
Ddesktop/build.sh | 55-------------------------------------------------------
Mdocs/adr/0002-an-app-is-a-folder-on-an-image-base.md | 3++-
Mdocs/adr/0003-apps-run-in-thin-jails.md | 3++-
Adocs/adr/0004-app-toml-format-1.md | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/adr/0005-apps-bring-their-own-on-a-small-platform.md | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/notes.md | 14+++++++-------
Afreebsd/README.md | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Afreebsd/bsdt.toml | 35+++++++++++++++++++++++++++++++++++
Afreebsd/stage.sh | 23+++++++++++++++++++++++
R.dockerignore -> linux/.dockerignore | 0
Alinux/Containerfile | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alinux/desktop/build.sh | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rdesktop/builder.Containerfile -> linux/desktop/builder.Containerfile | 0
Rsystem/etc/NetworkManager/conf.d/10-globally-managed-devices.conf -> linux/system/etc/NetworkManager/conf.d/10-globally-managed-devices.conf | 0
Rsystem/etc/accountsservice/user-templates/administrator -> linux/system/etc/accountsservice/user-templates/administrator | 0
Rsystem/etc/accountsservice/user-templates/standard -> linux/system/etc/accountsservice/user-templates/standard | 0
Alinux/vm/README.md | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rvm/build.sh -> linux/vm/build.sh | 0
Rvm/clean.sh -> linux/vm/clean.sh | 0
Rvm/common.sh -> linux/vm/common.sh | 0
Rvm/disk.sh -> linux/vm/disk.sh | 0
Rvm/registries.conf -> linux/vm/registries.conf | 0
Rvm/registry.sh -> linux/vm/registry.sh | 0
Rvm/vm.sh -> linux/vm/vm.sh | 0
Rvm/zfs-home.sh -> linux/vm/zfs-home.sh | 0
Dvm/README.md | 75---------------------------------------------------------------------------
29 files changed, 553 insertions(+), 272 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,9 +1,9 @@ # What the VM scripts make: the disk images, the SSH key, podman's storage, -# logs (vm/README.md). -/out/ +# logs (linux/vm/README.md). +/linux/out/ -# What desktop/build.sh makes: the source it builds, cargo's target, the staging. -/build/ +# What linux/desktop/build.sh makes: the source it builds, cargo's target, the staging. +/linux/build/ # Disk images, logs and private keys anywhere else, should one land outside out/. *.raw @@ -21,3 +21,6 @@ id_rsa .DS_Store .idea/ .vscode/ + +# What freebsd/stage.sh copies in for the VM to build. +/freebsd/src/ diff --git a/Containerfile b/Containerfile @@ -1,90 +0,0 @@ -# Patina OS: the Ubuntu 26.04 bootc base with a current kernel, the Patina -# desktop and what it needs, logged into from GDM. Two images come out of it: -# -# system the real one -# dev the system plus what the test VM needs: a user to log in as, and -# trust in the development registry (vm/README.md) -# -# The desktop is built first by desktop/build.sh into build/desktop/. - -# apt's database as a fresh Ubuntu has it: the base image empties /var, so -# derived images restore it to use apt (as the base's AGENTS.md describes). -FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 AS dpkg-state - -# ubuntu-bootc's minimal 26.04 base, pinned by digest (docs/notes.md). -FROM ghcr.io/ubuntu-bootc/ubuntu-26.04-bootc@sha256:d50ac19557f0b5bc56a980178aa68e3675735ad06b3750b4c9af967901e966f4 AS system - -COPY --from=dpkg-state /var/lib/dpkg /var/lib/dpkg - -# The base's kernel (7.0.0-15) has the fs-verity regression that stops a -# composefs system booting ("Failed to execute /sbin/init: Input/output error", -# bootc issue 2174, fixed from 7.0.7). Take the archive's current kernel, keep -# only it, and build its initramfs with the base's dracut settings. Kernel hooks -# are stubbed by the base, and /boot is emptied: bootc boots from /usr/lib/modules. -# -# Then what the desktop needs: GDM to log in, NetworkManager (patina-wifi), -# PipeWire and WirePlumber (wpctl, for the volume keys), Mesa (EGL, GBM), -# libinput, libseat, xkb's layouts, fonts, and foot as a terminal. The -# libraries are what the binaries link or load (see desktop/build.sh). -# -# And ZFS's tools, for the pool /home lives on (ADR-0001); the module comes -# with Ubuntu's kernel. A pool belongs to its machine, so the image holds -# none, nor a host ID (zfsutils makes one as it installs, which every machine -# would then share) or a pool cache: the installer makes those -# (vm/zfs-home.sh stands in for it). -RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log/apt \ - /var/tmp /var/roothome && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - dracut linux-image-generic && \ - kver=$(ls /usr/lib/modules | sort -V | tail -1) && \ - for k in /usr/lib/modules/*; do [ "${k##*/}" = "$kver" ] || rm -rf "$k"; done && \ - cp "/boot/vmlinuz-$kver" "/usr/lib/modules/$kver/vmlinuz" && \ - dracut --force --kver "$kver" "/usr/lib/modules/$kver/initramfs.img" && \ - rm -rf /boot/* && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - gdm3 dbus-user-session polkitd \ - network-manager \ - pipewire pipewire-pulse wireplumber \ - libegl1 libegl-mesa0 libgbm1 libgl1-mesa-dri mesa-vulkan-drivers \ - libwayland-server0 libwayland-client0 libwayland-egl1 \ - libinput10 libseat1 libxkbcommon0 xkb-data libpixman-1-0 libdrm2 \ - fonts-dejavu-core fonts-ubuntu hicolor-icon-theme adwaita-icon-theme \ - xdg-user-dirs foot \ - zfsutils-linux zfs-zed && \ - rm -f /etc/hostid /etc/zfs/zpool.cache && \ - apt-get clean && \ - rm -rf /var && mkdir /var - -# Files the system adds to the base, as laid out under system/. -COPY system/ / - -# The Patina desktop, and "Patina" as GDM's session. -COPY build/desktop/ / - -RUN systemctl enable gdm.service NetworkManager.service \ - zfs-import-cache.service zfs-mount.service zfs-zed.service \ - zfs-import.target zfs.target && \ - systemctl set-default graphical.target - -RUN bootc container lint - -# --------------------------------------------------------------------------- - -FROM system AS dev - -# Trust the development registry: localhost:5000 on the host, which is 10.0.2.2 -# from inside a QEMU VM. -COPY vm/registries.conf /etc/containers/registries.conf.d/50-patina-dev.conf - -# A user to log in as at GDM: patina, password patina, allowed sudo. Its home -# is made at boot, since /var starts empty. -RUN useradd -M -d /var/home/patina -s /bin/bash -G sudo patina && \ - echo patina:patina | chpasswd && \ - echo 'd /var/home/patina 0700 patina patina -' > /usr/lib/tmpfiles.d/patina-dev-user.conf - -# Which build this is, so an upgrade can be seen to have happened. -ARG BUILD_ID=unknown -RUN echo "$BUILD_ID" > /usr/lib/patina-os/build - -RUN bootc container lint diff --git a/README.md b/README.md @@ -1,47 +1,36 @@ # Patina OS -A Linux based operating system image for the Patina desktop: Ubuntu as a bootc image, so a machine boots -one known-good build, updates by moving to the next one whole, and rolls back if it breaks. -The user's data lives on a ZFS pool beside it. +An experiment to find which operating system base makes the least complicated OS for the +Patina desktop: one where a machine boots a known-good build of the system, updates by moving to +the next one whole, rolls back if it breaks, and keeps the user's data and apps apart from it. -The image builds and runs in a VM: GDM logs in to the Patina desktop, and the system upgrades -and rolls back ([vm/README.md](vm/README.md)). See [docs/adr](docs/adr) for decisions and -[docs/notes.md](docs/notes.md) for the research and open questions behind them. +Two bases are being tried, side by side: + +- **[linux/](linux/)**: Ubuntu 26.04 as a bootc image, built from a Containerfile, with `/home` + on a ZFS pool. It boots in a VM to GDM and the Patina desktop, and upgrades and rolls back + ([linux/vm/README.md](linux/vm/README.md)), but took a newer kernel, workarounds for bootc's + young Ubuntu support, and still has an open bug: upgrades that change a large layer fail. +- **[freebsd/](freebsd/)**: FreeBSD 15.1 on ZFS, where the system is a boot environment and + `/home` a dataset out of the box; updates, rollback and shipping a build are `bectl` and ZFS + streams ([freebsd/README.md](freebsd/README.md)). + +The app model (an app is a folder, as on a Mac) and the principles below hold whichever base +wins. See [docs/adr](docs/adr) for decisions and [docs/notes.md](docs/notes.md) for the research +and open questions behind them. ## Principles -- **The core is locked; apps are the user's.** The image is the whole system, the same on - every machine and read-only while it runs. Everything a user adds (apps, tools, their - settings) lives in their home folder, so it survives every system update and rollback, and - never changes the system under it. -- **Built like any container.** The image comes from a Containerfile, built and pushed with - the same tools and registries as Docker images, and as reproducible as we pin it. No - from-scratch distro to maintain: Ubuntu provides the packages, we choose and arrange them. +- **The core is locked; apps are the user's.** The system is one unit, the same on every + machine and not changed while it runs. Everything a user adds (apps, tools, their settings) + lives in their home folder, so it survives every system update and rollback, and never + changes the system under it. +- **Built, not assembled by hand.** The system is built from a recipe, repeatably, and shipped + whole, rather than each machine being installed and upgraded package by package. No + from-scratch distro to maintain: the base provides the packages, we choose and arrange them. - **An app is a folder.** `~/Apps/Name.app`, with an `app.toml` saying how to run it: - copy it in to install, delete it to uninstall, never touch the system. It runs on the base - image it names by digest, in a thin jail, so system updates never break it (ADR-0002, - ADR-0003). + copy it in to install, delete it to uninstall, never touch the system. As on a Mac, it brings + everything but a small, versioned platform the system guarantees (the C library, Wayland, the + GPU's drivers), so system updates never break it (ADR-0002, ADR-0005). - **Opinionated.** One desktop (Patina), one way to add apps, one way to keep data (ZFS). -- **Something new.** Not a copy of another distro: fix what's missing on Linux, starting with - the blurred line between the system's packages and the user's. - -## The shape of it - -- **The system** is a container image built from a Containerfile: an Ubuntu bootc base, the - Patina desktop (patina-compositor and its pieces, from `../patina-desktop`), its session file - and PAM service, and the few packages a desktop needs. It's deployed with bootc on ext4 or - xfs: `/usr` is read-only, `/etc` keeps local changes across updates, `/var` is kept. -- **Updates** are a new image in a registry; `bootc upgrade` stages it for the next boot and - `bootc rollback` goes back one. -- **Data** is a ZFS pool for `/home` (and anything else worth snapshotting), using the ZFS - module Ubuntu builds for its own kernel, so it always matches. - -## Why not ... - -- **ZFS root with boot environments (ZFSBootMenu):** the FreeBSD way, and it works, but - rollback is only as good as the snapshots taken by hand, and nothing builds a known-good - system to ship. -- **bootc on a ZFS root:** two rollback systems doing one job, and a combination bootc isn't - tested on. -- **Fedora as the base:** bootc's best-supported base, but Fedora can't ship ZFS and its - kernels run ahead of what OpenZFS supports. +- **Something new.** Not a copy of another distro: fix what's missing, starting with the + blurred line between the system's packages and the user's. diff --git a/desktop/build.sh b/desktop/build.sh @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Builds the Patina desktop for the image, from patina-desktop's last commit -# (not its working tree, so stray changes don't ship), and lays out what the -# image adds in build/desktop/, as it goes under /: -# -# usr/bin/patina-* the binaries -# usr/share/wayland-sessions/patina.desktop "Patina" at the login screen -# etc/pam.d/patina-lock the lock screen's PAM service -# usr/lib/patina-os/desktop which commit it was built from -# -# PATINA_DESKTOP is the checkout (default: ../patina-desktop beside this one). -set -euo pipefail - -ROOT=$(cd "$(dirname "$0")/.." && pwd) -SRC=${PATINA_DESKTOP:-$ROOT/../patina-desktop} -BUILD="$ROOT/build" -STAGE="$BUILD/desktop" -BUILDER=patina-os-desktop-builder - -say() { printf '==> %s\n' "$*"; } - -[[ -d "$SRC/.git" ]] || { echo "error: no patina-desktop checkout at $SRC" >&2; exit 1; } -commit=$(git -C "$SRC" rev-parse HEAD) -dirty=$(git -C "$SRC" status --porcelain --untracked-files=no) -[[ -z "$dirty" ]] || say "patina-desktop has uncommitted changes; building its last commit, $commit" - -say "the build environment" -docker build -q -f "$ROOT/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/desktop" >/dev/null - -say "building patina-desktop $(git -C "$SRC" log --oneline -1)" -rm -rf "$BUILD/src" -mkdir -p "$BUILD/src" "$BUILD/target" -git -C "$SRC" archive HEAD | tar -x -C "$BUILD/src" -# Cargo's downloads are kept in a volume, and its target folder in build/, so -# rebuilds are incremental. As the user, so build/ stays theirs. -docker run --rm --user "$(id -u):$(id -g)" \ - -e CARGO_HOME=/cargo -e HOME=/tmp \ - -v patina-os-cargo:/cargo \ - -v "$BUILD/src:/src:ro" -v "$BUILD/target:/target" \ - -w /src "$BUILDER" \ - cargo build --release --locked --workspace --target-dir /target - -say "laying out build/desktop" -rm -rf "$STAGE" -binaries=(patina-bar patina-compositor patina-launcher patina-lock patina-menu - patina-volume patina-wallpaper patina-wifi) -install -d "$STAGE/usr/bin" -for b in "${binaries[@]}"; do - install -m 755 "$BUILD/target/release/$b" "$STAGE/usr/bin/" -done -install -d "$STAGE/usr/share/wayland-sessions" "$STAGE/etc/pam.d" "$STAGE/usr/lib/patina-os" -sed 's|@BINDIR@|/usr/bin|' "$BUILD/src/packaging/linux/patina.desktop" \ - > "$STAGE/usr/share/wayland-sessions/patina.desktop" -install -m 644 "$BUILD/src/packaging/linux/patina-lock.pam" "$STAGE/etc/pam.d/patina-lock" -echo "$commit" > "$STAGE/usr/lib/patina-os/desktop" diff --git a/docs/adr/0002-an-app-is-a-folder-on-an-image-base.md b/docs/adr/0002-an-app-is-a-folder-on-an-image-base.md @@ -4,7 +4,8 @@ Date: 2026-10-15 ## Status -Proposed +Proposed; amended by ADR-0005: an app's base is the small Patina platform, and a system +image only for apps that can't bring their own (the folder itself stands). ## Context diff --git a/docs/adr/0003-apps-run-in-thin-jails.md b/docs/adr/0003-apps-run-in-thin-jails.md @@ -4,7 +4,8 @@ Date: 2026-10-15 ## Status -Proposed +Proposed; made the fallback by ADR-0005: only apps whose dependencies can't be bundled run +this way, and it isn't built until one needs it. ## Context diff --git a/docs/adr/0004-app-toml-format-1.md b/docs/adr/0004-app-toml-format-1.md @@ -0,0 +1,79 @@ +# 0004. app.toml, format 1 + +Date: 2026-10-16 + +## Status + +Proposed + +## Context + +An app is a folder, `~/Apps/Name.app`, with an `app.toml` saying how to run it (ADR-0002), and +it will run in a thin jail on the base it names (ADR-0003). People will package apps against +this file, so it needs settling before code depends on it: what's required, what's optional, +how it grows, and what a launcher must refuse. + +The runner doesn't exist yet. The first launcher to read the format (patina-desktop's) runs +every app straight on the running system, so the format has to make sense both before and +after the runner arrives. + +## Decision + +```toml +format = 1 # required: the version of this file's format +name = "Teleprinter" # required: shown in the launcher +exec = "bin/teleprinter" # required: the program, inside the folder + +id = "com.sectorflabs.Teleprinter" # reverse-DNS; the default is the folder's name +summary = "Messages" # one line under the name, like a .desktop GenericName +comment = "Chat over the terminal" +keywords = ["chat", "messages"] # searched as well as the name +categories = ["Network"] # freedesktop main categories +icon = "icon.svg" # inside the folder: SVG or PNG +args = ["--window"] # passed to the program, after it +terminal = false # run it in a terminal +platform = 1 # the Patina platform it's built for (ADR-0005) +base = "patina-os:1@sha256:..." # the image it runs on (ADR-0002); see below +``` + +A program for more than one OS or CPU names one per target, as `{os}-{arch}` (Rust's +`std::env::consts::OS` and `ARCH`), the way a macOS app can carry Intel and Arm binaries: + +```toml +[exec] +linux-x86_64 = "bin/linux-x86_64/teleprinter" +linux-aarch64 = "bin/linux-aarch64/teleprinter" +freebsd-x86_64 = "bin/freebsd-x86_64/teleprinter" +``` + +The rules a launcher follows: + +- **Only folders named `*.app`** directly in `~/Apps` are apps; others, and hidden ones, are + left alone. +- **Paths stay inside the folder**: `exec` and `icon` are relative, and may not be absolute or + climb out with `..`. An app that breaks this isn't listed. +- **`exec` must be there and executable** on this platform, or the app isn't listed. With a + table and no entry for this platform, it isn't listed either. +- **`format` decides what's understood**: a launcher lists only formats it knows, and says why + it skipped the others. Within a format, keys it doesn't know are ignored, so optional keys + can be added without a new format; a new format is for changes old launchers would get wrong. +- **The program runs from the user's home folder**, with `args` after it. It finds its own + folder from its executable's path (`std::env::current_exe`), not from anything the launcher + sets, so it works however it's started. +- **`platform` is optional**: the Patina platform the app is built for (ADR-0005), which it + relies on for everything it doesn't bring. It's what most apps name. +- **`base` is optional in format 1.** Until the runner (ADR-0003) exists, every app runs on the + running system, and `base` is only recorded. Without one, an app runs on the running system + for good: its author takes on what that means. +- **File types, URL schemes and commands** (ADR-0002) aren't in format 1. They come when + something opens files and links by them, as optional keys. + +## Consequences + +- Packaging an app is a folder, a binary and a few lines of TOML; nothing is installed and + nothing needs root. +- The same file works on Linux and FreeBSD, with one binary for each. +- A launcher written for format 1 keeps working as optional keys are added, and refuses, with a + reason, an app it can't run correctly. +- Apps without `base` run on whatever system they're on, as AppImages do; with one, the runner + will give them that base exactly, once it exists. diff --git a/docs/adr/0005-apps-bring-their-own-on-a-small-platform.md b/docs/adr/0005-apps-bring-their-own-on-a-small-platform.md @@ -0,0 +1,63 @@ +# 0005. Apps bring everything but a small platform, as on a Mac + +Date: 2026-10-16 + +## Status + +Proposed. Amends ADR-0002 and ADR-0003: an app's base is the platform below, not a system +image, and the thin-jail runner becomes the fallback for apps that can't bring their own. + +## Context + +ADR-0002 had each app name a whole system image as its base, by digest, and ADR-0003 a runner to +give it that base in a thin jail. That answers "Linux has no guaranteed base" in full, at the +cost of a layer store, a runner and images of gigabytes. + +Measured on our own apps, it's more than they need. A Rust app is nearly self-contained already: +Teleprinter is 36 MB and links only glibc (libc, libm, libgcc_s), loading libwayland-client, +libxkbcommon and the GPU's EGL/GL/Vulkan when it runs. Bundling the first two adds a few hundred +kilobytes. What can't be bundled is short: + +- **The GPU's drivers**, which must match the hardware and, for NVIDIA, the kernel. They're the + system's, whatever else the app brings (as ADR-0003 already decided). +- **glibc**, which loads those drivers, and which runs old programs on newer versions but not + the reverse: Teleprinter built on Ubuntu 26.04 needs glibc 2.43. + +That is the macOS model: the system guarantees a small, stable set of frameworks, and an app +brings everything else in its folder. It's simpler than a runner for every app, and +it's what users expect of an `.app`. + +## Decision + +- **The Patina platform** is the short list Patina OS guarantees every app, versioned. A version + only ever gains; what it promises stays as long as Patina OS ships it. +- **Platform 1** (x86_64 and aarch64 Linux): + - glibc 2.39 or later (Ubuntu 24.04's): `libc.so.6`, `libm.so.6`, `libgcc_s.so.1`, + `libstdc++.so.6`; + - Wayland and input: `libwayland-client.so.0`, `libwayland-egl.so.1`, `libxkbcommon.so.0`, + and xkb's data; + - graphics, from the system's drivers: `libEGL.so.1`, `libGL.so.1`, `libvulkan.so.1`; + - the session's services: the Wayland socket, PipeWire (with its PulseAudio socket), the + session D-Bus, fonts in `/usr/share/fonts`, and CA certificates in `/etc/ssl/certs`. +- **An app brings everything else** in its folder: libraries in `lib/` (found through + `$ORIGIN`), data, its own fonts if it wants them. +- **app.toml says `platform = 1`** (an optional key in format 1, ADR-0004). Without it, the app + runs on whatever system it's on, as before. +- **Apps are built against the platform's floor**: in an environment with glibc 2.39, so they + run on 2.39 and everything later. A Patina SDK image (Ubuntu 24.04 with Rust) does that. +- **`base` and the runner (ADR-0003) stay as the fallback**, for apps whose dependencies can't + be bundled cleanly (deep GTK or Python stacks). They're no longer the default, and aren't + built until such an app needs them. + +## Consequences + +- Most apps are a folder of tens of megabytes that runs as it is, with no runner, no layer store + and no jail. +- Patina OS must keep platform 1's libraries and services in every image from now on; dropping + one is a new platform version and a break for the apps that named the old one. +- Apps built on a newer system than the floor (as Teleprinter is today, on 26.04) still run on + Patina OS, but don't meet platform 1 until rebuilt with the SDK. +- No sandbox by default: a folder app runs as the user, as a Mac app does outside the App Store. + Sandboxing, if it comes, grows from the runner's list (ADR-0003). +- FreeBSD gets a platform of its own (its libc, the same Wayland and graphics libraries), named + the same way, when there's a FreeBSD Patina OS. diff --git a/docs/notes.md b/docs/notes.md @@ -13,7 +13,7 @@ Research for Patina OS, and what's still open. Dated, since this moves quickly. at Ubuntu Summit 26.04 argued for officially packaged bootc components and base images. - **Confirmed 2026-10-16**: the minimal base's kernel (7.0.0-15) can't boot composefs (fs-verity regression in 7.0, bootc issue 2174, fixed from 7.0.7). The archive's 7.0.0-38 (nifl's and - huginn's) boots; the Containerfile installs it. vm/README.md has the rest of what the VM found. + huginn's) boots; the Containerfile installs it. linux/vm/README.md has the rest of what the VM found. ## Staying with Ubuntu (2026-10-16) @@ -25,7 +25,7 @@ Research for Patina OS, and what's still open. Dated, since this moves quickly. (ADR-0002/0003). Fedora is worst for ZFS, since its kernels outrun OpenZFS. - Kept Ubuntu because it's set up and the VM loop works on it. Its ZFS module comes built for each kernel, and uutils is already in. The cost is the newness of Ubuntu's bootc support (see - vm/README.md). If that keeps biting, a CentOS Stream 10 Containerfile goes through the same + linux/vm/README.md). If that keeps biting, a CentOS Stream 10 Containerfile goes through the same VM loop with small changes to the install step (the ostree backend instead of composefs). ## ZFS @@ -39,7 +39,7 @@ Research for Patina OS, and what's still open. Dated, since this moves quickly. user, `patina/home/<user>`, so each home snapshots and sends alone. - **Machine, not image**: the host ID (`/etc/hostid`; zfsutils makes one as it installs, so the image deletes it) and the pool cache (`/etc/zfs/zpool.cache`) are in `/etc`, which bootc - keeps per machine across updates; the pool is outside the image. vm/zfs-home.sh does the + keeps per machine across updates; the pool is outside the image. linux/vm/zfs-home.sh does the per-machine part, standing in for the installer. - **Mounting order**: zfs-mount runs before local-fs.target, so the homes are there before tmpfiles, GDM or any login. @@ -56,10 +56,10 @@ nothing in the image may assume it. Collected as they come up: - Partition: EFI, the system partition for bootc, and the rest for the ZFS pool (or a second disk). `bootc install to-disk` takes a whole disk, so the installer partitions itself and - uses `bootc install to-filesystem` (vm/disk.sh uses to-disk, with the pool on a second disk). + uses `bootc install to-filesystem` (linux/vm/disk.sh uses to-disk, with the pool on a second disk). - `bootc install` with `--target-imgref` set to where this machine updates from. - ZFS: `zgenhostid`, `zpool create` on a stable name (`/dev/disk/by-id/...`), the cache file, - `patina/home` and the first user's dataset, as vm/zfs-home.sh does. + `patina/home` and the first user's dataset, as linux/vm/zfs-home.sh does. - The first user: the real image has none (the dev stage's `patina` is for the VM). ## Apps in the home folder @@ -114,10 +114,10 @@ Open, roughly in order: ## The image -- **Done 2026-10-16**: the Containerfile adds the Patina desktop (built by desktop/build.sh into +- **Done 2026-10-16**: the Containerfile adds the Patina desktop (built by linux/desktop/build.sh into `/usr/bin`, with its session file and PAM service), GDM, NetworkManager, PipeWire and WirePlumber, Mesa, fonts and foot. In the VM, GDM logs in to the Patina session, and the - launcher starts apps. vm/README.md has what it took. + launcher starts apps. linux/vm/README.md has what it took. - Open: GDM brings much of GNOME's plumbing; a Patina login screen (as patina-lock replaced swaylock) could replace it later. - Open: where images are pushed (a registry: ghcr.io, or our own), and signing them. diff --git a/freebsd/README.md b/freebsd/README.md @@ -0,0 +1,53 @@ +# Patina OS on FreeBSD + +An experiment: is FreeBSD a simpler base for Patina OS than Ubuntu with bootc (`../linux`)? +FreeBSD has most of what bootc adds to Linux built in, on ZFS: + +| Patina OS needs | Ubuntu (linux/) | FreeBSD | +|---|---|---| +| The system as one unit, booted whole | a bootc image on composefs | a boot environment: a ZFS dataset for `/`, `bectl` | +| Update atomically | `bootc upgrade`, the next image at the next boot | a new boot environment, upgraded, activated for the next boot | +| Roll back | `bootc rollback` | `bectl activate` the previous one, or pick it at the loader | +| Ship a build | an OCI image in a registry | `zfs send` of a built boot environment, `zfs receive` on the machine | +| `/home` on ZFS | zfsutils from Ubuntu's archive, a pool made per machine | `zroot/home`, part of every ZFS install | +| Build the system | a Containerfile, apt, bootc compiled newer than the base's | pkg (and pkgbase on 15) into a boot environment | + +What the VM can't show: QEMU's graphics have no FreeBSD driver, so the desktop runs nested on a +headless sway over VNC, not as a session on real graphics (drm-kmod on hardware). + +## Running it + +``` +freebsd/stage.sh copy patina-desktop's last commit into freebsd/src/ for the VM to build +cd freebsd && bsdt up boot it (the first time: FreeBSD's ZFS image, packages, the build) +bsdt ssh a shell in it +bsdt key super+shift+3 a screenshot, with Patina's own key, into the VM's ~/Pictures/Screenshots +``` + +## What it found (2026-10-16) + +Everything in the table worked the first time, with FreeBSD's own tools and nothing built or +worked around: + +- **The layout is already Patina's.** FreeBSD's ZFS image has `/` as a boot environment + (`zroot/ROOT/default`) and `zroot/home` as its own dataset. `/usr/local`, where packages and + Patina go, is inside the boot environment, so it's part of the system; `/home`, `/var/log` + and `/tmp` are outside it. +- **pkgbase.** 15.1's base system is installed as packages (`FreeBSD-*`, 719 of them), so the + whole system, base and packages, is updated with `pkg`, including into a boot environment + that isn't running (`pkg -r /mnt`). +- **The desktop builds and runs.** patina-desktop built in 4 minutes from FreeBSD's packages and + runs nested on the headless sway. +- **Atomic update.** `bectl create`, change the copy (`bectl mount`, `pkg -r`), `bectl activate`, + reboot: the new system came up whole; the running one was never touched. +- **Rollback.** `bectl activate` the previous one and reboot: back to the first build, with + Patina still installed. +- **Shipping a build.** `bectl export` wrote the whole system as a ZFS stream, 2.9 GB with zstd, + in 15 seconds; `bectl import` took it in as a new boot environment that booted. An + incremental stream (one binary and a file changed) was 5.1 MB, so a machine that has the last + build receives only what changed, as a registry's layers would give. +- **/home stayed put** through every switch: a file written there was the same in every boot + environment. + +Not tried here: the desktop on real graphics (drm-kmod), a login screen, and building a boot +environment from a recipe on a build machine rather than by hand in the VM. diff --git a/freebsd/bsdt.toml b/freebsd/bsdt.toml @@ -0,0 +1,35 @@ +# Patina OS on FreeBSD: a bsdt(1) VM to see whether FreeBSD makes a simpler +# base than Ubuntu with bootc (README.md). FreeBSD 15.1 on a ZFS root, so boot +# environments (bectl) and /home as a dataset come with the system. +# +# freebsd/stage.sh copy patina-desktop's last commit into src/ (run first) +# bsdt up from freebsd/: boot it, build the desktop on first boot +# +# QEMU's graphics have no FreeBSD driver, so the desktop runs nested: the +# compositor in a window on a headless sway, shown over VNC. + +[vm] +os = "freebsd" +version = "15.1" +cpus = 4 +memory = "4G" +disk = "30G" +filesystem = "zfs" +hostname = "patina" +gui = true + +[packages] +# What patina-desktop builds against (its `make deps`), and Rust. +install = ["rust", "git", "pkgconf", "libxkbcommon", "pixman", "libudev-devd", "libinput", + "seatd", "mesa-libs", "libdrm", "wayland"] + +[sync] +exclude = ["src/patina-desktop/target"] + +[provision] +run = ["cd src/patina-desktop && cargo build --release"] + +[gui] +desktop = "sway" +open = false +start = "exec src/patina-desktop/target/release/patina-compositor" diff --git a/freebsd/stage.sh b/freebsd/stage.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Copies patina-desktop's last commit into freebsd/src/patina-desktop, which +# bsdt syncs into the VM (it syncs only this folder). PATINA_DESKTOP is the +# checkout (default: patina-desktop beside patina-os); PATINA_DESKTOP_WORKTREE=1 +# copies its working tree instead, uncommitted changes and all. +set -euo pipefail + +HERE=$(cd "$(dirname "$0")" && pwd) +SRC=${PATINA_DESKTOP:-$HERE/../../patina-desktop} +DEST="$HERE/src/patina-desktop" + +[[ -d "$SRC/.git" ]] || { echo "error: no patina-desktop checkout at $SRC" >&2; exit 1; } +# Keep cargo's target folder, if the VM's build left one, so rebuilds are quick. +mkdir -p "$DEST" +find "$DEST" -mindepth 1 -maxdepth 1 ! -name target -exec rm -rf {} + +if [[ -n "${PATINA_DESKTOP_WORKTREE:-}" ]]; then + git -C "$SRC" ls-files -z --cached --others --exclude-standard | + tar -c -C "$SRC" --null -T - | tar -x -C "$DEST" + echo "==> staged patina-desktop's working tree (on $(git -C "$SRC" rev-parse --short HEAD))" +else + git -C "$SRC" archive HEAD | tar -x -C "$DEST" + echo "==> staged patina-desktop $(git -C "$SRC" rev-parse --short HEAD)" +fi diff --git a/.dockerignore b/linux/.dockerignore diff --git a/linux/Containerfile b/linux/Containerfile @@ -0,0 +1,110 @@ +# Patina OS: the Ubuntu 26.04 bootc base with a current kernel, the Patina +# desktop and what it needs, logged into from GDM. Two images come out of it: +# +# system the real one +# dev the system plus what the test VM needs: a user to log in as, and +# trust in the development registry (vm/README.md) +# +# The desktop is built first by desktop/build.sh into build/desktop/. + +# apt's database as a fresh Ubuntu has it: the base image empties /var, so +# derived images restore it to use apt (as the base's AGENTS.md describes). +FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 AS dpkg-state + +# bootc itself, newer than the base's 1.15.2: with 1.15.2 an upgrade that brings +# a changed layer fails ("Invalid splitstream content type"), as does +# installing straight from a registry. Built from source as the base builds +# its own, with rustup's Rust. +FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 AS bootc + +ARG BOOTC_VERSION=v1.17.1 +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential ca-certificates curl git go-md2man libostree-dev libzstd-dev \ + make ostree pkgconf libselinux1-dev clang libclang-dev && \ + rm -rf /var/lib/apt/lists/* +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ + sh -s -- --profile minimal -y && \ + git clone --depth 1 --branch "$BOOTC_VERSION" https://github.com/bootc-dev/bootc.git /src && \ + cd /src && . "$HOME/.cargo/env" && \ + make bin install-all DESTDIR=/output + +# ubuntu-bootc's minimal 26.04 base, pinned by digest (docs/notes.md). +FROM ghcr.io/ubuntu-bootc/ubuntu-26.04-bootc@sha256:d50ac19557f0b5bc56a980178aa68e3675735ad06b3750b4c9af967901e966f4 AS system + +COPY --from=dpkg-state /var/lib/dpkg /var/lib/dpkg +# Before the initramfs is built below: its composefs setup is bootc's too. +COPY --from=bootc /output / + +# The base's kernel (7.0.0-15) has the fs-verity regression that stops a +# composefs system booting ("Failed to execute /sbin/init: Input/output error", +# bootc issue 2174, fixed from 7.0.7). Take the archive's current kernel, keep +# only it, and build its initramfs with the base's dracut settings. Kernel hooks +# are stubbed by the base, and /boot is emptied: bootc boots from /usr/lib/modules. +# +# Then what the desktop needs: GDM to log in, NetworkManager (patina-wifi), +# PipeWire and WirePlumber (wpctl, for the volume keys), Mesa (EGL, GBM), +# libinput, libseat, xkb's layouts, fonts, and foot as a terminal. The +# libraries are what the binaries link or load (see desktop/build.sh). +# +# And ZFS's tools, for the pool /home lives on (ADR-0001); the module comes +# with Ubuntu's kernel. A pool belongs to its machine, so the image holds +# none, nor a host ID (zfsutils makes one as it installs, which every machine +# would then share) or a pool cache: the installer makes those +# (vm/zfs-home.sh stands in for it). +RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log/apt \ + /var/tmp /var/roothome && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + dracut linux-image-generic && \ + kver=$(ls /usr/lib/modules | sort -V | tail -1) && \ + for k in /usr/lib/modules/*; do [ "${k##*/}" = "$kver" ] || rm -rf "$k"; done && \ + cp "/boot/vmlinuz-$kver" "/usr/lib/modules/$kver/vmlinuz" && \ + dracut --force --kver "$kver" "/usr/lib/modules/$kver/initramfs.img" && \ + rm -rf /boot/* && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + gdm3 dbus-user-session polkitd \ + network-manager \ + pipewire pipewire-pulse wireplumber \ + libegl1 libegl-mesa0 libgbm1 libgl1-mesa-dri mesa-vulkan-drivers \ + libwayland-server0 libwayland-client0 libwayland-egl1 \ + libinput10 libseat1 libxkbcommon0 xkb-data libpixman-1-0 libdrm2 \ + fonts-dejavu-core fonts-ubuntu hicolor-icon-theme adwaita-icon-theme \ + xdg-user-dirs foot \ + zfsutils-linux zfs-zed && \ + rm -f /etc/hostid /etc/zfs/zpool.cache && \ + apt-get clean && \ + rm -rf /var && mkdir /var + +# Files the system adds to the base, as laid out under system/. +COPY system/ / + +# The Patina desktop, and "Patina" as GDM's session. +COPY build/desktop/ / + +RUN systemctl enable gdm.service NetworkManager.service \ + zfs-import-cache.service zfs-mount.service zfs-zed.service \ + zfs-import.target zfs.target && \ + systemctl set-default graphical.target + +RUN bootc container lint + +# --------------------------------------------------------------------------- + +FROM system AS dev + +# Trust the development registry: localhost:5000 on the host, which is 10.0.2.2 +# from inside a QEMU VM. +COPY vm/registries.conf /etc/containers/registries.conf.d/50-patina-dev.conf + +# A user to log in as at GDM: patina, password patina, allowed sudo. Its home +# is made at boot, since /var starts empty. +RUN useradd -M -d /var/home/patina -s /bin/bash -G sudo patina && \ + echo patina:patina | chpasswd && \ + echo 'd /var/home/patina 0700 patina patina -' > /usr/lib/tmpfiles.d/patina-dev-user.conf + +# Which build this is, so an upgrade can be seen to have happened. +ARG BUILD_ID=unknown +RUN echo "$BUILD_ID" > /usr/lib/patina-os/build + +RUN bootc container lint diff --git a/linux/desktop/build.sh b/linux/desktop/build.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# Builds the Patina desktop for the image, from patina-desktop's last commit +# (not its working tree, so stray changes don't ship), and lays out what the +# image adds in build/desktop/, as it goes under /: +# +# usr/bin/patina-* the binaries +# usr/share/wayland-sessions/patina.desktop "Patina" at the login screen +# etc/pam.d/patina-lock the lock screen's PAM service +# usr/lib/patina-os/desktop which commit it was built from +# +# PATINA_DESKTOP is the checkout (default: patina-desktop beside patina-os). +# PATINA_DESKTOP_WORKTREE=1 builds its working tree instead, uncommitted +# changes and all, to try them in the VM; the image then says "+dirty". +set -euo pipefail + +ROOT=$(cd "$(dirname "$0")/.." && pwd) +SRC=${PATINA_DESKTOP:-$ROOT/../../patina-desktop} +BUILD="$ROOT/build" +STAGE="$BUILD/desktop" +BUILDER=patina-os-desktop-builder + +say() { printf '==> %s\n' "$*"; } + +[[ -d "$SRC/.git" ]] || { echo "error: no patina-desktop checkout at $SRC" >&2; exit 1; } +commit=$(git -C "$SRC" rev-parse HEAD) +worktree=${PATINA_DESKTOP_WORKTREE:-} +dirty=$(git -C "$SRC" status --porcelain) +if [[ -n "$worktree" ]]; then + [[ -z "$dirty" ]] || commit="$commit+dirty" +elif [[ -n "$dirty" ]]; then + say "patina-desktop has uncommitted changes; building its last commit, $commit" +fi + +say "the build environment" +docker build -q -f "$ROOT/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/desktop" >/dev/null + +say "building patina-desktop $commit" +rm -rf "$BUILD/src" +mkdir -p "$BUILD/src" "$BUILD/target" +if [[ -n "$worktree" ]]; then + # What git would commit: tracked files and new ones it doesn't ignore. + git -C "$SRC" ls-files -z --cached --others --exclude-standard | + tar -c -C "$SRC" --null -T - | tar -x -C "$BUILD/src" +else + git -C "$SRC" archive HEAD | tar -x -C "$BUILD/src" +fi +# Cargo's downloads are kept in a volume, and its target folder in build/, so +# rebuilds are incremental. As the user, so build/ stays theirs. +docker run --rm --user "$(id -u):$(id -g)" \ + -e CARGO_HOME=/cargo -e HOME=/tmp \ + -v patina-os-cargo:/cargo \ + -v "$BUILD/src:/src:ro" -v "$BUILD/target:/target" \ + -w /src "$BUILDER" \ + cargo build --release --locked --workspace --target-dir /target + +say "laying out build/desktop" +rm -rf "$STAGE" +binaries=(patina-bar patina-compositor patina-launcher patina-lock patina-menu + patina-volume patina-wallpaper patina-wifi) +install -d "$STAGE/usr/bin" +for b in "${binaries[@]}"; do + install -m 755 "$BUILD/target/release/$b" "$STAGE/usr/bin/" +done +install -d "$STAGE/usr/share/wayland-sessions" "$STAGE/etc/pam.d" "$STAGE/usr/lib/patina-os" +sed 's|@BINDIR@|/usr/bin|' "$BUILD/src/packaging/linux/patina.desktop" \ + > "$STAGE/usr/share/wayland-sessions/patina.desktop" +install -m 644 "$BUILD/src/packaging/linux/patina-lock.pam" "$STAGE/etc/pam.d/patina-lock" +echo "$commit" > "$STAGE/usr/lib/patina-os/desktop" diff --git a/desktop/builder.Containerfile b/linux/desktop/builder.Containerfile diff --git a/system/etc/NetworkManager/conf.d/10-globally-managed-devices.conf b/linux/system/etc/NetworkManager/conf.d/10-globally-managed-devices.conf diff --git a/system/etc/accountsservice/user-templates/administrator b/linux/system/etc/accountsservice/user-templates/administrator diff --git a/system/etc/accountsservice/user-templates/standard b/linux/system/etc/accountsservice/user-templates/standard diff --git a/linux/vm/README.md b/linux/vm/README.md @@ -0,0 +1,76 @@ +# The test VM + +Builds the Patina desktop and the image, installs it onto a disk file the way it would go onto a real disk, and boots it +in QEMU, then lets the VM upgrade from a local registry and roll back. Needs Docker, QEMU with KVM, +and OVMF (`apt install qemu-system-x86 ovmf`); no root, no podman on the host. Paths here are +relative to `linux/`. + +``` +vm/build.sh build the desktop and the image (its dev stage), push it to localhost:5000 +vm/disk.sh install the image onto out/disk.raw (and make out/data.qcow2, the SSH key) +vm/vm.sh start boot it in the background (serial console in out/serial.log) +vm/vm.sh wait wait until SSH answers +vm/vm.sh ssh [cmd] a root shell, or a command +vm/zfs-home.sh put /home on a ZFS pool on the second disk, as the installer will (once) +vm/vm.sh console boot it on this terminal instead (Ctrl-a x quits) +vm/vm.sh view its screen in a VNC viewer (localhost:5901) +vm/vm.sh screenshot its screen, saved to out/screen.png +vm/vm.sh log follow the serial console +vm/vm.sh stop power it off +vm/clean.sh stop it and delete out/ (--all: the registry and the image too) +``` + +GDM comes up on the screen; log in as **patina**, password **patina**, and the Patina session +starts (the dev image adds that user; the real image has none). + +Trying an update: + +``` +vm/build.sh # a new build, pushed +vm/vm.sh ssh bootc upgrade # the VM fetches and stages it +vm/vm.sh ssh systemctl reboot # boots into it +vm/vm.sh ssh cat /usr/lib/patina-os/build # which build is running +vm/vm.sh ssh bootc rollback # the previous one, at the next boot +``` + +## How it works + +- **The desktop** is built by `desktop/build.sh` from patina-desktop's last commit (beside this + checkout, or `PATINA_DESKTOP`), in an Ubuntu 26.04 container with the archive's Rust, so it + links what the image has. It lands in `build/desktop/` as it goes under `/`, with the session + file and the PAM service; the commit is in `/usr/lib/patina-os/desktop`. +- **The image** has two stages: `system`, the real one, and `dev`, which adds the test user and + trust in the registry. vm/build.sh builds `dev`. +- **The registry** (`vm/registry.sh`, started by the others) is Docker's `registry:2` on + localhost:5000, which the VM reaches as 10.0.2.2:5000 (QEMU's user network). The image + trusts it over plain HTTP (`vm/registries.conf`); that's for development builds only. +- **The install** runs the image itself, privileged, with the host's `/dev` for a loop device: + its own podman pulls it from the registry, and its own `bootc install to-disk` writes the + disk, with the composefs backend and systemd-boot, as ubuntu-bootc's CI does. The installed + system follows `10.0.2.2:5000/patina-os:dev`. +- **After the install**, the boot entry gets `root=UUID=...` (systemd 259 on 26.04 doesn't always + find the root by itself) and root's `authorized_keys` goes straight into the installed `/var`. +- **The VM** has 4 CPUs, 4 GB, UEFI, the system disk, an empty 10 GB second disk for the ZFS pool + (`/dev/disk/by-id/virtio-patina-data`, whichever `vdX` it gets), SSH on localhost:2222 with the key in `out/id_ed25519`, a virtio GPU shown over VNC + (Mesa draws in software), a USB tablet and keyboard, and QEMU's monitor on + `out/monitor.sock` (screenshots, and `sendkey` to type into it). + +## Found along the way + +- The base image's kernel (7.0.0-15) can't boot composefs: "Failed to execute /sbin/init: + Input/output error", fs-verity's regression in 7.0 (bootc issue 2174, fixed from 7.0.7). + The Containerfile installs the archive's current kernel (7.0.0-38), which boots. +- bootc's composefs backend can't install straight from a registry ("Invalid splitstream + content type"), only from podman's storage, hence the pull inside the install container. +- `--root-ssh-authorized-keys` leaves `/root/.ssh` empty with the composefs backend. +- The minimal base has no network configuration; the image adds NetworkManager. +- GDM 50 has no setting for the default session, and Ubuntu's AccountsService templates leave + a new user's session empty, which GDM takes as GNOME (not installed: "Failed to fill + session"). `system/etc/accountsservice/user-templates` makes it Patina. +- Ubuntu's NetworkManager leaves wired interfaces to netplan, which isn't here; an empty + `10-globally-managed-devices.conf` in `/etc` lets it manage them. +- The disks swap names between boots (the data disk was `vda` one time, `vdb` another), so the + pool is made on the data disk's serial (`/dev/disk/by-id/virtio-patina-data`); the system + disk is found by its UUID in the boot entry. +- Docker here has only the legacy builder (no BuildKit), so the Containerfile uses + `COPY --from` rather than `RUN --mount`. diff --git a/vm/build.sh b/linux/vm/build.sh diff --git a/vm/clean.sh b/linux/vm/clean.sh diff --git a/vm/common.sh b/linux/vm/common.sh diff --git a/vm/disk.sh b/linux/vm/disk.sh diff --git a/vm/registries.conf b/linux/vm/registries.conf diff --git a/vm/registry.sh b/linux/vm/registry.sh diff --git a/vm/vm.sh b/linux/vm/vm.sh diff --git a/vm/zfs-home.sh b/linux/vm/zfs-home.sh diff --git a/vm/README.md b/vm/README.md @@ -1,75 +0,0 @@ -# The test VM - -Builds the Patina desktop and the image, installs it onto a disk file the way it would go onto a real disk, and boots it -in QEMU, then lets the VM upgrade from a local registry and roll back. Needs Docker, QEMU with KVM, -and OVMF (`apt install qemu-system-x86 ovmf`); no root, no podman on the host. - -``` -vm/build.sh build the desktop and the image (its dev stage), push it to localhost:5000 -vm/disk.sh install the image onto out/disk.raw (and make out/data.qcow2, the SSH key) -vm/vm.sh start boot it in the background (serial console in out/serial.log) -vm/vm.sh wait wait until SSH answers -vm/vm.sh ssh [cmd] a root shell, or a command -vm/zfs-home.sh put /home on a ZFS pool on the second disk, as the installer will (once) -vm/vm.sh console boot it on this terminal instead (Ctrl-a x quits) -vm/vm.sh view its screen in a VNC viewer (localhost:5901) -vm/vm.sh screenshot its screen, saved to out/screen.png -vm/vm.sh log follow the serial console -vm/vm.sh stop power it off -vm/clean.sh stop it and delete out/ (--all: the registry and the image too) -``` - -GDM comes up on the screen; log in as **patina**, password **patina**, and the Patina session -starts (the dev image adds that user; the real image has none). - -Trying an update: - -``` -vm/build.sh # a new build, pushed -vm/vm.sh ssh bootc upgrade # the VM fetches and stages it -vm/vm.sh ssh systemctl reboot # boots into it -vm/vm.sh ssh cat /usr/lib/patina-os/build # which build is running -vm/vm.sh ssh bootc rollback # the previous one, at the next boot -``` - -## How it works - -- **The desktop** is built by `desktop/build.sh` from patina-desktop's last commit (beside this - checkout, or `PATINA_DESKTOP`), in an Ubuntu 26.04 container with the archive's Rust, so it - links what the image has. It lands in `build/desktop/` as it goes under `/`, with the session - file and the PAM service; the commit is in `/usr/lib/patina-os/desktop`. -- **The image** has two stages: `system`, the real one, and `dev`, which adds the test user and - trust in the registry. vm/build.sh builds `dev`. -- **The registry** (`vm/registry.sh`, started by the others) is Docker's `registry:2` on - localhost:5000, which the VM reaches as 10.0.2.2:5000 (QEMU's user network). The image - trusts it over plain HTTP (`vm/registries.conf`); that's for development builds only. -- **The install** runs the image itself, privileged, with the host's `/dev` for a loop device: - its own podman pulls it from the registry, and its own `bootc install to-disk` writes the - disk, with the composefs backend and systemd-boot, as ubuntu-bootc's CI does. The installed - system follows `10.0.2.2:5000/patina-os:dev`. -- **After the install**, the boot entry gets `root=UUID=...` (systemd 259 on 26.04 doesn't always - find the root by itself) and root's `authorized_keys` goes straight into the installed `/var`. -- **The VM** has 4 CPUs, 4 GB, UEFI, the system disk, an empty 10 GB second disk for the ZFS pool - (`/dev/disk/by-id/virtio-patina-data`, whichever `vdX` it gets), SSH on localhost:2222 with the key in `out/id_ed25519`, a virtio GPU shown over VNC - (Mesa draws in software), a USB tablet and keyboard, and QEMU's monitor on - `out/monitor.sock` (screenshots, and `sendkey` to type into it). - -## Found along the way - -- The base image's kernel (7.0.0-15) can't boot composefs: "Failed to execute /sbin/init: - Input/output error", fs-verity's regression in 7.0 (bootc issue 2174, fixed from 7.0.7). - The Containerfile installs the archive's current kernel (7.0.0-38), which boots. -- bootc's composefs backend can't install straight from a registry ("Invalid splitstream - content type"), only from podman's storage, hence the pull inside the install container. -- `--root-ssh-authorized-keys` leaves `/root/.ssh` empty with the composefs backend. -- The minimal base has no network configuration; the image adds NetworkManager. -- GDM 50 has no setting for the default session, and Ubuntu's AccountsService templates leave - a new user's session empty, which GDM takes as GNOME (not installed: "Failed to fill - session"). `system/etc/accountsservice/user-templates` makes it Patina. -- Ubuntu's NetworkManager leaves wired interfaces to netplan, which isn't here; an empty - `10-globally-managed-devices.conf` in `/etc` lets it manage them. -- The disks swap names between boots (the data disk was `vda` one time, `vdb` another), so the - pool is made on the data disk's serial (`/dev/disk/by-id/virtio-patina-data`); the system - disk is found by its UUID in the boot entry. -- Docker here has only the legacy builder (no BuildKit), so the Containerfile uses - `COPY --from` rather than `RUN --mount`.