snapcore / core-initrd

initrd implementation in ubuntu core
https://ubuntu.com/core/docs
GNU General Public License v3.0
9 stars 27 forks source link

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

Closed valentindavid closed 1 year ago

valentindavid commented 1 year ago

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:

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.