Skip to content

1bit OS: an installer - live boot onto one internal disk, same signed layout, with refusals - #539

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/os-install
Oct 23, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/os-install

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

1bit OS: an installer — live boot onto one internal disk, same signed layout, with refusals

Why

1bit-selftest proved the live stick, and there was no way to put the appliance on a machine (#515 says
so plainly: the image carries no installer at all). The Gantt's install row needs a known sequence rather
than an experiment, so this adds the installer and proves the whole thing in QEMU — live boot, install,
reboot from the installed disk with no stick attached — plus every refusal, so the owner's real install
is a list of commands that has already run once.

What changes

File Change
os/mini/install.sh (new) shipped as /bin/1bit-install. Installs onto ONE internal disk named explicitly: GPT with a 512 MB EFI system partition — the signed chain this boot came from (shim, signed grub, vmlinuz, initramfs, grub.cfg, copied byte for byte, so the machine's MOK enrolment is unchanged) — and a 1BIT-DATA ext4 partition filling the disk, carrying the stick's models/, lemonade/ (backends, config, cache, key), the NPU kernel sets and ssh/, then /data/.installed. Refuses, before writing anything: no --yes; a partition instead of a whole disk; a removable device; the disk this live boot runs from; a disk with anything mounted; a missing GPT tool. Prints the disk's model/size/partition table and waits 10 s.
os/mini/init.sh an installed disk carries /data/.installed and the same init then boots the appliance from it: INSTALLED banner and /etc/1bit/installed instead of LIVE / /etc/1bit/live, and the stick's menu is skipped (there is nothing to choose). Loads nvme/ahci (the install target is always an internal NVMe) and the vfat codepages the installer's ESP mount needs; creates /etc/1bit itself; say() defined before its first use.
os/mini/mkimage.sh ships install.sh as /bin/1bit-install, plus sfdisk (busybox fdisk is MBR-only) and the real e2fsprogs mke2fs with /etc/mke2fs.conf — the installer lays the disk out with the same sfdisk recipe the build uses for the stick. Ships nvme, ahci, nls_cp437, nls_ascii.
os/mini/selftest.sh reports the mode it is actually running in (/etc/1bit/installed vs /etc/1bit/live) instead of always printing LIVE.
os/mini/vmtest.sh an install pass: a sparse qcow2 virtual NVMe attached to the live VM, the refusal matrix, 1bit-install, poweroff, then a second boot from the installed disk alone with clean NVRAM and no USB, asserting the INSTALLED banner, /etc/1bit/installed, /data on the disk, the GGUF listed, 401 without the key, a chat, and 1bit-selftest reporting INSTALLED.
os/README.md "Install it on the machine's own disk": the owner's commands, the Secure Boot/MOK note, how to get back to the live stick, and what the VM proves vs what only the machine can.

Apache-2.0 notices on the new file; python3 tools/copyright.py --check → rc=0.

Refusal matrix — what the VM asserts (vmtest-install6, 23 Oct 09:53, one run)

Each invocation must print REFUSED and exit 2, and write nothing:

Invocation Result
1bit-install /dev/nvme0n1 (no --yes) REFUSED: refusing to write /dev/nvme0n1 without --yes (this destroys its contents)
1bit-install --help prints its own usage, rc=0
1bit-install /dev/sda1 --yes (a partition) REFUSED: /dev/sda1 is a partition; name the whole disk (e.g. /dev/nvme0n1, not /dev/nvme0n1p1)
1bit-install /dev/sda --yes (the live stick) REFUSED: /dev/sda carries this live boot's 1BIT-DATA partition; install onto a different disk
1bit-install /dev/does-not-exist --yes REFUSED: /dev/does-not-exist is not a block device
1bit-install /dev/nvme0n1 --yes with its partition mounted REFUSED: /dev/nvme0n1 is in use: /dev/nvme0n1p2 is mounted

A removable device is refused in the same way, but the VM has no removable target to point at (the
only removable disk in QEMU is the stick, which the live-disk rule already catches), so that refusal is
code-and-review only, and is called out here rather than claimed as tested.

Verification — labelled "90 W cap, PCM pad (23 Oct)"

os/mini/vmtest.sh on strixhalo under gpu-hold -l "pi osinstall" -t 14, one full run:

Check Result
live boot: SSH, web app, KaTeX font, 401 without key, model listed, chat PASS — Paris. (llamacpp:vulkan)
the refusal matrix above PASS (6/6 asserted)
1bit-install /dev/nvme0n1 --yes PASS — layout : GPT - partition 1 = 512 MB EFI system partition (1BIT-OS), the rest = ext4 (1BIT-DATA), partition 1: /dev/nvme0n1p1 512 MB
second boot, installed disk only, no USB, clean NVRAM PASS — the installed disk booted on its own (no USB attached)
INSTALLED banner on the console PASS — MODE: INSTALLED - 1bit OS runs from this machine's disk; /data is /dev/nvme0n1p2.
/etc/1bit/installed instead of /etc/1bit/live PASS — /etc/1bit/installed present, no live marker
/data comes from the installed disk PASS — /dev/nvme0n1p2 /data ext4
Lemonade with its key, and without one PASS — 401 without the key, lists the GGUF carried over to the disk: Qwen3-0.6B-Q4_K_M, chat … answered: Paris.
1bit-selftest on the installed disk PASS — reports the INSTALLED mode
overall VMTEST PASS

What the VM proves, and what only the real machine can

  • VM: every refusal, the layout written, that the installed disk boots on its own (no stick, clean
    NVRAM), the INSTALLED mode and marker, /data coming from the disk, Lemonade serving with its key and
    a chat answered by llamacpp:vulkan, and the self-test reporting INSTALLED.
  • Only the machine: that this firmware offers the installed disk without help, the NPU
    (/dev/accel/accel0, the placement line, RESULT-NPU: PASS), the GPU, and real Secure Boot against
    the enrolled MOK.

Six bugs the VM found (all invisible on a stick that never needs a second disk)

  1. The image shipped no nvme/ahci module at all, so the live system could not see the disk an
    install target always is (install: no NVMe device in the VM).
  2. Partition names were decided by asking whether the node already existed — right after sfdisk it does
    not, so the installer wrote /dev/nvme0n11 on a disk whose name ends in a digit.
  3. mke2fs was busybox's: ext2-only, no -t. Shipping the real e2fsprogs binary was not enough on
    its own — this is a busybox shell with CONFIG_FEATURE_SH_STANDALONE, so an applet name is answered by
    the shell before PATH, and /bin/mke2fs was still skipped (type mke2fs → "mke2fs is mke2fs" while
    /bin/mke2fs printed the e2fsprogs usage). The installer now names the tools it needs absolutely.
  4. No vfat mount could succeed: codepage cp437 not found, then IO charset ascii not found — the image
    shipped neither nls_cp437 nor nls_ascii (this kernel's CONFIG_NLS_DEFAULT is ascii).
  5. findfs LABEL=1BIT-DATA answered with the target disk after an install, whose own partition
    carries that label: the installer refused the correct target as "the disk this live boot runs from",
    which would have blocked every reinstall, and the ESP copy source had the same ambiguity. Both the live
    disk and the live ESP now come from what /data is actually mounted from (/proc/mounts).
  6. 1bit-selftest printed mode : LIVE unconditionally, and /etc/1bit did not exist on any boot:
    mkimage.sh creates it (and writes libhsa) after it packs the initramfs, so the marker was silently
    lost. init now creates the directory itself and the self-test reads the markers. (That mkimage ordering
    is pre-existing and left alone here — it also means /etc/1bit/libhsa and /opt/1bit-llama have never
    reached a booted image; it wants its own issue.)

Owner's sequence (nothing in this PR writes a real disk — the VM did)

# 1. write the stick (image: out/1bit-os-v2026.43-pin27abcc24.img.zst), boot it, check it
1bit-release-check                       # or 1bit-selftest: must report mode LIVE and RESULT: PASS
# 2. install onto the internal disk — ONE disk, named explicitly, this destroys it
1bit-install /dev/nvme0n1 --yes          # prints the disk and waits 10 s before writing
# 3. power off, remove the stick, boot the machine from the disk
1bit-release-check                       # now reports mode INSTALLED

Secure Boot needs no change: the disk carries the same MOK-signed kernel and initramfs the stick booted,
and the machine's enrolment (mokutil --list-enrolled) is untouched. Booting the stick again gets you
back to a live system and does not touch the installed disk.

Co-Authored-By: Claude Fable 5.1 [email protected]

1bit OS boots live from a stick and there was no way to put it on a machine
(the #515 image says so plainly: no installer at all). This adds the installer
and proves the whole sequence in QEMU, so the owner's install is a known run of
commands rather than an experiment.

- os/mini/install.sh (new), shipped as /bin/1bit-install: installs onto ONE
  internal disk named explicitly. Before it writes anything it refuses: no
  --yes, a partition instead of a whole disk, a removable device, the disk this
  live boot runs from (the 1BIT-DATA partition's parent, via sysfs), a disk
  with anything mounted, a missing GPT tool. Then it prints the disk's
  model/size/partition table and waits 10 s. Past that: GPT with a 512 MB ESP
  (the live ESP copied byte for byte - the same shim, signed grub, vmlinuz,
  initramfs, grub.cfg, so the MOK enrolment on the machine is unchanged) and a
  1BIT-DATA ext4 partition filling the disk carrying the stick's models,
  Lemonade backends/config/cache, the NPU kernel sets and the SSH keys, plus
  /data/.installed.
- os/mini/init.sh: /data/.installed selects the installed mode - INSTALLED
  banner instead of LIVE, /etc/1bit/installed instead of /etc/1bit/live, and no
  stick menu (there is nothing to choose). Same initramfs and signed chain
  either way. Also define say() before its first use: it sat below the NPU
  kernel-link line, so that line died as "say: not found" on the console.
- os/mini/mkimage.sh: ship install.sh and sfdisk (busybox fdisk is MBR-only;
  the installer lays the target out with the same sfdisk script the build uses
  for the stick, so a stick and an installed disk are one layout), and ship and
  load nvme + ahci. Without them the live system had no NVMe driver at all and
  could not see the disk an install target always is.
- os/mini/vmtest.sh: an install pass - a sparse qcow2 virtual NVMe attached to
  the live VM, the refusal matrix, the install, poweroff, then a second boot
  from the installed disk alone with clean NVRAM and no USB attached, asserting
  the INSTALLED banner, /etc/1bit/installed, /data on the disk, Lemonade with
  its key answering a chat, and 1bit-selftest reporting INSTALLED.
- os/README.md: the owner's sequence as commands, the Secure Boot/MOK note, how
  to get back to the live stick, and what the VM proves vs what only the real
  machine can.

Three bugs the VM found, all invisible to a stick that never needs a second disk:
the image shipped no nvme/ahci module; new_part() decided a partition's name by
asking whether the node already existed (right after sfdisk it does not), so it
wrote /dev/nvme0n11 on a disk whose name ends in a digit; and "mke2fs" was not
mke2fs. The image shipped only busybox's applet, which is ext2-only and rejects
-t, so the data partition was never created ("1bit-install: mke2fs failed").
Shipping the real e2fsprogs binary was not enough on its own: this is a busybox
shell with CONFIG_FEATURE_SH_STANDALONE, so a name it knows as an applet is
answered by the shell before PATH is consulted, and the real /bin/mke2fs was
still skipped (measured in the guest: `type mke2fs` -> "mke2fs is mke2fs", while
/bin/mke2fs printed the e2fsprogs usage). The installer now names the tools it
needs by absolute path - /bin/sfdisk and /bin/mke2fs - and mkimage.sh ships the
real mke2fs with its libraries and /etc/mke2fs.conf. install.sh also reads the
partition table back with sfdisk, not busybox fdisk, which cannot read a GPT.

Two more the same runs found. Mounting the ESP failed with EINVAL and the kernel
said why: "FAT-fs (nvme0n1p1): codepage cp437 not found" - the image ships
nls_cp437 but init loaded vfat and not the codepage, so no vfat mount could
succeed. And the live disk was found with `findfs LABEL=1BIT-DATA`, which after
an install answers with the *installed* disk, whose own partition carries that
label: the installer then refused the target as "the disk this live boot runs
from" (blocking every reinstall) and would have copied the wrong ESP. Both the
live disk and the live ESP are now taken from what /data is actually mounted
from, in /proc/mounts.

Booting the installed disk and asking it (not guessing) found the last two: 1bit-selftest
printed "mode: LIVE" unconditionally, so on an installed machine it contradicted the
banner and the installer's own "selftest reports INSTALLED" check could never pass - it
now reads /etc/1bit/installed vs /etc/1bit/live. And /etc/1bit did not exist at all on
any boot, because mkimage.sh creates it after it packs the initramfs; init makes the
directory itself now, so the marker is not silently lost. That ordering in mkimage.sh
(/etc/1bit/libhsa and /opt/1bit-llama are also added after the pack) is pre-existing and
left alone here.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

515 - Partially compliant

Compliant requirements:

  • Live mode indicator is implemented in init.sh
  • 1bit-selftest script is created and integrated
  • Selftest appends results to /data/selftest.log
  • Selftest exits with non-zero code on failure
  • /etc/1bit/live is dropped to indicate live mode
  • Bugs in selftest are fixed (stray /d line and model-id parse)
  • Optional SSH key support is implemented

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Partition Naming

The new_part() function in install.sh uses a logic to determine partition naming that may not correctly handle all device types. Specifically, for devices like nvme0n1, the function appends p before the partition number, but for devices like sda, it does not. This could lead to incorrect partition device names being generated, especially on systems where the naming convention is inconsistent.

new_part() {   # <disk> <1|2> -> the kernel's device name for that partition
    # by name, not by asking the kernel whether the node exists yet: right after sfdisk it does not, and
    # "does /dev/nvme0n1p1 exist?" answered "no" for a disk whose partitions were simply not published
    # yet, which is how this wrote /dev/nvme0n11 (measured in the VM).
    case "${1##*/}" in
        *[0-9]) echo "$1p$2" ;;   # nvme0n1, mmcblk0: a digit glued to a number needs the p
        *)      echo "$1$2" ;;    # sda, vda, hda
    esac
}
Race Condition in Partition Detection

The logic in init.sh that detects whether the system is running from an installed disk or a live boot relies on checking /proc/mounts and /data/.installed. However, there's a potential race condition where the check for /data/.installed might not be reliable if the filesystem is not fully mounted or if there are delays in the filesystem being accessible. This could lead to incorrect mode detection.

INSTALLED=0
grep -q " /data " /proc/mounts && [ -e /data/.installed ] && INSTALLED=1
# this boot's state lives here, and init makes it rather than trusting the image to carry it: mkimage.sh
# creates /etc/1bit after it packs the initramfs, so the directory was never in any image and the marker
# below was silently lost (the installed boot reported INSTALLED on screen and no marker in /etc/1bit)
mkdir -p /etc/1bit 2>/dev/null
MODE=live
Mode Detection Logic

The mode detection logic in selftest.sh relies on checking for the existence of /etc/1bit/installed or /etc/1bit/live. If these files are missing or corrupted, the script will default to UNKNOWN mode. This could lead to incorrect reporting if the system state is not properly tracked or if the files are accidentally removed or modified.

if [ -e /etc/1bit/installed ]; then
    MODE=INSTALLED
    MODEWHAT="runs from this machine's disk, /data is $(findfs LABEL=1BIT-DATA 2>/dev/null)"
elif [ -e /etc/1bit/live ]; then
    MODE=LIVE
    MODEWHAT="RAM only, nothing installed, internal disks never mounted"
else
    MODE=UNKNOWN
    MODEWHAT="no marker in /etc/1bit, so this boot cannot say where it came from"
fi

@bong-water-water-bong
bong-water-water-bong merged commit c95d0f4 into main Oct 23, 2026
8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/os-install branch October 23, 2026 13:00
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The deliverable image was built from this branch before the merge, signed with the machine's enrolled MOK,
and verified the same way the VM ran it:

Artifact sha256
os-l/1bit-os.img (USB image, 2393899008 B) f721ed95764c8936eb0dc83545206a264ae3d73b9bf2bc3b44c77efef5eeff7e
os-l/1bit-os.efi (UKI) 3ed81562066c35f4da20e625c433643cb281ee74f4eddc6b4609e8c10999028b

sbverify --cert /var/lib/shim-signed/mok/MOK-Kernel.pem os-l/1bit-os.efi -> Signature verification OK,
and the ESP's initramfs (extracted from the image, not assumed) carries /bin/1bit-install,
/bin/sfdisk, the real e2fsprogs /bin/mke2fs with /etc/mke2fs.conf, /bin/1bit-release-check, and
nls_ascii + nls_cp437 — i.e. everything this PR's installer needs is in the shipped image.

Owner's step, when the stick is at /dev/sdX:

sudo dd if=1bit-os.img of=/dev/sdX bs=4M conv=fsync     # then grow 1BIT-DATA to fill the stick

The .zst of the same image is still queued behind other agents' GPU holds
(out/1bit-os-v2026.43-install-d7004bf.img.zst); the raw image above is the artifact of record until it
lands.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The compressed artifact landed, so the loose end above is closed:

Artifact Size sha256
out/1bit-os-v2026.43-install-d7004bf.img.zst 376184918 B e0ed1ff77c941cdc794119a93fbd436207b0525920cd202900dee14c4684a909

zstd -t reports the full 2393899008 bytes, matching the 1bit-os.img sha256 in the table above.

bong-water-water-bong added a commit that referenced this pull request Oct 26, 2026
`os/mini` is the BusyBox image that ships today: everything in RAM, a reflash to update. `os/v2` is the
same appliance - Lemonade Server by AMD on the 1bit engine, our kernel, Secure Boot through the enrolled
MOK - on a minimal Ubuntu 26.04 root filesystem with systemd, where every piece we ship is a `.deb` from
our own signed repository and `apt update && apt upgrade` is the update path. `os/mini` keeps shipping
until v2 passes the same checks on hardware.

Seven packages, built from what a release already produces (no binary is rebuilt): `1bit-engine`,
`1bit-lemonade`, `1bit-kernel-image-<kver>`, `1bit-kernel-modules-<kver>`, `1bit-ryzenadj`,
`1bit-appliance` and `1bit-archive-keyring`. The kernel version is in the package name, so an upgrade keeps
the previous kernel installed - that is the rollback. `mkdebs.sh` refuses a stage whose EC module is
unsigned or built for another kernel, and a kernel image with no signature; it localises the engine's
libraries with `scripts/pack-elf.sh` (the same `pack_localize` a release tarball goes through), because a
package that carries the build machine's RUNPATH is a package that does not load (#549).

The live medium is the root filesystem as a squashfs with a tmpfs overlay: one initramfs-tools script
(`scripts/init-bottom/0-1bit-live`) builds the overlay and hands `rootmnt` back through `/conf/param.conf`,
so userspace has nothing custom at boot and a live boot cannot write the medium. `install.sh` is
`1bit-install`, with the same refusal matrix as #539 and three partitions (ESP, `1BIT-ROOT`, `1BIT-DATA`)
instead of a RAM image; it unpacks the squashfs, writes `fstab` by label, one grub entry per installed
kernel, and leaves `/etc/1bit/live` off the installed disk so `1bit-first-boot.service` writes
`/etc/1bit/installed` after making that machine's own SSH keys.

Two VM tests, both judged from what the guest writes to its own disk rather than from QEMU:
`vmtest-v2.sh` (the appliance, booted through OVMF so the secureboot row answers instead of failing for a
QEMU choice) and `vmtest-install-v2.sh` (builds the medium with a test-only unit inside it, boots it with a
target disk and a USB stick attached, runs the refusals, installs, then boots the installed disk alone).

Bugs this found in the v2 path, all fixed here: the engine package could not load its own libraries
(a dev-built stage carried the build tree's RUNPATH and never shipped libhrx/libloomc/libomp); `1bit`
needed `libgomp1`/`libpcre2-8-0`, which minbase has not; lemond exits at once without `HOME` in a systemd
unit; `ssh.service` enabled while `ssh.socket` was masked starts nothing at all on Ubuntu 26.04 (the socket
is what listens, and it carries RequiredBy=ssh.service) - so the socket is what the package enables; minbase
has no `sfdisk` (Ubuntu's lives in `fdisk`); `root=` in the live entry has to be the squashfs partition, or
`data.mount` fights the initramfs for the data partition; and `1bit-appliance` never shipped the aggregate
`/usr/share/licenses/1bit-os` that release-check reads.

Known gap, named in `os/v2/README.md` rather than papered over: the ROCm userspace (HIP, rocBLAS,
hipBLASLt, the HSA runtime) is the machine's, not the engine package's, and the engine's `Depends` do not
name Ubuntu's packages for it yet - gfx1201 support against the distro's ROCm is a hardware question a VM
cannot settle. `vmtest-v2` therefore asserts the package's own libraries resolve and lets only that set be
missing, which is exactly the check that caught the first bug above.

Evidence: `VMTEST-V2 PASS` (seven packages installed, banner, /data, 1bit --help, our kernel's vmlinuz and
initrd in /boot, sshd on 22, apt from the repository, Lemonade 401 + GGUF + chat, release-check with no
FAIL row but `sealed`, which needs a stage that carries the sealed NPU sets) and `VMTEST-V2-INSTALL PASS`
(six refusals, install, installed disk boots alone: INSTALLED mode, first-boot marker and own SSH keys,
/data on its own partition, Lemonade 401 + GGUF + chat, selftest INSTALLED). Transcripts:
`~/wt/osapt-proto/v2-final.log` and `~/wt/osapt-proto/live-install.log`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant