Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/docs/RECOVERY_MEDIA_MACHINE1.md # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 14 This 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. 16 The physical run on 2026-09-25 booted the USB once, mounted the internal root 17 and ESP read-only, checked the fallback loader and recovery tools, and 18 returned to Ubuntu. It made no filesystem or firmware changes. The evidence 19 is in [recovery_boot_machine1.md](../evidence/recovery_boot_machine1.md). 20 21 That historical stick loaded an external, unauthenticated initrd. Its 22 read-only boot receipt remains valid for that observation, not for 23 authenticated recovery userspace or for safely presenting offline secrets. 24 The signed replacement described below is implemented in the builder but 25 has not been staged, booted or qualified on Machine 1. 26 27 **Issue #17 done state:** Machine 1 has booted the USB recovery environment; 28 the environment mounted the NVMe root and ESP read-only, confirmed repair and 29 boot-entry tools are present, and the boot was recorded. Actual filesystem 30 repair and boot-entry mutation are intentionally outside this read-only 31 exercise. 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 81 The builder keeps temporary initrd, unsigned EFI and signing intermediates in 82 a private build directory, removes them on exit, and never puts those files 83 on the removable medium. 84 85 ## Build and verify 86 87 The owner key must remain on a separate offline signing machine, never on 88 Machine 1's everyday Linux. On Machine 1, export **public boot inputs only**: 89 the selected `/boot/vmlinuz-`, 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//` tree with `modules.dep*` metadata. Copy 93 those files from Machine 1 to a separate **data-only transfer medium** and 94 then to the offline signer; do not transfer the owner signing key in this 95 direction or run the signing operation on Machine 1. Record each input's 96 SHA-256 digest on Machine 1 and compare every transferred copy on the 97 offline signer before building; a mismatch or unverified source is a STOP. 98 Install the matching module tree at `/lib/modules//` on 99 the offline signer so `modprobe -S --show-depends` finds it. 100 The signer must also have the recovery `BINARIES`, their shared 101 libraries, `gocryptfs`, `libtss2-tcti-device`, `grub-mkstandalone`, `sbsign`, 102 `sbverify`, `zstd`, `xz` and a FAT filesystem toolchain. The private signing 103 key is never transferred back with the public inputs or copied into the 104 recovery image. The signer needs the prepared USB partition attached when 105 the script runs. 106 107 New temporary foreign build dependencies on this path, measured on the 108 development host: `grub-mkstandalone` (GRUB `2.12-1ubuntu7.3`) packages 109 kernel, initrd and menu into an ARM64 PE with embedded memdisk; 110 `sbsign`/`sbverify` (`0.9.4`) sign and check its Authenticode certificate. 111 Record the offline signer's exact versions with the build receipt rather 112 than assuming they match. The forward replacement is an Omega-authored 113 PE/memdisk builder and signer with independent verification; it is not 114 implemented in this change. 115 116 The preexisting unattended USB and 2026-09-25 receipt predate this 117 authenticated-image builder. They do not establish that the replacement 118 boots or that the owner certificate is enrolled. The replacement requires 119 an attended Secure Boot ON boot and refusal after initrd-only tampering 120 before TRUST-1 Gate 1 may rely on it. The offline AAVMF test uses a different 121 trust anchor and does not close that operator/hardware requirement. 122 123 ```bash 124 # On the prepared offline signer, after checking transferred input digests: 125 lsblk -f 126 bash scripts/test_recovery_media_security.sh 127 AIENOS_RECOVERY_QEMU_EMBED=1 bash scripts/test_recovery_media_security.sh 128 bash scripts/verify_recovery_tools.sh 129 bash scripts/qemu_verify_recovery_media.sh 130 export AIENOS_RECOVERY_KERNEL=/verified/public/vmlinuz- 131 export AIENOS_RECOVERY_SHIM=/verified/public/BOOTAA64.EFI 132 export AIENOS_RECOVERY_MOKMANAGER=/verified/public/mmaa64.efi 133 export AIENOS_RECOVERY_SIGNING_KEY=/secure/offline/boot-signer.key 134 export AIENOS_RECOVERY_SIGNING_CERT=/secure/offline/boot-signer.crt 135 sudo -v 136 sudo --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 140 The builder refuses missing signer inputs and refuses to install an 141 unsigned GRUB. Its local `sbverify --cert` checks the built image signature, 142 not actual firmware/shim admission. Confirm the selected partition's 143 identity and FAT type before invoking it; a mounted or non-FAT target is 144 rejected. Do not format it as a side effect of this build. 145 146 ## Boot the USB once 147 148 Use the firmware boot menu or set a one-time BootNext. Do not change the 149 default boot order. The attended run observed the USB as `BootCurrent: 0004` 150 and `BootOrder: 0001,0003,0004`. 151 152 ```bash 153 sudo efibootmgr --bootnext 0004 154 sudo reboot 155 ``` 156 157 Expect the AIENOS GRUB menu and the rescue banner `AIENOS Standalone Hardware 158 Recovery Core` / `Root filesystem: 100% RAM disk`. The shell reports Secure 159 Boot, PCRs, devices, and firmware entries. The NVMe is initially unmounted. 160 161 ## Inspect internal storage read-only 162 163 The Machine 1 root is ext4 UUID 164 ``d27bfd26`-ff30-400e-9eca-`9cdf73de9406`` on `/dev/nvme0n1p2`. Check and mount it 165 read-only: 166 167 ```sh 168 blkid /dev/nvme0n1p2 169 fsck.ext4 -n /dev/nvme0n1p2 170 mkdir -p /mnt/root 171 mount -o ro /dev/nvme0n1p2 /mnt/root 172 ``` 173 174 The ESP is vfat UUID `9DA2-3597` on `/dev/nvme0n1p1`. Check and mount it 175 read-only at `/mnt/esp`: 176 177 ```sh 178 blkid /dev/nvme0n1p1 179 fsck.vfat -n /dev/nvme0n1p1 180 mkdir -p /mnt/esp 181 mount -o ro /dev/nvme0n1p1 /mnt/esp 182 ls -l /mnt/esp/EFI/BOOT/BOOTAA64.EFI 183 ``` 184 185 `fsck.vfat`, `mkfs.vfat`, `fsck.ext4`, and `chroot` are present for a 186 separately authorized repair workflow. Do not use repair or format options 187 during this evidence exercise. `efibootmgr` can list firmware entries; this 188 exercise only reads entries and does not change efivars or BootOrder. 189 190 ## Capture the recovery evidence 191 192 Run the collector packaged on the USB, not a copy assumed to exist in the 193 repository checkout. Use the exact mount locations above. Type it as shown, 194 with no `aien-proof hold` in front: that tool is not on the stick, and an 195 earlier version of this page wrongly said to use it here. 196 197 ```sh 198 env AIENOS_ESP_MNT=/mnt/esp \ 199 /usr/local/sbin/collect_recovery_boot_evidence /mnt/root 200 ``` 201 202 The collector is read-only. A PASS checks removable-media boot, Secure Boot 203 byte readability, internal root mount, ESP mount and fallback loader, 204 efivarfs presence, and readable boot entries. Preserve its complete output. 205 206 For the TRUST-1 Gate 1 round trip (opening the private storage read-only with 207 the 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 210 For the 2026-09-25 historical boot, the Machine 1 `aien-proof hold` 211 around the old stick build was the last ledger event before reboot; that run 212 had no separate boot ledger event. For the new offline-signed build, do not 213 claim such a Machine 1 build hold exists. Record the offline signer's 214 source-input digests, signed EFI digest, signer certificate fingerprint, 215 host and AAVMF test outputs, and the distinct attended boot/return evidence. 216 217 ## Return to Linux and complete the record 218 219 Exit any chroot, unmount `/mnt/esp` and `/mnt/root`, then reboot or power off. 220 Confirm Linux returns and record its root/ESP mounts. Record the recovery 221 `BootCurrent` and `BootOrder`, the return-to-Linux proof, tool results and 222 Secure Boot observations before and after the boot. Record only test-board 223 events actually taken from Ubuntu; the old build hold belongs solely to 224 the 2026-09-25 run. If an abbreviated collector or receipt omitted the 225 Secure Boot byte or post-return state, say so explicitly; do not infer it. 226 227 For the 2026-09-25 run, the recovery entry was `Boot0004* UEFI: USB USB Hard 228 Drive, Partition 1`; BootCurrent was `0004` and BootOrder remained 229 `0001,0003,0004`. The root and ESP were mounted read-only, the fallback 230 loader was present, the listed repair tools were present, and Ubuntu 231 returned. Secure Boot was observed enabled immediately before the run. The 232 abbreviated receipt omitted the EFI byte and the supplied return output did 233 not capture a second Secure Boot observation. See the evidence record for 234 full 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 246 The QEMU zero-disk boot and the earlier unattended self-test are separate 247 supporting evidence. They do not replace the attended mount and return 248 evidence recorded for this exercise.