Skip to content

dracut_functions.sh: make sure device UUIDs are correct before creating systemd device units - #1918

Draft
Cyanoxygen wants to merge 1 commit into
dracut-ng:mainfrom
AOSC-Tracking:aosc/upstream/verify-uuid
Draft

dracut_functions.sh: make sure device UUIDs are correct before creating systemd device units#1918
Cyanoxygen wants to merge 1 commit into
dracut-ng:mainfrom
AOSC-Tracking:aosc/upstream/verify-uuid

Conversation

@Cyanoxygen

Copy link
Copy Markdown
Contributor

Sometimes the information read from udev may be outdated, for example a disk has just got repartitioned. We don't know why this happens, but it is better to verify the unique identifiers before returning from get_persistent_dev().

We compare the ID provided by get_persistent_dev() and the probed result of blkid. If they don't match, we use the latter one.

This inconsistency is observed during initramfs generation stage of the OS installation, and can not be reproduced reliably, and may be platform dependent. It results in an unbootable OS, stuck at initrd trying to wait a nonexistant UUID.

This pull request adds a verification to confirm the device UUID we are going to wait for during the initramfs actually is correct. @MingcongBai can provide some details on the issue this PR is going to fix.

Changes

  • dracut-functions.sh: verify device UUID before creating device units for the initramfs

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

@Cyanoxygen
Cyanoxygen requested a review from a team as a code owner December 5, 2025 15:10
@Cyanoxygen Cyanoxygen changed the title dracut_functions.sh: confirm if the UUID matches before returning dracut_functions.sh: confirm if the UUID matches before creating systemd device units Dec 5, 2025
@Cyanoxygen
Cyanoxygen force-pushed the aosc/upstream/verify-uuid branch from df67a3a to 7d5a622 Compare December 6, 2025 07:13
Sometimes the information read from udev may be outdated, for example a
disk has just got repartitioned. We don't know why this happens, but it
is better to make sure the unique identifiers are correct before returning
from get_persistent_dev(), preventing it from waiting an non-existant
device later on.

We compare the ID provided by get_persistent_dev() and the probed
result from blkid. If they don't match, we use the latter one.

This inconsistency is observed during initramfs generation stage of the
OS installation. It results in an unbootable OS, stuck at initrd trying
to wait a nonexistant UUID.

Signed-off-by: Xinhui Yang <cyan@cyano.uk>
@Cyanoxygen
Cyanoxygen force-pushed the aosc/upstream/verify-uuid branch from 7d5a622 to fda1678 Compare December 6, 2025 07:15
@MingcongBai

Copy link
Copy Markdown
Contributor

This issue is actually quite weird, sometimes as though U-Dev had some sort of "cache" in place for devices. I ran into this whilst installing AOSC OS, which runs dracut at the end of installation in a chroot - the disk was repartitioned, but the resulting initramfs contains /dev/disk entries that reflects the disk before it was repartitioned.

I can confirm that this patch fixes the issue I ran into, but it could also be worth looking into why U-Dev did not refresh the device paths immediately.

@Cyanoxygen

Copy link
Copy Markdown
Contributor Author

why U-Dev did not refresh the device paths immediately.

Then we should dive into systemd-udevd then, or should we manually trigger the refresh?

@Cyanoxygen

Cyanoxygen commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

Oh well. A quickly written script showed that udev sometimes doesn't drop the old records, or won't update the symlinks in /dev/disk on time.

I have a whole bunch of broken ones too:

image

So, reading from udev may be unreliable, we can either add an additional step to make sure they are correct, or switch to using blkid --probe entirely.

@Cyanoxygen Cyanoxygen changed the title dracut_functions.sh: confirm if the UUID matches before creating systemd device units dracut_functions.sh: make sure device UUIDs are correct before creating systemd device units Dec 8, 2025
@Conan-Kudo

Copy link
Copy Markdown
Collaborator

Is there a bug filed with systemd about this?

@Cyanoxygen

Copy link
Copy Markdown
Contributor Author

Is there a bug filed with systemd about this?

No AFAIK. Do you think we should treat this as an upstream issue?

@jozzsi

jozzsi commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Do you think we should treat this as an upstream issue?

First yes, please.

@Conan-Kudo
Conan-Kudo marked this pull request as draft December 14, 2025 22:26
@Conan-Kudo

Copy link
Copy Markdown
Collaborator

Marking as draft until we get feedback from systemd folks.

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.

4 participants