interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / RECOVERY_MEDIA_MACHINE1.md

248 lines · 13058 bytes Raw Blame History Rendered
1# Bootable recovery media for Machine 1
2
3> **Operator doing TRUST-1:** follow
4> [TRUST-1-OPERATOR-STEPS.md](TRUST-1-OPERATOR-STEPS.md) (Step 4 rebuilds the
5> stick, Step 6 boots it and proves the unlock). This page is the technical
6> record of what the stick contains and how it was first proven.
7>
8> **Two places, two sets of tools.** Commands in "Build and verify" run in a
9> normal Ubuntu terminal on the Spark. Commands after "Boot the USB once" run
10> at the recovery prompt on the stick, which only has the tools listed under
11> "What ships". `aien-proof` (the shared test-board tool) is **not** on the
12> stick: use it only from Ubuntu.
13
14This procedure builds and exercises the bootable recovery USB for
15[issue #17](https://github.com/aien-dev/aienux/issues/17) and TRUST-1 Gate 1.
16The physical run on 2026-09-25 booted the USB once, mounted the internal root
17and ESP read-only, checked the fallback loader and recovery tools, and
18returned to Ubuntu. It made no filesystem or firmware changes. The evidence
19is in [recovery_boot_machine1.md](../evidence/recovery_boot_machine1.md).
20
21That historical stick loaded an external, unauthenticated initrd. Its
22read-only boot receipt remains valid for that observation, not for
23authenticated recovery userspace or for safely presenting offline secrets.
24The signed replacement described below is implemented in the builder but
25has not been staged, booted or qualified on Machine 1.
26
27**Issue #17 done state:** Machine 1 has booted the USB recovery environment;
28the environment mounted the NVMe root and ESP read-only, confirmed repair and
29boot-entry tools are present, and the boot was recorded. Actual filesystem
30repair and boot-entry mutation are intentionally outside this read-only
31exercise.
32
33## What the new builder ships (not yet hardware-qualified)
34
35- `scripts/build_recovery_media.sh /dev/sdX1` accepts an existing, unmounted
36 FAT partition only. It refuses the internal NVMe and ATLAS_RECOV, mounts
37 the target with `nodev,nosuid,noexec`, and writes through a private mount
38 point. An ext4/other Unix filesystem is refused before any mount or write;
39 preexisting filesystem symlinks must never be followed as root.
40- The new build carries signed shim plus a single **owner-signed standalone GRUB
41 EFI image**. The GRUB image contains its menu, the signed production
42 kernel and the complete initrd in its embedded memdisk. The menu loads
43 `(memdisk)/boot/vmlinuz` and `(memdisk)/boot/initrd.img`; there is no external
44 `grub.cfg`, kernel or initrd for a USB editor to replace independently.
45 Firmware/shim acceptance of this owner signature requires the exact
46 signing certificate to be enrolled and not revoked; `sbverify` on the build
47 host alone does not establish that enrollment or a successful physical boot.
48- `scripts/build_standalone_recovery_initrd.sh` creates the unsigned RAM
49 rescue payload for embedding; its standalone output is **not** an
50 authenticated boot artifact and must never be loaded directly from USB.
51 It contains these programs (the `BINARIES` list in that
52 script, plus gocryptfs):
53 - shell and basics: BusyBox (with its built-in commands), `sh`, `bash`,
54 `mount`, `umount`, `mkdir`, `cat`, `grep`, `sed`, `sha256sum`;
55 - disks: `lsblk`, `blkid`, `findmnt`, `cryptsetup`;
56 - repair and boot entries: `fsck.vfat`, `mkfs.vfat`, `fsck.ext4`, `chroot`,
57 `efibootmgr`;
58 - TRUST-1 Gate 1: `tpm2_pcrread` (startup measurements), `sbverify` (loader
59 signatures), `age` (opens the offline spare), `gocryptfs` and
60 `fusermount3` (open and close the private storage read-only).
61
62 It also packages the Machine 1 xHCI/HID/USB-storage/NVMe/dm-crypt modules.
63 It does **not** contain `aien-proof`, `tpm2_eventlog`, `mokutil`, a
64 repository checkout, or any key. Internal storage remains unmounted until
65 the operator mounts it.
66- The build copies the attended collector into the image at
67 `/usr/local/sbin/collect_recovery_boot_evidence`; it does not depend on a
68 repository checkout being present in the rescue shell.
69- `scripts/verify_recovery_tools.sh` extracts a locally built initrd and
70 checks its tools and collector. This proves contents, not boot integrity.
71- `scripts/test_recovery_media_security.sh` checks target-type refusal and
72 signed-image tamper refusal using throwaway keys and scratch files.
73 `AIENOS_RECOVERY_QEMU_EMBED=1` also boots a signed standalone GRUB directly
74 under AAVMF Secure Boot with a published snakeoil test key, checks hostile
75 external `grub.cfg` files do not override its embedded config, and observes
76 firmware refusal after an embedded initrd byte changes. It does **not**
77 exercise Ubuntu shim, owner MOK enrollment or physical hardware.
78- `scripts/qemu_verify_recovery_media.sh` verifies the RAM payload in a
79 zero-disk QEMU kernel boot. It does **not** exercise shim or signed GRUB.
80
81The builder keeps temporary initrd, unsigned EFI and signing intermediates in
82a private build directory, removes them on exit, and never puts those files
83on the removable medium.
84
85## Build and verify
86
87The owner key must remain on a separate offline signing machine, never on
88Machine 1's everyday Linux. On Machine 1, export **public boot inputs only**:
89the selected `/boot/vmlinuz-<kernel-version>`, the known Ubuntu shim
90`/boot/efi/EFI/boot/BOOTAA64.EFI`, optional MOK manager
91`/boot/efi/EFI/ubuntu/mmaa64.efi`, and the exact matching
92`/lib/modules/<kernel-version>/` tree with `modules.dep*` metadata. Copy
93those files from Machine 1 to a separate **data-only transfer medium** and
94then to the offline signer; do not transfer the owner signing key in this
95direction or run the signing operation on Machine 1. Record each input's
96SHA-256 digest on Machine 1 and compare every transferred copy on the
97offline signer before building; a mismatch or unverified source is a STOP.
98Install the matching module tree at `/lib/modules/<kernel-version>/` on
99the offline signer so `modprobe -S <kernel-version> --show-depends` finds it.
100The signer must also have the recovery `BINARIES`, their shared
101libraries, `gocryptfs`, `libtss2-tcti-device`, `grub-mkstandalone`, `sbsign`,
102`sbverify`, `zstd`, `xz` and a FAT filesystem toolchain. The private signing
103key is never transferred back with the public inputs or copied into the
104recovery image. The signer needs the prepared USB partition attached when
105the script runs.
106
107New temporary foreign build dependencies on this path, measured on the
108development host: `grub-mkstandalone` (GRUB `2.12-1ubuntu7.3`) packages
109kernel, initrd and menu into an ARM64 PE with embedded memdisk;
110`sbsign`/`sbverify` (`0.9.4`) sign and check its Authenticode certificate.
111Record the offline signer's exact versions with the build receipt rather
112than assuming they match. The forward replacement is an Omega-authored
113PE/memdisk builder and signer with independent verification; it is not
114implemented in this change.
115
116The preexisting unattended USB and 2026-09-25 receipt predate this
117authenticated-image builder. They do not establish that the replacement
118boots or that the owner certificate is enrolled. The replacement requires
119an attended Secure Boot ON boot and refusal after initrd-only tampering
120before TRUST-1 Gate 1 may rely on it. The offline AAVMF test uses a different
121trust anchor and does not close that operator/hardware requirement.
122
123```bash
124# On the prepared offline signer, after checking transferred input digests:
125lsblk -f
126bash scripts/test_recovery_media_security.sh
127AIENOS_RECOVERY_QEMU_EMBED=1 bash scripts/test_recovery_media_security.sh
128bash scripts/verify_recovery_tools.sh
129bash scripts/qemu_verify_recovery_media.sh
130export AIENOS_RECOVERY_KERNEL=/verified/public/vmlinuz-<kernel-version>
131export AIENOS_RECOVERY_SHIM=/verified/public/BOOTAA64.EFI
132export AIENOS_RECOVERY_MOKMANAGER=/verified/public/mmaa64.efi
133export AIENOS_RECOVERY_SIGNING_KEY=/secure/offline/boot-signer.key
134export AIENOS_RECOVERY_SIGNING_CERT=/secure/offline/boot-signer.crt
135sudo -v
136sudo --preserve-env=AIENOS_RECOVERY_KERNEL,AIENOS_RECOVERY_SHIM,AIENOS_RECOVERY_MOKMANAGER,AIENOS_RECOVERY_SIGNING_KEY,AIENOS_RECOVERY_SIGNING_CERT \
137 bash scripts/build_recovery_media.sh /dev/sdX1
138```
139
140The builder refuses missing signer inputs and refuses to install an
141unsigned GRUB. Its local `sbverify --cert` checks the built image signature,
142not actual firmware/shim admission. Confirm the selected partition's
143identity and FAT type before invoking it; a mounted or non-FAT target is
144rejected. Do not format it as a side effect of this build.
145
146## Boot the USB once
147
148Use the firmware boot menu or set a one-time BootNext. Do not change the
149default boot order. The attended run observed the USB as `BootCurrent: 0004`
150and `BootOrder: 0001,0003,0004`.
151
152```bash
153sudo efibootmgr --bootnext 0004
154sudo reboot
155```
156
157Expect the AIENOS GRUB menu and the rescue banner `AIENOS Standalone Hardware
158Recovery Core` / `Root filesystem: 100% RAM disk`. The shell reports Secure
159Boot, PCRs, devices, and firmware entries. The NVMe is initially unmounted.
160
161## Inspect internal storage read-only
162
163The Machine 1 root is ext4 UUID
164`d27bfd26-ff30-400e-9eca-9cdf73de9406` on `/dev/nvme0n1p2`. Check and mount it
165read-only:
166
167```sh
168blkid /dev/nvme0n1p2
169fsck.ext4 -n /dev/nvme0n1p2
170mkdir -p /mnt/root
171mount -o ro /dev/nvme0n1p2 /mnt/root
172```
173
174The ESP is vfat UUID `9DA2-3597` on `/dev/nvme0n1p1`. Check and mount it
175read-only at `/mnt/esp`:
176
177```sh
178blkid /dev/nvme0n1p1
179fsck.vfat -n /dev/nvme0n1p1
180mkdir -p /mnt/esp
181mount -o ro /dev/nvme0n1p1 /mnt/esp
182ls -l /mnt/esp/EFI/BOOT/BOOTAA64.EFI
183```
184
185`fsck.vfat`, `mkfs.vfat`, `fsck.ext4`, and `chroot` are present for a
186separately authorized repair workflow. Do not use repair or format options
187during this evidence exercise. `efibootmgr` can list firmware entries; this
188exercise only reads entries and does not change efivars or BootOrder.
189
190## Capture the recovery evidence
191
192Run the collector packaged on the USB, not a copy assumed to exist in the
193repository checkout. Use the exact mount locations above. Type it as shown,
194with no `aien-proof hold` in front: that tool is not on the stick, and an
195earlier version of this page wrongly said to use it here.
196
197```sh
198env AIENOS_ESP_MNT=/mnt/esp \
199 /usr/local/sbin/collect_recovery_boot_evidence /mnt/root
200```
201
202The collector is read-only. A PASS checks removable-media boot, Secure Boot
203byte readability, internal root mount, ESP mount and fallback loader,
204efivarfs presence, and readable boot entries. Preserve its complete output.
205
206For the TRUST-1 Gate 1 round trip (opening the private storage read-only with
207the offline spare), use the longer form with the `AIENOS_UNLOCK_*` settings in
208[TRUST-1-OPERATOR-STEPS.md, Step 6](TRUST-1-OPERATOR-STEPS.md#step-6-boot-the-recovery-stick-with-secure-boot-on-and-prove-the-unlock-gate-1-attended).
209
210For the 2026-09-25 historical boot, the Machine 1 `aien-proof hold`
211around the old stick build was the last ledger event before reboot; that run
212had no separate boot ledger event. For the new offline-signed build, do not
213claim such a Machine 1 build hold exists. Record the offline signer's
214source-input digests, signed EFI digest, signer certificate fingerprint,
215host and AAVMF test outputs, and the distinct attended boot/return evidence.
216
217## Return to Linux and complete the record
218
219Exit any chroot, unmount `/mnt/esp` and `/mnt/root`, then reboot or power off.
220Confirm Linux returns and record its root/ESP mounts. Record the recovery
221`BootCurrent` and `BootOrder`, the return-to-Linux proof, tool results and
222Secure Boot observations before and after the boot. Record only test-board
223events actually taken from Ubuntu; the old build hold belongs solely to
224the 2026-09-25 run. If an abbreviated collector or receipt omitted the
225Secure Boot byte or post-return state, say so explicitly; do not infer it.
226
227For the 2026-09-25 run, the recovery entry was `Boot0004* UEFI: USB USB Hard
228Drive, Partition 1`; BootCurrent was `0004` and BootOrder remained
229`0001,0003,0004`. The root and ESP were mounted read-only, the fallback
230loader was present, the listed repair tools were present, and Ubuntu
231returned. Secure Boot was observed enabled immediately before the run. The
232abbreviated receipt omitted the EFI byte and the supplied return output did
233not capture a second Secure Boot observation. See the evidence record for
234full values and limits.
235
236## Issue #17 mapping
237
238| Requirement | Evidence |
239| --- | --- |
240| USB boots Machine 1 into rescue | Recovery `BootCurrent: 0004`, Linux kernel and command line in the evidence record |
241| Mount the NVMe root | Root UUID and read-only `/mnt/root` mount |
242| Repair `/boot/efi` capability | `fsck.vfat`, `mkfs.vfat`, and `chroot` are present; no repair was performed |
243| Restore boot-entry capability | `efibootmgr` is present and boot entries are readable; no entry was changed |
244| Record boot and recovery | Attended output and return-to-Linux observations in the evidence record |
245
246The QEMU zero-disk boot and the earlier unattended self-test are separate
247supporting evidence. They do not replace the attended mount and return
248evidence recorded for this exercise.