Skip to content

kexec-iso-init: improve hybrid ISO detection and boot param handling#2083

Draft
tlaurion wants to merge 10 commits intolinuxboot:masterfrom
tlaurion:iso-boot-detection
Draft

kexec-iso-init: improve hybrid ISO detection and boot param handling#2083
tlaurion wants to merge 10 commits intolinuxboot:masterfrom
tlaurion:iso-boot-detection

Conversation

@tlaurion
Copy link
Copy Markdown
Collaborator

@tlaurion tlaurion commented Apr 12, 2026

Summary

Fixes #2008 - boot hybrid ISOs (PureOS, Ubuntu, Tails, NixOS, Kicksecure, etc.) directly from ISO file on USB without needing to dd the ISO to a raw USB device.

Changes

Tested (works in QEMU/Heads):

  • kexec-parse-boot.sh: Fix boot entries not appearing for hybrid ISOs
    • check_path() no longer fails on ISO-mounted files (FUSE-visible but not kernel-level)
    • TAB-indented GRUB configs now parsed correctly
    • Leading whitespace stripped before extracting cmd/val
    • case $trimcmdcase $cmd in syslinux_entry
    • GRUB --- bootloader marker stripped from append params
    • syslinux_end handles initrd= via ${param#initrd=}
    • set -e exits on normal conditions fixed (grep -q, blkid, etc.)
  • kexec-parse-bls.sh: Same TAB/whitespace/trim fixes
  • functions.sh: Skip EFI boot configs (irrelevant on coreboot)
  • unpack_initramfs.sh: Handle set -e exits
  • kexec-boot.sh: Fix cmdadd append ordering
  • kexec-select-boot.sh: Fix initrd path detection

Untested (needs QEMU/hardware boot test):

  • kexec-iso-init: Inject casper-premount script into ISO initrd
    • mounts ISO as loopback at /run/initramfs/iso_mount/ before casper runs
    • fixes subshell isolation via /run/initramfs/livemedia.env
    • patches casper to source livemedia.env after premount scripts
    • creates casper-premount/ORDER so run_scripts executes the script
    • passes live-media=$MOUNTED_ISO_PATH (ISO file path)
    • passes iso-scan/auto=true

Testing

Parser test harness at tests/iso-parser-test.sh validates all 13 ISOs parse correctly.

Live boot test pending: PureOS 10.3 GNOME on QEMU/Heads — verify these logs:

  • DEBUG: Successfully injected casper-premount/iso_mount into initrd
  • Running /scripts/casper-premountiso_mount script
  • Should get past "Unable to find a live file system" panic

Copilot AI review requested due to automatic review settings April 12, 2026 16:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ISO-on-USB boot compatibility detection and improved UX/logging around kexec-based booting, including documentation of supported ISO behaviors.

Changes:

  • Add initrd/GRUB scanning and USB filesystem compatibility checks for ISO-file boot, with user warnings on likely failures.
  • Improve boot option selection UX and display of applied kernel parameter add/remove operations.
  • Log the final kernel command line in debug output and document the ISO boot flow + compatibility matrix.

Reviewed changes

Copilot reviewed 1 out of 4 changed files in this pull request and generated no comments.

File Description
initrd/bin/kexec-select-boot.sh Simplifies menu display and improves confirmation/add/remove parameter UX.
initrd/bin/kexec-iso-init.sh Adds ISO boot-method detection, USB FS probing, initrd capability heuristics, and broader distro parameter support.
initrd/bin/kexec-boot.sh Refactors option parsing and adds debug logging of the final kernel cmdline.
doc/boot-process.md Documents “Stage 2b” ISO-on-USB boot flow and known compatibility results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tlaurion tlaurion force-pushed the iso-boot-detection branch from b4b1383 to cb30626 Compare April 12, 2026 17:04
@tlaurion tlaurion changed the title initrd: add ISO boot detection, USB filesystem validation, and distro kernel params initrd: add ISO boot detection and USB filesystem validation Apr 12, 2026
@tlaurion tlaurion force-pushed the iso-boot-detection branch 2 times, most recently from d810864 to d5b268c Compare April 12, 2026 19:43
@tlaurion tlaurion marked this pull request as draft April 12, 2026 19:43
@tlaurion tlaurion force-pushed the iso-boot-detection branch from 29fb8da to ab2fc17 Compare April 12, 2026 20:14
@tlaurion tlaurion closed this Apr 13, 2026
@tlaurion tlaurion force-pushed the iso-boot-detection branch from ab2fc17 to 8f78967 Compare April 13, 2026 00:32
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 13, 2026
- Add check_hybrid_iso() using MBR signature at offset 510 (0x55AA)
- Add detect_iso_boot_method() to extract boot params from initrd via strings
- Add inspect_iso_boot_config() to extract boot params from GRUB configs
- Simplify header to document Dracut vs Anaconda boot methods
- Use DEBUG level for NOTE/WARN/STATUS spam per logging.md
- Change terminal prompts to [Y,d] style with Enter defaulting to yes
- Remove Anaconda blocking - let user attempt boot (Qubes R4.3 works)
- Keep combined boot params approach (let ISO initrd pick what it needs)

Tested with Qubes R4.3 on Q35 QEMU (works).

Ref: linuxboot#2083, linuxboot#2008
@tlaurion tlaurion changed the title initrd: add ISO boot detection and USB filesystem validation kexec-iso-init: improve hybrid ISO detection and boot param handling Apr 13, 2026
@tlaurion tlaurion reopened this Apr 13, 2026
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 13, 2026
Add resolve_grub_vars() to substitute GRUB variables like ${iso_path}
and ${isofile} with the actual ISO path when extracting boot params
from GRUB configs.

Fixes boot failure where iso-scan/filename=${iso_path} wasn't being
resolved to the actual ISO path.

Ref: linuxboot#2083
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 13, 2026
Add resolve_grub_vars() to substitute GRUB variables like ${iso_path}
and ${isofile} with the actual ISO path when extracting boot params
from GRUB configs.

Fixes boot failure where iso-scan/filename=${iso_path} wasn't being
resolved to the actual ISO path.

Ref: linuxboot#2083
@tlaurion tlaurion force-pushed the iso-boot-detection branch from 90f3faf to 16b9805 Compare April 13, 2026 00:44
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 13, 2026
Add TRACE/DEBUG to understand how boot parameters flow through
kexec-boot.sh, especially the cmdline and cmdadd parameters.

Ref: linuxboot#2083
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 15, 2026
- Add check_hybrid_iso() using MBR signature at offset 510 (0x55AA)
- Add detect_iso_boot_method() to extract boot params from initrd via strings
- Add inspect_iso_boot_config() to extract boot params from GRUB configs
- Simplify header to document Dracut vs Anaconda boot methods
- Use DEBUG level for NOTE/WARN/STATUS spam per logging.md
- Change terminal prompts to [Y,d] style with Enter defaulting to yes
- Remove Anaconda blocking - let user attempt boot (Qubes R4.3 works)
- Keep combined boot params approach (let ISO initrd pick what it needs)

Tested with Qubes R4.3 on Q35 QEMU (works).

Ref: linuxboot#2083, linuxboot#2008
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 15, 2026
Add resolve_grub_vars() to substitute GRUB variables like ${iso_path}
and ${isofile} with the actual ISO path when extracting boot params
from GRUB configs.

Fixes boot failure where iso-scan/filename=${iso_path} wasn't being
resolved to the actual ISO path.

Ref: linuxboot#2083
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
@tlaurion tlaurion force-pushed the iso-boot-detection branch from 594c17f to f17cf57 Compare April 15, 2026 18:04
tlaurion added a commit to tlaurion/heads that referenced this pull request Apr 15, 2026
Add TRACE/DEBUG to understand how boot parameters flow through
kexec-boot.sh, especially the cmdline and cmdadd parameters.

Ref: linuxboot#2083
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- Add check_hybrid_iso() using MBR signature at offset 510 (0x55AA)
- Add detect_iso_boot_method() to extract boot params from initrd via strings
- Add inspect_iso_boot_config() to extract boot params from GRUB configs
- Simplify header to document Dracut vs Anaconda boot methods
- Use DEBUG level for NOTE/WARN/STATUS spam per logging.md
- Change terminal prompts to [Y,d] style with Enter defaulting to yes
- Remove Anaconda blocking - let user attempt boot (Qubes R4.3 works)
- Keep combined boot params approach (let ISO initrd pick what it needs)

Tested with Qubes R4.3 on Q35 QEMU (works).

Ref: linuxboot#2083, linuxboot#2008
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Add resolve_grub_vars() to substitute GRUB variables like ${iso_path}
and ${isofile} with the actual ISO path when extracting boot params
from GRUB configs.

Fixes boot failure where iso-scan/filename=${iso_path} wasn't being
resolved to the actual ISO path.

Ref: linuxboot#2083
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Add TRACE/DEBUG to understand how boot parameters flow through
kexec-boot.sh, especially the cmdline and cmdadd parameters.

Ref: linuxboot#2083
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Fixes linuxboot#2008 - boot hybrid ISOs (PureOS, Ubuntu, Tails,
NixOS, Kicksecure, etc.) directly from ISO file on USB without needing
to dd the ISO to a raw USB device.

Key fixes (TESTED):
- kexec-parse-boot: check_path() no longer fails on ISO-mounted files
  (which exist via FUSE but not at kernel level during initrd execution)
- kexec-parse-boot: fix TAB-indented GRUB configs and leading whitespace
  stripping (sed 's/^[[:space:]]*//' before extracting cmd/val)
- kexec-parse-boot: fix case \$trimcmd -> case \$cmd in syslinux_entry
  (trimcmd includes full line; cmd is just the command word)
- kexec-parse-boot: strip GRUB '---' bootloader marker from append params
- kexec-parse-boot: syslinux_end handles initrd= via \${param#initrd=}
- kexec-parse-boot: fix set -e exits on normal conditions (grep -q, etc.)
- kexec-parse-bls.sh: same TAB/whitespace/trim fixes
- functions.sh: skip EFI boot configs (irrelevant on coreboot platforms)
- unpack_initramfs.sh: handle set -e exits from grep/blkid
- kexec-boot.sh: fix cmdadd append ordering in adjust_cmd_line()
- kexec-select-boot.sh: fix initrd path detection

Key fixes (UNTESTED - needs QEMU/hardware boot test):
- kexec-iso-init: inject casper-premount script into ISO initrd
  (mounts ISO as loopback at /run/initramfs/iso_mount/ before casper runs)
- kexec-iso-init: fix subshell isolation via /run/initramfs/livemedia.env
  (casper's run_scripts runs scripts in subshells; export doesn't propagate)
- kexec-iso-init: patch casper to source livemedia.env after premount
- kexec-iso-init: create casper-premount/ORDER so run_scripts executes script
- kexec-iso-init: pass live-media=\$MOUNTED_ISO_PATH (ISO file path)
- kexec-iso-init: pass iso-scan/auto=true

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
…m support

- Add scan_initramfs() to detect filesystem drivers (ext4, vfat, exfat, etc.)
  and boot methods (iso-scan, live-media, boot=live, boot=casper, etc.)
- Add detect_initrd_boot_support() to scan initrds from parsed boot entries
- Add extract_boot_params_from_cfg() to scan *.cfg files for boot params
- Warn if USB filesystem is not supported by ISO initramfs
- Warn if no boot method detected, offer to try anyway
- Keep ADD params matching origin/master (fromiso=/dev/disk/by-uuid/...)

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- Use unpack_initramfs.sh to extract initrds
- Detect what boot params each ISO's initramfs understands
- Show init script name and relevant lines for debugging

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Add live-media=/dev/disk/by-uuid/.../path/to/iso.iso and live-media-path=casper
to ADD params. PureOS casper initramfs needs live-media= pointing to the ISO
file path, not /boot. This complements existing fromiso=, iso-scan/filename=,
img_loop=, and iso= params.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- Fix duplicate iso-scan/filename parameter injection
- Add deduplication to cfg boot method extraction
- Add selective parameter injection (boot=live, boot=casper, live-media)
- Add header comments to kexec-iso-init.sh, kexec-parse-boot.sh, kexec-boot.sh
- Add param injection validation to test suite
- Fix Tails boot parameter regression (was injecting boot=casper incorrectly)
- Show boot params in boot menu options
@tlaurion
Copy link
Copy Markdown
Collaborator Author

this is way too complex. look at u-root/u-root#3578

- Simplify parameter injection to always inject iso-scan/filename as primary
- Add installer ISO detection (warns user to use dd instead)
- Remove Ventoy recommendations (not supported by Heads)
- Keep USB filesystem check from initrd scanning
@tlaurion tlaurion force-pushed the iso-boot-detection branch from f17cf57 to ca51e23 Compare April 22, 2026 17:50
- Add ISO boot documentation to development.md
- Fix kexec-parse-boot.sh path in sim_iso_menu.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"kicksecure iso doesn't boot under Heads

2 participants