Skip to content

dissect: turn systemd-dissect into a plugin for udev that creates symlinks for dissected partitions - #36209

Closed
poettering wants to merge 4 commits into
systemd:mainfrom
poettering:dissect-udev-probe
Closed

poettering wants to merge 4 commits into
systemd:mainfrom
poettering:dissect-udev-probe

Conversation

@poettering

Copy link
Copy Markdown
Member

No description provided.

… with explicit property

So far udev-builtin-blkid only marked the root partition of the main
block device we booted from. Let's also mark the main block device
explicitly. This is later useful to use as property to run the
dissect_id plugin on.
All other rules in 99-systemd.rules are pretty much concerned about
SYSTEMD_READY=1 and tagging devices the service manager shall track. But
the gpt-root symlink is different, and it makes sense independently of
the service manager. Hence give it a separate file.
…ection symlinks

benefits:

* can eventually take image policies into accounts
* works for all designators
* understands versioning
* understands architecture matching
* gpt-auto-generator and root fs logic use the same dissection logic
@github-actions github-actions Bot added build-system meson please-review PR is ready for (re-)review by a maintainer labels Jan 28, 2025
@septatrix

septatrix commented Jan 28, 2025 •

Copy link
Copy Markdown
Contributor

Will this support dm_verity protected partitions? Currently they seem to be somewhat broken with dissect (#34807). I apologize if this question does not apply - I just know that some parts (e.g. mounting) of sd-dissect are broken with verity protection (which in turn breaks sd-repart - #32029) and would like to know if this is affected by that or still works

@yuwata yuwata left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you split out the main dissect logic to shared/dissect-image.c ? Then, please introduce udev-builtin-dissect.c, rather than reusing systemd-dissect. Why? Several merits:

  • we do not need to install systemd-dissect in initrd (even on the main system, if people want),
  • we can use sd_device_open(), which verifies DISKSEQ,
  • we can directly set/import properties through udev_builtin_add_property() and friends, rather than printing to stdout and parse it.

Please add test cases for the new feature.

Comment thread rules.d/90-image-dissect.rules Resolved
Comment thread src/dissect/dissect.c Resolved
@yuwata yuwata added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Jan 29, 2025
# If this is a partition, and we found something on the parent, then copy the right properties from the parent, and rename them
ENV{DEVTYPE}=="partition", ENV{ID_DISSECT_IMAGE}!="", IMPORT{program}="dissect_id --copy $devnode"

ENV{DEVTYPE}=="partition", ENV{ID_DISSECT_PART_DESIGNATOR}!="", SYMLINK+="gpt-auto-$env{ID_DISSECT_PART_DESIGNATOR}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think disk/by-parttype/ as implemented in #28894 is way more descriptive and well-organized than laying all these directly in /dev/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

well, my goal here was to not introduce new naming, but to just mildly extend the naming of the existing /dev/gpt-auto-root symlink

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

or to say this differently, this is a natural extension of the existing /dev/gpt-auto-root logic, just with a bunch more partitions.

i think the /dev/disk/by-* is kinda important if we basically unbounded number of devices in there. But this is different, the number of symlinks we'll create here is bounded by the number of designators, which is pretty low. hence I think we can get away with following the current naming scheme and extending it a tiny bit for the other designators, and don't have to introduce something entirely new.

@poettering

Copy link
Copy Markdown
Member Author

Closing, a new version is #36631

@poettering poettering closed this Mar 6, 2025
@poettering

Copy link
Copy Markdown
Member Author

Will this support dm_verity protected partitions? Currently they seem to be somewhat broken with dissect (#34807). I apologize if this question does not apply - I just know that some parts (e.g. mounting) of sd-dissect are broken with verity protection (which in turn breaks sd-repart - #32029) and would like to know if this is affected by that or still works

hmm? dm-verity works perfectly her with dissect.

but you do have to specify a roothash or place it in a file next to the image.

@github-actions github-actions Bot removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Mar 6, 2025
@septatrix

Copy link
Copy Markdown
Contributor

hmm? dm-verity works perfectly her with dissect.

but you do have to specify a roothash or place it in a file next to the image.

I can only speak from my experience in the issues I referenced where stuff did not seem to work. At least sd-repart uses dissect under the hood and I cannot pass a roothash to sd-repart so I am not sure how this is supposed to work. For some weird reasons however ParticleOS does not seem to have problems with that even though they use a similar setup. I am not sure if this might depend on the order of hash partition and hash data partition.

poettering added a commit that referenced this pull request Apr 3, 2025
…ks based on partition designators (#36631)

This replaces #36209 and implements this via a new builtin, rather than
by shelling out to systemd-dissect.

Replaces: #36209 
Replaces: #28894
Fixes: #34319 
Fixes: #33453 
Fixes: #27897
Fixes: #18035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants