notes.md (10569B)
1 # Notes 2 3 Research for Patina OS, and what's still open. Dated, since this moves quickly. 4 5 ## Ubuntu with apt, no snaps, ZFS root (2026-10-22) 6 7 - ADR-0007: Patina OS is Ubuntu 26.04 with the Patina desktop, no snaps, root and homes on ZFS, a snapshot before every apt run, ZFSBootMenu to boot one. Chosen over the image-based designs for hardware (the laptop's lid, battery and suspend; the workstation's CUDA) and software compatibility; FreeBSD was the simplest system but trails on laptops. 8 - To do: the installer (ADR-0008: the system built in CI and received as a ZFS stream onto the whole disk, from a USB stick that is Patina OS itself), the apt hook and its pruning, the Patina desktop as `.deb`s. 9 - Check: whether 26.04's own installer offers a ZFS root, and how ZFSBootMenu is best installed on Ubuntu (its release EFI image, or built). 10 - The notes below on bootc, ADR-0006's boot environments and FreeBSD are kept as the record. 11 12 ## No bootc (2026-10-22) 13 14 - ADR-0006 rules bootc out: both bases boot ZFS boot environments and update by ZFS streams, so one update model and one updater serve FreeBSD and Ubuntu. docs/comparison.md has the comparison; what's left between them is mostly laptops. 15 - The bootc notes below (bases, the kernel, the installer's bootc steps) are kept as the record of what was tried. 16 - On Ubuntu: the Containerfile starts from Canonical's `ubuntu` image, adds a kernel and `zfs-dracut` or `zfs-initramfs` (both in 26.04's main, OpenZFS 2.4.1), and its filesystem is written into `patina/ROOT/<build>`; ZFSBootMenu on the ESP boots it. Open: whether ZFSBootMenu can boot a build once and fall back (FreeBSD has `bectl activate -t`). 17 - Open, for both: how a new build keeps the machine's `/etc` (users, hostname, networks). 18 - Check: FreeBSD's OCI images, which would let FreeBSD's system be built from a Containerfile too. 19 20 ## Ubuntu bootc bases (checked 2026-10-15) 21 22 - **bootcrew/ubuntu-bootc** (the Universal Blue people's experiment) is archived since March 23 2026; its Ubuntu work moved to **bootcrew/mono**, a collection of bootc images for several 24 OSes (Ubuntu, Debian, openSUSE, SteamOS). It uses the composefs-native backend. 25 - A separate **ubuntu-bootc** GitHub organisation has Ubuntu 26.04 LTS bases: a minimal one (no 26 desktop, no flatpak, no ZFS), plus desktop and server variants. Updated May 2026. 27 - **Canonical** doesn't support bootc; its own image-based system is Ubuntu Core (snaps). A talk 28 at Ubuntu Summit 26.04 argued for officially packaged bootc components and base images. 29 - **Confirmed 2026-10-16**: the minimal base's kernel (7.0.0-15) can't boot composefs (fs-verity 30 regression in 7.0, bootc issue 2174, fixed from 7.0.7). The archive's 7.0.0-38 (nifl's and 31 huginn's) boots; the Containerfile installs it. linux/vm/README.md has the rest of what the VM found. 32 33 ## Staying with Ubuntu (2026-10-16) 34 35 - The image already has the Rust tools: uutils coreutils 0.8.0 (`ls` is 36 `/usr/lib/cargo/bin/coreutils/ls`) and sudo-rs 0.2.13, Ubuntu's defaults since 25.10. 37 - Considered: CentOS Stream 10's official bootc images, which are the best-tested bootc path. Its 38 kernel stays on 6.12 for years, so OpenZFS's ready-made EL kernel modules would keep ZFS 39 reliable. Its thinner package set matters little when apps bring their own bases 40 (ADR-0002/0003). Fedora is worst for ZFS, since its kernels outrun OpenZFS. 41 - Kept Ubuntu because it's set up and the VM loop works on it. Its ZFS module comes built for 42 each kernel, and uutils is already in. The cost is the newness of Ubuntu's bootc support (see 43 linux/vm/README.md). If that keeps biting, a CentOS Stream 10 Containerfile goes through the same 44 VM loop with small changes to the install step (the ostree backend instead of composefs). 45 46 ## ZFS 47 48 - **Done 2026-10-16**, in the VM: /home on a ZFS pool, imported and mounted at boot, through 49 upgrades and rollbacks. The module comes with Ubuntu's kernel package 50 (`ubuntu/dkms/zfs/zfs.ko.zst`, built for it); the image adds zfsutils-linux and zfs-zed and 51 enables zfs-import-cache, zfs-mount and zed. 52 - **The layout**: a pool `patina` (ashift=12, zstd, atime off, xattr=sa, POSIX ACLs, not 53 mounted itself); `patina/home` at `/var/home` (/home links there on bootc); one dataset per 54 user, `patina/home/<user>`, so each home snapshots and sends alone. 55 - **Machine, not image**: the host ID (`/etc/hostid`; zfsutils makes one as it installs, so the 56 image deletes it) and the pool cache (`/etc/zfs/zpool.cache`) are in `/etc`, which bootc 57 keeps per machine across updates; the pool is outside the image. linux/vm/zfs-home.sh does the 58 per-machine part, standing in for the installer. 59 - **Mounting order**: zfs-mount runs before local-fs.target, so the homes are there before 60 tmpfiles, GDM or any login. 61 - Open: a dataset for each *new* user. useradd makes a plain folder inside `patina/home`; 62 whatever creates users (the installer, a settings app) should `zfs create` first. 63 - Open: native encryption, unlocked with the login password or at boot (an initramfs prompt, or 64 a unit before GDM). 65 - Open: whether more of `/var` (containers, flatpaks, logs) goes on the pool. 66 67 ## What the installer will do 68 69 The Patina installer (our own; no existing one fits) is where a machine's own setup lives, so 70 nothing in the image may assume it. Collected as they come up: 71 72 - Partition: EFI, the system partition for bootc, and the rest for the ZFS pool (or a second 73 disk). `bootc install to-disk` takes a whole disk, so the installer partitions itself and 74 uses `bootc install to-filesystem` (linux/vm/disk.sh uses to-disk, with the pool on a second disk). 75 - `bootc install` with `--target-imgref` set to where this machine updates from. 76 - ZFS: `zgenhostid`, `zpool create` on a stable name (`/dev/disk/by-id/...`), the cache file, 77 `patina/home` and the first user's dataset, as linux/vm/zfs-home.sh does. 78 - The first user: the real image has none (the dev stage's `patina` is for the VM). 79 80 ## Apps in the home folder 81 82 The aim isn't to copy what's there but to fix what's missing. On Linux the user's packages and 83 the system's are blurred: a user's app often needs something installed system-wide first. Here 84 the system is locked, and apps live in the home folder, on the ZFS pool, snapshotted with the 85 rest of the user's data, never needing the system changed. 86 87 **The native way** (proposed): an app is a folder, `~/Apps/Name.app`, with an 88 `app.toml` saying how to run it, run on an OCI base image named by digest (ADR-0002), in a thin 89 jail (ADR-0003). In short: thin jails for desktop apps, with OCI images as the base. 90 91 - **What's new**: the parts exist (Flatpak's shared runtimes, which can even come from OCI 92 registries; toolbox's containers; FreeBSD's thin jails), but not the booted system itself 93 being the app runtime, versioned by digest, with plain folders as apps. No separate runtime 94 world to keep up, as Flatpak has. 95 - **Why folders failed on Linux before** (GNUstep, ROX AppDirs): no guaranteed base. macOS's 96 .app works because Apple guarantees its base; ours is guaranteed by the image digest. 97 - **What AppImage is underneath**: an AppDir (a folder) packed into SquashFS with an ELF runtime 98 in front that mounts it with FUSE, so it needs libfuse on the system. The folder without the 99 packing is simpler and needs nothing. 100 101 Other ways that still work beside it, all without root: 102 103 - **Flatpak, per user** (`flatpak --user`, in `~/.local/share/flatpak`); the launcher reads the 104 .desktop files it exports (in `~/.local/share/flatpak/exports/share/applications`, on 105 XDG_DATA_DIRS; check). 106 - **Distrobox / toolbox**: a mutable distro in a container, with apt, for development tools. 107 - **Per-user language tools**: cargo, rustup, npm in `~/.cargo`, `~/.local`. 108 109 Open, roughly in order: 110 111 1. The `app.toml` format: fields, and binaries for more than one platform 112 (`bin/linux-x86_64/`, `bin/freebsd-amd64/`). 113 2. Opening files and links: something like Launch Services, reading `app.toml`'s file types and 114 URL schemes. Where it lives: the launcher, or a small service beside it. 115 3. Commands on PATH: linked into `~/.local/bin`, or added by the session. 116 4. Trust: anything to say the first time a downloaded app runs. 117 5. The runner's list of what reaches an app, and fetching and removing old bases. 118 6. How an app is built: a tool that takes a base, a binary and an `app.toml` and checks the 119 binary needs nothing the base and folder don't have (`ldd` against the base). 120 121 ## Reproducible builds 122 123 - Pin the base image by digest, not tag. 124 - apt fetches whatever is newest at build time, so two builds of one Containerfile can differ. 125 Ubuntu's snapshot service (snapshot.ubuntu.com) serves the archive as it was at a given time; 126 building against a fixed snapshot makes the packages repeatable. Check how it's used from a 127 Containerfile. 128 - Build the Patina desktop from a tagged commit, with `cargo build --locked`. 129 130 ## The image 131 132 - **Done 2026-10-16**: the Containerfile adds the Patina desktop (built by linux/desktop/build.sh into 133 `/usr/bin`, with its session file and PAM service), GDM, NetworkManager, PipeWire and 134 WirePlumber, Mesa, fonts and foot. In the VM, GDM logs in to the Patina session, and the 135 launcher starts apps. linux/vm/README.md has what it took. 136 - Open: GDM brings much of GNOME's plumbing; a Patina login screen (as patina-lock replaced 137 swaylock) could replace it later. 138 - Open: where images are pushed (a registry: ghcr.io, or our own), and signing them. 139 - Open: how a machine is installed: `bootc install to-disk` from the image, or an ISO 140 (bootc-image-builder). 141 142 ## Questions for Patina itself 143 144 - Binaries in `/usr/bin` rather than `~/.local/bin`: works (checked in the VM: the compositor 145 starts the wallpaper, bar and launcher from there). 146 - Config defaults (`~/.config/patina-*`) stay per user; system-wide defaults could go in 147 `/etc/xdg` or `/usr/share` if we want the image to choose them. 148 149 ## Sources 150 151 - [bootcrew on GitHub](https://github.com/bootcrew), [bootcrew/mono](https://deepwiki.com/bootcrew/mono) 152 - [ubuntu-bootc organisation](https://github.com/ubuntu-bootc) 153 - [jmarrero/ubuntu-bootc guide](https://github.com/jmarrero/ubuntu-bootc/blob/main/GUIDE.md) 154 - [The Register, June 2026: Red Hat and bootc at the Ubuntu Summit](https://www.theregister.com/software/2026/06/15/red-hat-gives-ubuntu-a-bootc-up-the-backside-at-canonical-shindig/5255608) 155 - [Ubuntu Summit 26.04 bootc talk](https://discourse.ubuntu.com/t/bootc-use-your-container-knowledge-and-infrastructure-to-build-and-deploy-your-ubuntu-hosts/79498)