Skip to content

initramfs: Require bootc-root-setup for initrd-root-fs.target - #2667

Merged
jmarrero merged 1 commit into
bootc-dev:mainfrom
jmarrero:initramfs-require-root-setup
Nov 20, 2026
Merged

jmarrero merged 1 commit into
bootc-dev:mainfrom
jmarrero:initramfs-require-root-setup

Conversation

@jmarrero

@jmarrero jmarrero commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The dracut module linked bootc-root-setup.service into initrd-root-fs.target.wants, so a failure of the service did not fail the target. On a sealed composefs image with root locked, the emergency shell returns at once and the boot could continue to switch-root into an unverified /sysroot. Link the service into initrd-root-fs.target.requires instead, so a failure fails the target and switch-root cannot happen until the service has succeeded. Also document the failure behaviour, including rd.shell=0.

This is the fix from the temporary private fork for GHSA-9889-q45r-84v7, re-raised as a public PR because required status checks cannot run in advisory forks. The commit is cherry-picked unchanged from that fork and was already approved there by @cgwalters and me. Authored by Arsslen Idadi.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:05
@github-actions github-actions Bot added the area/documentation Updates to the documentation label Nov 19, 2026
@bootc-bot
bootc-bot Bot requested a review from gursewak1997 November 19, 2026 19:06
@jmarrero
jmarrero requested a review from cgwalters November 19, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Missing VM validation leaves unconfirmed whether root-setup failures block switch-root after locked-root emergency-shell exit or with rd.shell=0, and whether recovery retries work on supported dracut/systemd versions.

No open issues 🎉

What changed in this PR

This PR makes composefs root setup a required initramfs dependency, preventing boot from continuing into an unverified /sysroot when setup fails.

Changes:

  • Changes the dracut dependency from Wants to Requires for bootc-root-setup.service.
  • Documents failure handling, emergency-shell behavior, and the rd.shell=0 option.
File Description
docs/​src/​man/​bootc-root-setup.service.5.md Documents setup failures, retries, and dracut emergency options.
docs/​src/​bootc-boot-failure-detection.7.md Clarifies boot failure behavior and links to the service manual.
crates/​initramfs/​dracut/​module-setup.sh Installs the service under initrd-root-fs.target.requires.
crates/​initramfs/​bootc-root-setup.service Adds comments explaining the required dependency; no functional unit changes.

Review effort: Balanced

The dracut module linked bootc-root-setup.service into
initrd-root-fs.target.wants, so a failure of the service did not fail
the target. The failure isolates emergency.target, and dracut's
emergency.service starts the default target again when the shell exits.
On an image with root locked, sulogin returns at once, so with the
default rd.shell the default target is started again and the service is
retried. Once systemd's start rate limit (5 starts in 10 s by default)
refuses a restart, the unit stays failed, OnFailure= does not fire
again, and the boot goes on: initrd-root-fs.target is reached without
the service, initrd-parse-etc.service runs, and the initramfs switches
root into /sysroot without the composefs image ever having been mounted
or verified. On a sealed image that defeats the guarantee the signed
composefs digest is meant to give.

Link the service into initrd-root-fs.target.requires instead. The
service is already ordered before the target, so a failure now fails
the target, including a start refused by the rate limit, since start
failure propagates to units that require the failed unit.
initrd-parse-etc.service, whose OnSuccess= is the only way to
initrd-cleanup.service and switch-root in a systemd initramfs, requires
the target, so switch-root cannot happen until the service has
succeeded. Starting the default target again after the emergency shell
retries the service rather than skipping it.

Document the behaviour on failure, including that rd.shell=0 makes
dracut power off (or follow rd.emergency=) instead of offering a shell.

Tested by hand: a dracut initramfs built with the module now carries
initrd-root-fs.target.requires/bootc-root-setup.service and no .wants
link. A stand-in reproduction under systemd 259, with units carrying
the same dependencies as initrd-root-fs.target,
initrd-parse-etc.service, initrd-cleanup.service and dracut's
emergency.service, and a setup unit that always fails, confirmed that
with the .wants link the boot can reach switch-root after the emergency
shell, and that with the .requires link the target stays inactive and
switch-root never runs. The rate-limit mechanism itself follows from
source analysis of systemd. Not tested in a booted VM.

Generated-by: AI
Signed-off-by: Arsslen Idadi <[email protected]>
Signed-off-by: Joseph Marrero Corchado <[email protected]>
@jmarrero
jmarrero force-pushed the initramfs-require-root-setup branch from ea31a8e to bff0d7d Compare November 19, 2026 19:46
@jmarrero
jmarrero enabled auto-merge (rebase) November 19, 2026 20:09
@jmarrero jmarrero mentioned this pull request Nov 19, 2026
@jmarrero
jmarrero merged commit 3a4b3d1 into bootc-dev:main Nov 20, 2026
136 of 143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants