fix(kernel-bootstrap): unify external raw container flow and remove default second disk

This commit is contained in:
vxtls 2026-03-03 08:33:19 -05:00
parent 919200478b
commit 85c389044d
4 changed files with 120 additions and 91 deletions

View file

@ -2,10 +2,10 @@
This repository uses [`README.rst`](./README.rst) as the canonical main documentation.
## Kernel-bootstrap `payload.img`
## Kernel-bootstrap raw `external.img`
`payload.img` is a raw container disk used in kernel-bootstrap offline mode
(`--repo` and `--external-sources` are both unset).
`external.img` is a raw container disk used in kernel-bootstrap mode when
`--external-sources` is set and `--repo` is unset.
### Why not put everything in the initial image?
@ -20,7 +20,7 @@ around the Fiwix transition in QEMU or on bare metal).
So the design is intentionally split:
- Initial image: only what is required to reach `improve: import_payload`
- `payload.img`: the rest of offline distfiles
- `external.img`: the rest of distfiles
This is not a patch-style workaround. It is a two-phase transport design that
keeps early boot deterministic and moves bulk data import to a stage where the
@ -29,14 +29,14 @@ runtime is robust enough to process it safely.
### Why import from an external image and copy into main filesystem?
Because the bootstrap still expects distfiles to end up under the normal local
path (`/external/distfiles`) for later steps. `payload.img` is used as a
path (`/external/distfiles`) for later steps. `external.img` is used as a
transport medium only.
The flow is:
1. Boot minimal initial image.
2. Reach `improve: import_payload`.
3. Detect the payload disk by magic (`LBPAYLD1`) across detected block devices.
3. Detect the external container disk by magic (`LBPAYLD1`) across detected block devices.
4. Copy payload files into `/external/distfiles`.
5. Continue the build exactly as if files had been present locally all along.
@ -54,7 +54,7 @@ The importer probes detected block devices and selects the one with magic `LBPAY
### Manual creation without Python
Prepare `payload.list` as:
Prepare `external.list` as:
```text
<archive-name> <absolute-path-to-archive>
@ -66,8 +66,8 @@ Then:
cat > make-payload.sh <<'SH'
#!/bin/sh
set -e
out="${1:-payload.img}"
list="${2:-payload.list}"
out="${1:-external.img}"
list="${2:-external.list}"
write_u32le() {
v="$1"
@ -89,14 +89,17 @@ while read -r name path; do
done < "${list}"
SH
chmod +x make-payload.sh
./make-payload.sh payload.img payload.list
./make-payload.sh external.img external.list
```
Attach `payload.img` as an extra raw disk in QEMU, or as the second disk on bare metal.
Attach `external.img` as an extra raw disk in QEMU, or as the second disk on bare metal.
### When it is used
- Used in kernel-bootstrap offline mode.
- Not used when `--repo` or `--external-sources` is provided.
- `--build-guix-also` increases payload contents (includes post-early `steps-guix`
- Used in kernel-bootstrap with `--external-sources` and without `--repo`.
- Not used with `--repo` (that path still uses an ext filesystem disk).
- Without `--external-sources` and without `--repo`, there is no second disk:
the initial image only includes distfiles needed before `improve: get_network`,
and later distfiles are downloaded from mirrors.
- `--build-guix-also` increases container contents (includes post-early `steps-guix`
sources), but does not change the mechanism.