Skip to content

blockdev: Fall back to blkid -p when udev is unavailable#2169

Open
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:fix-no-udev
Open

blockdev: Fall back to blkid -p when udev is unavailable#2169
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:fix-no-udev

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

See osbuild/osbuild#2428

When running inside a container or sandbox without /run/udev bind-mounted (e.g. osbuild's bwrap), lsblk returns null for partition metadata fields like parttype (partition type GUID) and pttype (partition table type), because these come from the udev database.

This causes partition discovery to fail -- most visibly on ppc64le where the PReP partition can't be found by GUID, but also affecting ESP discovery on all architectures. On x86_64 UEFI, bootupd silently falls back to mounted-ESP detection, masking the problem; on ppc64le there is no fallback and the install fails hard.

Add a blkid -p fallback in backfill_missing() that probes partition metadata directly from the disk when udev is absent. The udev check tests for /run/udev/data (the actual database directory) rather than /run/udev, because bootc's ensure_mirrored_host_mount() creates an empty /run/udev directory on the bwrap tmpfs that is_same_as_host() then considers 'already mounted'.

Tested end-to-end via the BIB tmt test (plan-33-bib-build) with a patched bootupd that removes the mounted-ESP fallback entirely.

This follows the same approach coreos-installer uses (PRs #1511, sfdisk-based workaround originally added in PR #688.

Assisted-by: OpenCode (Claude Opus 4)

@bootc-bot bootc-bot Bot requested a review from ckyrouac April 25, 2026 17:30
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a fallback mechanism for block device metadata discovery when the udev database is unavailable, such as within container sandboxes. It introduces blkid -p as a secondary source for partition and table types, updates the Device backfilling logic, and adds new internal CLI subcommands for block device inspection. Feedback was provided to optimize the backfill_missing function by caching the device path to avoid redundant string operations.

Comment thread crates/blockdev/src/blockdev.rs Outdated
@cgwalters cgwalters enabled auto-merge (rebase) April 25, 2026 18:17
See osbuild/osbuild#2428

When running inside a container or sandbox without /run/udev
bind-mounted (e.g. osbuild's bwrap), lsblk returns null for partition
metadata fields like parttype (partition type GUID) and pttype
(partition table type), because these come from the udev database.

This causes partition discovery to fail -- most visibly on ppc64le
where the PReP partition can't be found by GUID, but also affecting
ESP discovery on all architectures. On x86_64 UEFI, bootupd silently
falls back to mounted-ESP detection, masking the problem; on ppc64le
there is no fallback and the install fails hard.

Add a blkid -p fallback in backfill_missing() that probes partition
metadata directly from the disk when udev is absent. The udev check
tests for /run/udev/data (the actual database directory) rather than
/run/udev, because bootc's ensure_mirrored_host_mount() creates an
empty /run/udev directory on the bwrap tmpfs that is_same_as_host()
then considers 'already mounted'.

Tested end-to-end via the BIB tmt test (plan-33-bib-build) with a
patched bootupd that removes the mounted-ESP fallback entirely.

This follows the same approach coreos-installer uses (PRs bootc-dev#1511,
sfdisk-based workaround originally added in PR bootc-dev#688.

Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant