feat(rescue): bootable Debian rescue stick #1

Merged
ses merged 36 commits from feat/rescue-image into main 2026-11-06 17:16:51 +00:00
Owner

Summary

  • New rescue/ image: a bootable Debian Trixie USB stick for laptop repair — disk, LVM, bcache, cryptsetup, vendor firmware (Intel WiFi, MediaTek), SSH, restic, tmux.
  • Built with mkosi from rescue/mkosi.conf (version 26.10.3 via mkosi.version/mkosi.bump): two GPT partitions — 512 MiB ESP fixed, 3 GiB btrfs root — no fstab: systemd-gpt-auto-generator finds both by GPT type. /boot on the root tree stays deliberately empty; a populated one makes the generator drop the ESP.
  • systemd-boot with Type 1 entries (UnifiedKernelImages=none) so apt upgrade kernels actually boot; root autologin on every console including serial; one shared wpa_supplicant config for every adapter, started per interface by a udev rule; networkd DHCP; .bash_history seeded from two real repair sessions; the README ships to /root.
  • rescue/mise-tasks/build injects secrets from a directory argument (refuses missing or wrong-mode files) and defaults to the inert stand-ins in rescue/tests/fixtures/secrets/, so the default build is harmless.
  • write.sh: refuses non-root and drives that are neither USB nor removable, asks for a typed confirmation, dds the newest .raw, then sgdisk -e moves the backup GPT to the end of the (larger) stick when sgdisk is present.
  • test.sh: builds with the fixtures, checks the partition table, boots under QEMU/OVMF and runs 24 checks — shell, gpt-auto mounts, loader, networkd/wpa, firmware, snapshots, secrets, ssh key pair.
  • Repo-level: top-level README.md covers both images and the rescue workflow; mise.toml gains qemu-system-x86, ovmf, util-linux; .gitignore ignores VARS.fd; new opencode.jsonc denies the agent read/edit/grep/bash access to *secrets/* (fixtures explicitly allowed).

Why

  • Symptom: a laptop that no longer boots needs disk, LVM/bcache, LUKS and vendor-firmware tools that stock live installers leave out, and an unknown live distro is no trusted medium.
  • Policy: one purpose-built minimal stick, Debian Trixie only, UEFI only, unencrypted and treated as a bearer token; secrets are injected at build time from outside the repository, guarded by opencode.jsonc.
  • Rejected: UKI boot entries — systemd-boot sorts sort-keyed entries first, so an apt upgrade would install kernels that never boot. Grow-on-first-boot — the image is sized at build time, systemd-growfs has nothing to do. GRUB BIOS — the target hardware boots UEFI.

Verification

Scenario Expected Result
./test.sh (build + QEMU/OVMF boot, fixture secrets) boots, all checks pass 24 checks, 0 failures
write.sh on a non-removable disk refused before any write by inspection
write.sh without sgdisk warning, stick written anyway by inspection
Agent secret guardrails *secrets/* denied, fixtures allowed opencode.jsonc, by inspection

Out of scope

  • Size guard before dd — an undersized stick fails mid-write; the README documents it.
  • Installing sgdisk automatically — a missing binary warns and continues.
  • Growing the root partition to fill the stick — repartitioning on the stick stays manual by design.
  • Publishing — unlike the Vagrant boxes, the rescue image is built and carried, not uploaded.
## Summary - New `rescue/` image: a bootable Debian Trixie USB stick for laptop repair — disk, LVM, bcache, cryptsetup, vendor firmware (Intel WiFi, MediaTek), SSH, restic, tmux. - Built with mkosi from `rescue/mkosi.conf` (version `26.10.3` via `mkosi.version`/`mkosi.bump`): two GPT partitions — 512 MiB ESP fixed, 3 GiB btrfs root — no `fstab`: `systemd-gpt-auto-generator` finds both by GPT type. `/boot` on the root tree stays deliberately empty; a populated one makes the generator drop the ESP. - systemd-boot with Type 1 entries (`UnifiedKernelImages=none`) so `apt upgrade` kernels actually boot; root autologin on every console including serial; one shared `wpa_supplicant` config for every adapter, started per interface by a udev rule; networkd DHCP; `.bash_history` seeded from two real repair sessions; the README ships to `/root`. - `rescue/mise-tasks/build` injects secrets from a directory argument (refuses missing or wrong-mode files) and defaults to the inert stand-ins in `rescue/tests/fixtures/secrets/`, so the default build is harmless. - `write.sh`: refuses non-root and drives that are neither USB nor removable, asks for a typed confirmation, `dd`s the newest `.raw`, then `sgdisk -e` moves the backup GPT to the end of the (larger) stick when `sgdisk` is present. - `test.sh`: builds with the fixtures, checks the partition table, boots under QEMU/OVMF and runs 24 checks — shell, gpt-auto mounts, loader, networkd/wpa, firmware, snapshots, secrets, ssh key pair. - Repo-level: top-level `README.md` covers both images and the rescue workflow; `mise.toml` gains `qemu-system-x86`, `ovmf`, `util-linux`; `.gitignore` ignores `VARS.fd`; new `opencode.jsonc` denies the agent read/edit/grep/bash access to `*secrets/*` (fixtures explicitly allowed). ## Why - Symptom: a laptop that no longer boots needs disk, LVM/bcache, LUKS and vendor-firmware tools that stock live installers leave out, and an unknown live distro is no trusted medium. - Policy: one purpose-built minimal stick, Debian Trixie only, UEFI only, unencrypted and treated as a bearer token; secrets are injected at build time from outside the repository, guarded by `opencode.jsonc`. - Rejected: UKI boot entries — systemd-boot sorts sort-keyed entries first, so an `apt upgrade` would install kernels that never boot. Grow-on-first-boot — the image is sized at build time, `systemd-growfs` has nothing to do. GRUB BIOS — the target hardware boots UEFI. ## Verification | Scenario | Expected | Result | |---|---|---| | `./test.sh` (build + QEMU/OVMF boot, fixture secrets) | boots, all checks pass | 24 checks, 0 failures | | `write.sh` on a non-removable disk | refused before any write | by inspection | | `write.sh` without `sgdisk` | warning, stick written anyway | by inspection | | Agent secret guardrails | `*secrets/*` denied, fixtures allowed | `opencode.jsonc`, by inspection | ## Out of scope - Size guard before `dd` — an undersized stick fails mid-write; the README documents it. - Installing `sgdisk` automatically — a missing binary warns and continues. - Growing the root partition to fill the stick — repartitioning on the stick stays manual by design. - Publishing — unlike the Vagrant boxes, the rescue image is built and carried, not uploaded.
ses added 25 commits 2026-11-01 13:18:11 +00:00
Three defects the QEMU e2e run exposed:

- The image was unusable over serial. mkosi's Autologin=yes only writes
  drop-ins for console-getty and getty@tty1, so serial-getty stopped at a
  login prompt nobody could pass, since root's password is locked. Add a
  drop-in on the serial-getty@.service template so every serial port is
  covered, including ones this image has never seen.

- systemd-firstboot stopped every boot to ask for a user name, because the
  image ships no committed machine-id. Set systemd.firstboot=no rather than
  creating /etc/machine-id, which would be wrong on a stick that gets
  written to many machines.

- btrfs subvolume snapshot does not set ro in btrfs-progs 7.1; a snapshot
  is writable without -r. The rollback point was therefore not immutable
  and the README claimed it was. Use -r, and test writability.

Verified by booting: ESP mounts at /boot with /efi left empty, so drop the
/efi pin (it only made both candidate paths busy), point the checks there,
and correct the README.

setup.sh passed --copy-to a directory; it takes the image, so injection
failed on argument parsing. Copy each file straight into the image, which
also keeps secrets off the host staging tree.
Two independent rules had to line up, and neither is obvious from the docs.

systemd-gpt-auto-generator takes /boot for the ESP whenever /boot is empty in
the root filesystem, and only falls back to /efi when /boot is non-empty
(add_partition_esp in gpt-auto-generator.c). So the way to get the ESP on /efi
is to make /boot busy, not to "pin" /efi.

But repart never copies /boot or /efi into the root filesystem when an ESP is
part of the same image, so /boot was empty and the ESP landed there. repart's
manual documents the override: an explicit CopyFiles=/boot:/boot. That puts the
kernel on the root filesystem, makes /boot busy, and the ESP moves to /efi.

Verified by booting: ESP on /efi, BOOTX64.EFI and the loader entries present,
bootctl agreeing. 16 of 18 checks pass; the two secret checks still need a
host that can mount the image.
Closes four gaps found by checking the package list against a built tree.

firmware-iwlwifi is not pulled in by firmware-linux, and the image had no
iwlwifi firmware at all, so Intel wireless could not work -- the common case
for the laptops this image exists to rescue.

systemd-cryptsetup adds the boot-time units that prompt for a passphrase and
unlock LUKS volumes. cryptsetup-bin was already there, so volumes could be
opened by hand, just not automatically.

tmux keeps a session alive across a serial console dropping, which is the
normal failure mode when SSH is not up yet.

dracut replaces initramfs-tools. I expected a Conflicts problem, but on trixie
apt resolves linux-image's initrd dependency through linux-initramfs-tool, so
initramfs-tools is never pulled in and nothing has to be removed. Verified
with apt-get -s against a trixie index rather than against this host, which
is debian 14/sid and would have given the wrong answer.
The image was 11G and would not fit on the 8G sticks it has to run from. It is
now 6.5G -- 512M ESP plus a 6G root -- and claims whatever a larger stick has on
top at the first boot.

The growing part is two stock systemd units, already shipped by the systemd
package and simply not enabled: systemd-repart stretches the root partition,
systemd-growfs grows btrfs into it. The DPS GrowFileSystem flag that drives the
second half is already set on the partition. Both are incremental, so later boots
do nothing.

One thing does need handling. write.sh dd's an image smaller than the stick,
which leaves the GPT backup header where the image ended; repart reads the last
usable LBA out of it, sees no free space and refuses to grow anything. write.sh
now moves that header to the end of the device. It is an unfixed upstream bug,
systemd#38747, so this is the workaround rather than the intended way.

Both the partition and the filesystem growing are now covered by test.sh, which
runs its disk larger than the image for the same reason write.sh leaves room.

Verified by booting: 6G image on a 16G stick grows to 15.5G with btrfs following,
unattended, ESP still on /efi. 20 of 22 checks pass; the two secret checks still
need a host that can mount the image.
The stick size should not be a build-time decision. A disk image is sized when
mkosi builds it, so an 8G stick forced a 6.5G image and anything larger had to be
grown by systemd-repart at boot. That dragged in two enabled units, a runtime
repart.d definition, and a workaround for a stale GPT header -- all of it to
recover the very freedom a build-time size had taken away.

Format=directory hands mkosi's output tree to mkstick.sh instead, which applies
mkosi.repart/ to the target at write time and repart sizes the root partition to
whatever the stick actually is. The growth path is therefore deleted rather than
fixed, along with its dependency on systemd-repart being installed in the image.

The ESP definition loses a comment explaining that repart resolves CopyFiles=
against --root=; that stays true but mkstick.sh is where it now matters.
mkstick.sh applies mkosi.repart/ to a target and lets --size=auto take the size
of whatever it is handed. It is a separate script from write.sh so test.sh can
run the identical repart invocation against a plain file: writing a stick and
testing a stick then differ only in the target, not in the command.

Two details are not obvious and cost an hour to find:

systemd-repart defaults to --dry-run=yes, so --dry-run=no has to be asked for
explicitly, the way mkosi asks for it.

CopyFiles= resolves against --root=. Without it, CopyFiles=/boot:/boot in
mkosi.repart/20-root.conf reads the host's /boot and repart aborts with
"Permission denied" instead of populating the image. mkosi passes --root=<tree>
for the same reason.

--seed is a fixed UUID rather than the version string: a version is not a UUID,
and two builds of the same version should produce the same partition layout.

Verified against systemd 257: an 8G target gets a 512M ESP and a 7.4G root,
/boot is populated in the root filesystem while /efi stays the ESP's, the
resulting image is sparse (5.9M of 8.0G) and needs neither root nor a loop
device.
Three changes that belong together: the secrets no longer need a mounted image,
the partition definitions are no longer mkosi's, and the stick is no longer
written without asking.

setup.sh copies into the image tree instead of into a disk image. There is no
image to reach into any more, and no reason to: the tree is a directory, so
this is install -m 600 and nothing else. It needs no root, no mount, no loop
device and no systemd-dissect. The tree it writes to is git-ignored, which is
what makes putting credentials in it acceptable. Files already present are kept,
so a second write.sh does not replace a rotated secret with an older copy.

mkosi.repart/ becomes repart.d/. mkosi no longer reads it -- repart_dirs is only
consulted in build_disk(), which Format=directory never reaches -- so the old
name claimed an ownership that had ended. repart.d/ is systemd's name for a
directory of partition definitions and matches the NN-<designator>.conf files
inside it.

write.sh gains --force and, without it, refuses to repartition a target that
already carries secrets. --empty=force would erase them, and setup.sh's
keep-what-is-there rule cannot help there because the check belongs where the
destruction happens. The root filesystem is found by PARTLABEL, which the older
image's own repart.d/ named "rescue", so no state has to be hardcoded.
test.sh now runs mkstick.sh rather than re-enacting what write.sh does. It
builds an 8G and a 16G stick and boots both, because the claim being tested is
that the target, not the build, decides the size: one size would pass even if
both were wrong the same way.

Sizing is asserted against the partition table before the boot, so a regression
there costs a second instead of a minute. The ESP must be exactly 512M and the
root must leave a constant 2088 sectors unaccounted for -- measured across 8G,
16G and 32G rather than guessed from one. The ESP check was verified to fail
when the definition is deliberately changed, because a check that cannot fail is
not a check. root-partition-grew and root-fs-grew are gone: repart sizes
everything up front now, so nothing grows at boot.

secrets-injected and secrets-mode-600 run against tests/fixtures/secrets/, which
holds generated stand-ins: an ssh-keygen key private to this repository, a
password that is a note, an ssh_config pointing at the non-resolving
storage.invalid, and a WPA config whose SSID does not exist. setup.sh is pointed
at them, so the real code path runs; the copies go into a throwaway copy of the
working directory, so a built tree is never left holding stand-ins that could
reach a real stick.

Both of the guards that keep secrets out of the repository matched any path
component called "secrets", which is how they were meant to be read and exactly
how they would have behaved:

rescue/.gitignore said "secrets/", which also swallowed the fixtures directory,
so they would never have been committed. It is now "/secrets/", anchored to the
real one.

opencode.jsonc said "*secrets/*", with the same effect on reads and edits. It
now re-opens exactly rescue/tests/fixtures/secrets/ after the denies, and the
exception cannot widen the real secrets because matching it requires the literal
path rescue/tests/fixtures/secrets/, which /.../rescue/secrets/ never contains.

mkosi.conf also gains ExtraTrees=README.md:/root/README.md so the instructions
are readable at the rescue shell, where autologin starts, and moves Packages=
out of [Runtime] into [Content], which is where mkosi says it belongs.
The first real build produced a tree that mkosi was happy with and a guest
that could not be used. Four separate causes, each found by booting the
artifact rather than by reading the config:

systemd.firstboot=no never arrived. KernelCommandLineExtra= is consulted
only when mkosi boots the image with nspawn, never when it assembles a UKI,
so the UKI had no .cmdline section at all. systemd-firstboot then asked for
a user name on every boot, between the firmware and the shell, and swallowed
everything a test fed the console. finalize_cmdline() reads
/etc/kernel/cmdline instead; that file is what lands in .cmdline.

loader.conf was in the wrong tree. mkosi points bootctl at
SYSTEMD_ESP_PATH=/efi, so the ESP is copied from the tree's efi/ directory.
A loader.conf under /etc/systemd/boot/ therefore stayed on the root
partition, where systemd-boot does not read it, and the five second menu
timeout was mkosi's commented-out default instead.

CopyFiles=/boot:/boot in 20-root.conf kept a second copy of the kernel next
to the original. systemd-gpt-auto-generator creates no mount unit for a
directory that already contains files, so the populated /boot made it ignore
the ESP entirely. The kernel and the loader belong on the ESP alone.

The root filesystem came up read-only, and said so in the least helpful way
possible. repart preserves ownership, so a tree built unprivileged lands in
the image owned by the invoking user. /usr/bin/mount is setuid, and a setuid
binary owned by a non-root uid hands that uid to the process even when root
executes it -- mount(8) then refuses with "must be superuser to use mount",
systemd-remount-fs gives up, and every write on the stick fails with EROFS
while the boot log points at the privilege level instead of the mount
option. The write path needs a root-owned tree for this reason alone; the
README says so.
Two ways for the test to look green while checking nothing, both of which
hid every failure above.

The result parser matched ^(PASS|FAIL) against a log where the shell puts a
bracketed-paste marker in front of every line. Not one of the six results in
a real run matched the anchor, so the suite reported "0 checks" -- and the
following condition, which only rejected a non-zero failure count, called
that a pass. Strip the escape sequences first, then anchor, and treat an
empty result as a failure of the harness.

The result loop fed its input with printf '%s', so the last line reached
read() without a trailing newline and was neither printed nor counted. A
failing final check passed unnoticed; one boot produced exactly one result
and zero reported.

On top of that, the checks were aimed at the wrong paths. systemd-gpt-auto-
generator mounts the ESP at /boot and never at /efi, so esp-on-efi could not
pass however healthy the image was. boot-entry-present asked for a .conf that
the type-1 automatic entry never writes; the UKI under EFI/Linux is what
boots, so that is what gets checked. A read-only root now fails as
root-writable, where the message names the mount option instead of sending
after a privilege problem that is not there.

Verified end to end: 21 checks, 0 failures at both 8G and 16G.
The build now produces mkosi.output/debian-rescue-<version>.raw, and write.sh
dd's that file. The tree-plus-mkstick.sh model is gone: setup.sh, mkstick.sh,
lib.sh and rescue/secrets/ with its .gitignore entry, because mkosi copies the
secrets, reparts and resolves the ownership itself.

Why the direction changed, all measured:

repart preserves the ownership of the source tree, so a tree built
unprivileged landed in the image as uid 1000. A setuid binary owned by a
non-root uid hands that uid to the process even when root execs it, mount(8)
refuses with "must be superuser to use mount", systemd-remount-fs gives up and
root stays read-only. chown -R 0:0 is not a way out: it strips every setuid bit
(4755 -> 755). mkosi's Format=disk resolves it, and the build reports
/usr/bin/mount as root:root 4755 and /etc/shadow as root:root 640 in the
running guest.

repart cannot grow an image offline: --size=16G on an 8G image moved the
partition to 15.5 GiB and left btrfs at 7.5 GiB. cp --sparse does not help on a
block device either -- coreutils only makes holes in regular files and falls
back to write_zeros(), the same amount of data as dd. So write.sh is dd,
sequentially, the plainest thing that can touch a block device.

SizeMinBytes=6G -> 3G, measured: the image is 3759161856 bytes (3.5G) with
891.5M consumed, so a stick needs 4 GB. A larger root would only make the write
slower; nothing grows at boot.

RepartDirectories=repart.d hands our definitions to mkosi instead of to a
script we wrote, and ElTorito=no keeps the image UEFI-only. mkosi resolves
CopyFiles= against --root=, which is why repart.d/10-esp.conf still reads the
same and no longer names mkstick.sh.

The build task passes the secrets as --extra-tree from the directory it is
given, defaulting to the fixtures so an ordinary build is harmless and
testable. No intermediate copy and no directory of our own: mkosi reads the
files where they are. It refuses a missing file or a mode that is not 0600,
which is what setup.sh did. copy_tree() keeps "mode,links" even with
preserve=False, so the mode survives, and install_extra_trees() runs
immediately before run_postinst_scripts(), so the hook's install -d -m 0700
still sets /root/.ssh and /etc/wpa_supplicant afterwards.

test.sh is the acceptance test and no longer needs root or a throwaway copy:
neither the unprivileged build nor QEMU touch a device, and nothing mutates
the tree. It boots the artifact with -snapshot so the run does not write back
into it, and reports /usr/bin/mount and /etc/shadow as INFO lines -- not
checks. We do not touch the operating system: the image carries whatever the
packages set.

The root-takes-rest check no longer counts a constant slack. It asserted 2088
sectors measured across repart-built targets; mkosi sizes the image itself and
the constant is 2081, so the check now states the invariant it meant -- the
root ends at the last usable sector of the image.

Verified end to end: 23 checks, 0 failures. A missing secret and a secret at
0644 both abort the build with a message naming the file.
RepartDirectories=repart.d named a directory mkosi already looks for by
convention. mkosi.repart/ needs no setting, and it is the name the vagrant
image already uses, so one convention now covers both images in the
repository.

The default partition definitions cannot be taken instead, though they look
close. mkosi drops all of them as soon as one definition of its own exists --
no partial adoption -- and the default 10-root.conf would be
Format=<distribution-default-fs>, which is ext4 on Debian, where the
rollback needs btrfs, plus Minimize=guess, which would size the root to its
891M of content instead of 3G. Our 10-esp.conf is the default 00-esp.conf
plus a label.

Verified: repart picks up mkosi.repart/ with no setting, 23 checks, 0
failures.
write.sh no longer unmounts anything and no longer measures the stick. Both
blocks were the only code in the script that could act on the device, and
both could fail in the direction that destroys data:

the unmount loop parsed lsblk output, sorted it and called umount on the
result. A mountpoint that lsblk formats differently than the sed expects, or
an empty field that survives the filter, means dd writes onto a mounted
filesystem -- silently, because the kernel writes at device offsets while
the filesystem keeps its own view. Detecting that and then refusing needs
one lsblk call and no action, so the warning replaces the loop: the user
unmounts, and the only thing between the prompt and the device stays the
typed path.

the size check could not destroy anything, but it did have a case worth
having. A stick with 241 MB less than the image fails part-way through dd
with ENOSPC and holds an image that cannot boot. That is now documented as
a caveat instead of caught, which is a real loss and the reviewer's call,
not an improvement.

Verified: usage, root and block-device guards abort in that order. The dd
line itself cannot be exercised here -- no loop driver, and the only real
block device is the internal NVMe.
/root/.bash_history now carries 101 commands from two actual rescues: one that
found an NVMe fallen out of the bus behind LUKS and LVM, one that cloned a
working disk onto a stick and built a replacement system. mkosi.extra/ is copied
as a tree onto /, so this lands at exactly that path with no ExtraTrees and no
hook. HISTFILE is set nowhere in the image, so bash picks the file up by its
default and histappend already appends to it.

The order is importance, and it runs bottom-up. Bash numbers history entries in
file order and the arrow keys walk them newest first, so the newest entry is the
last line: verified with history 1 on a loaded shell, where entry 112 was line
112 of the file. Writing the important commands first would therefore have put
them last on the arrow keys. What the first presses give now:

  3  cat /etc/fstab
  4  lsblk -f
  5  lsblk -o +FSTYPE,LABEL,UUID
  6  lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,UUID,LABEL
  7  dmesg | grep -i nvme

No section headers, because a comment line is a history entry like any other:
with them, presses 7 and 12 landed on "# --- what does this machine look like
---". Only one header survives at the top of the file, which takes a hundred
presses to reach. Blank lines are free -- bash drops them.

The consolidation dropped what a history accumulates instead of a repair:
walls of flag permutations (40 systemd-nspawn lines, the wpa_supplicant
start/enable/status loop), blocks repeated verbatim three times, no-ops, typos
(netow, dmsg, sunc, killall %1), and the debootstrap/apt-install block that
built this image by hand before mkosi did it. Interactive commands are gone too:
cfdisk, vim and poweroff all misbehave when arrow-up hands them to you.

history-ships checks the shell loaded it rather than the file existing, and it
fails on an empty file. It counts matching lines and asks for more than one
instead of grepping for one: the command line itself lands in the history before
it runs, so a plain grep -q matches itself and passes on an empty file.

Verified: 22 checks, 0 failures, and the arrow-key order read back from a shell
that loaded the file.
A comment line is a history entry like any other, so the six header lines at
the top of the file were six presses on the arrow keys that return nothing. My
argument for keeping them was that they sit at the far end of the chain, which
is a reason they are survivable, not a reason they belong there. The note about
the bottom-up order belongs in the README, where it costs nobody a press.
WiFi was missing on the stick and apt upgrade never replaced the kernel.
Both trace back to the build, and the second one hid the first.

firmware-mediatek is only a Recommends of firmware-misc-nonfree, and mkosi
installs with APT::Install-Recommends=false, so firmware-linux never
delivered it. That alone left the mt7925e probe failing with -2. But the
initrd is why installing the package on the stick afterwards did not help:
it carries the whole module tree, a modules.alias mapping the card's
pci:v000014C3d00007925 to mt7925e, and udev, so it loads the driver and
probes it before the root filesystem is there. switch_root does not unload
modules, so the root udev then finds the module already loaded and modprobe
returns without probing again. Installing the package changes the root
filesystem, never the initrd. mkosi mirrors the image's /usr/lib/firmware
into it, so the fix belongs in Packages=, and the initrd now carries all
three mt7925 blobs, WiFi and Bluetooth alike.

UnifiedKernelImages=none stops mkosi building a UKI. systemd-boot sorts
entries that carry a sort key ahead of those that do not, and a UKI always
gets one from ID= in its osrel, so a UKI won every boot against the type 1
entries kernel-install writes -- an upgrade installed a kernel that never
ran. mkosi already nudges kernel-install to type 1 by writing
boot/loader/entries.srel, and the setting overrode it. systemd-boot itself is
untouched and still boots the image, from /EFI/systemd and /EFI/BOOT.

console=ttyS0 moves into the boot entry. test.sh injects a console over
SMBIOS, which does not reach a type 1 boot on trixie's systemd, so the guest
came up healthy in 5.3s and said nothing on the wire -- indistinguishable
from a hang. The image needs the console anyway: it promises a serial login
for the laptop whose screen nobody can see, and without console= systemd
spawns no serial-getty at all.

test.sh: uki-on-esp becomes bls-entries, a check that the MediaTek firmware
is present rather than just the package installed, and the guest timeout
drops to 180s now that boot is 5s. wpa-shared-config matched a flag in the
unit and went red when that unit was rewritten in 2c056b7; it now checks the
property, that every adapter reads the one injected file.

The rollback example pointed at /EFI/Linux/<kernel-name> and one initrd.
The real entry uses /debian/<version>/vmlinuz and two initrds, so following
it as written would not have booted. It also warns that a numeric prefix
sorts ahead of the debian- entries and would become the default.

README: the wpa_supplicant paragraph explained the drop-in rather than
telling the reader which file to edit, and was wrong about how the unit
works. The reader is at a rescue shell and needs the former, not the
mechanism, which the unit's own comment already carries.
Author
Owner

We must add sudo sgdisk -e /dev/sda to the readme or to the writing script.

We must add `sudo sgdisk -e /dev/sda` to the readme or to the writing script.
ses changed title from WIP: feat/rescue-image to feat(rescue): bootable Debian rescue stick 2026-11-01 14:53:54 +00:00
The artifact is built at 3.5 GiB so dd stays quick, but the stick it lands
on is usually bigger and its free space went unused. systemd-growfs only
grows inside partition 2, so the partition itself has to grow first: the
runtime definition in mkosi.extra/etc/repart.d/20-root.conf does that, and
the drop-in keeps systemd-repart ahead of systemd-growfs-root, because the
root filesystem is already mounted by the initrd when the latter runs.

The runtime definition stays out of mkosi.repart/, which is build-time: a
definition there sizes the image itself, and the build must not grow.
systemd reads the drop-in files of a unit directory in lexicographic order,
so the prefix is the sort order. A bare override.conf leaves that implicit.
ses force-pushed feat/rescue-image from fe4ff2c073 to 7450123da3 2026-11-06 17:16:36 +00:00 Compare
ses merged commit 7450123da3 into main 2026-11-06 17:16:51 +00:00
ses deleted branch feat/rescue-image 2026-11-06 17:16:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sebatec-eu/sebatec-images!1
No description provided.