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

@ -63,34 +63,36 @@ Without using Python:
* *Only* copy distfiles listed in ``sources`` files for ``build:`` steps
manifested before ``improve: get_network`` into this disk.
* In kernel-bootstrap offline mode (no ``--repo`` and no
``--external-sources``), use the second image as ``payload.img``.
``payload.img`` is a raw container (not a filesystem) used to carry the
* In kernel-bootstrap mode with ``--external-sources`` (and no ``--repo``),
use the second image as ``external.img``.
``external.img`` is a raw container (not a filesystem) used to carry the
distfiles that are not needed before ``improve: import_payload``.
In other words, the first image only carries the minimal set needed to
reach the importer; the rest of the offline distfiles live in payload.
reach the importer; the rest of the distfiles live in ``external.img``.
* Header magic: ``LBPAYLD1`` (8 bytes).
* Then: little-endian ``u32`` file count.
* Repeated for each file: little-endian ``u32`` name length,
little-endian ``u32`` file size, raw file name bytes, raw file bytes.
* If you are not in that mode, the second disk can still be used as an
optional ext3 distfiles disk, as before.
* With ``--repo``, the second disk remains an ext3 distfiles/repo disk.
* Without ``--external-sources`` and without ``--repo``, no second disk is
used: the initial image includes only pre-network distfiles, and later
distfiles are downloaded from configured mirrors after networking starts.
* Run QEMU, with 4+G RAM, optionally SMP (multicore), both drives (main
builder image plus payload/ext3 image), a NIC with model E1000
builder image plus external image, when a second image is used), a NIC with model E1000
(``-nic user,model=e1000``), and ``-machine kernel-irqchip=split``.
c. **Bare metal:** Follow the same steps as QEMU, but the disks need to be
two different *physical* disks, and boot from the first disk.
Manual ``payload.img`` preparation
----------------------------------
Manual raw ``external.img`` preparation
---------------------------------------
The following script creates a raw ``payload.img`` from a manually prepared
The following script creates a raw ``external.img`` from a manually prepared
file list. This is equivalent to what ``rootfs.py`` does for kernel-bootstrap
offline mode.
with ``--external-sources`` (and no ``--repo``).
1. Prepare a ``payload.list`` with one file per line, formatted as:
1. Prepare an ``external.list`` with one file per line, formatted as:
``<archive-name> <absolute-path-to-archive>``.
2. Run:
@ -99,8 +101,8 @@ offline mode.
cat > make-payload.sh <<'EOF'
#!/bin/sh
set -e
out="${1:-payload.img}"
list="${2:-payload.list}"
out="${1:-external.img}"
list="${2:-external.list}"
write_u32le() {
v="$1"
@ -122,16 +124,19 @@ offline mode.
done < "${list}"
EOF
chmod +x make-payload.sh
./make-payload.sh payload.img payload.list
./make-payload.sh external.img external.list
3. Attach ``payload.img`` as an additional raw disk when booting in QEMU, or
3. Attach ``external.img`` as an additional raw disk when booting in QEMU, or
as the second physical disk on bare metal.
Notes:
* ``payload.img`` is used in kernel-bootstrap offline mode regardless of
``--build-guix-also``. With ``--build-guix-also``, the payload content is
larger because it also includes post-early sources from ``steps-guix``.
* ``external.img`` raw container mode is used with ``--external-sources`` (and
no ``--repo``). With ``--build-guix-also``, the container content is larger
because it also includes post-early sources from ``steps-guix``.
* Without ``--external-sources`` and without ``--repo``, there is no second
image. The initial image only includes distfiles needed before
``improve: get_network``; later distfiles are downloaded from mirrors.
* The runtime importer identifies the correct disk by checking the magic
``LBPAYLD1`` on each detected block device, not by assuming a device name.