Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Persist device mapper devices in udev database #203

Conversation

valentindavid
Copy link
Collaborator

Note that while we do not plan to bring systemd re-exec in UC20, this fix does fix the state of dev mapper devices. Without this fix, they are disabled with SYSTEMD_READY=0 while being dependencies of inferred mount units, which can be problematic in some cases.

The following is the commit message:

55-dm.rules will disable cold plugged device mapper block devices. In order for it not to disable them we need to keep the state from initrd to main boot. That is we need to mark the devices as persist_db so that initrd-udevadm-cleanup-db.service does not remove it.

When a device mapper device gets disabled, then all systemd mounts with BindsTo to the device will get unmounted, as well as all bind mounts that depend on it. Which causes a catastrophic failure of Ubuntu Core.

As a work-around for this issue we have used a stateless reexecution of systemd. This was making systemd forget about encrypted mount units and thus did not trigger unmount when devices were taken down.

Now that we mark the device mapper devices as persist_db, this work-around is not needed anymore.

Tested on:

  • qemu x86_64 without secure boot
  • qemu x86_64 with secure boot
  • intel nuc with secure boot
  • raspberry pi 4

The mounts in /proc/mounts are the same as before the fix, except than now systemd-mount --list properly lists device mapper mounts.

This commit does not contain the removal of the stateless reexecutil work around.

55-dm.rules will disable cold plugged device mapper block devices.  In
order for it not to disable them we need to keep the state from initrd
to main boot. That is we need to mark the devices as `persist_db` so
that initrd-udevadm-cleanup-db.service does not remove it.

When a device mapper device gets disabled, then all systemd mounts
with BindsTo to the device will get unmounted, as well as all bind
mounts that depend on it. Which causes a catastrophic failure of
Ubuntu Core.

As a work-around for this issue we have used a stateless reexecution
of systemd. This was making systemd forget about encrypted mount units
and thus did not trigger unmount when devices were taken down.

Now that we mark the device mapper devices as `persist_db`, this
work-around is not needed anymore.

Tested on:
 - qemu x86_64 without secure boot
 - qemu x86_64 with secure boot
 - intel nuc with secure boot
 - raspberry pi 4

The mounts in `/proc/mounts` are the same as before the fix, except
than now `systemd-mount --list` properly lists device mapper mounts.

This commit does not contain the removal of the stateless reexecutil
work around.
Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@alfonsosanchezbeato alfonsosanchezbeato merged commit f8215f1 into canonical:core20 Aug 22, 2023
1 check passed
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.

2 participants