From dc16846c26287fd2081eb3c4a73487c9b186e2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 1 Jun 2021 08:05:03 +0200 Subject: [PATCH 1/2] units: stop automount unit when shutting down This is currently our only .automount unit. We wouldn't want to trigger it accidentally during shutdown, so let's stop it too. --- units/proc-sys-fs-binfmt_misc.automount | 1 + 1 file changed, 1 insertion(+) diff --git a/units/proc-sys-fs-binfmt_misc.automount b/units/proc-sys-fs-binfmt_misc.automount index a71e249976..172c8757ab 100644 --- a/units/proc-sys-fs-binfmt_misc.automount +++ b/units/proc-sys-fs-binfmt_misc.automount @@ -13,6 +13,7 @@ Documentation=https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.htm Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems DefaultDependencies=no Before=sysinit.target +Conflicts=shutdown.target ConditionPathExists=/proc/sys/fs/binfmt_misc/ ConditionPathIsReadWrite=/proc/sys/ From 294eace024b0e6c34cb64e3bb4f8958bb98ee00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 7 Jun 2021 13:29:19 +0200 Subject: [PATCH 2/2] core: disable "update" units in the initramfs Initially I wanted to add ConditionPathExists=!/etc/initrd-release in various units (ldconfig.service, systemd-sysusers.service, systemd-hwdb-update.service, systemd-journal-catalog-update, systemd-update-done.service), but I think it's better to just disable the mechanism in the initrd altogether. Initrd images are put together in a very particular way, and there is not need to do post-update steps on them. If a unit from some other package winds up in the initrd, we wouldn't want to invoke it either. Also, any modifications are ephemeral, so any update would happen on every use. And finally, initrd images are all about speed, and we shouldn't invoke any unneeded services. --- src/shared/condition.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/condition.c b/src/shared/condition.c index d4d9eacc4b..b86312548d 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -675,6 +675,11 @@ static int condition_test_needs_update(Condition *c, char **env) { if (r > 0) return b; + if (in_initrd()) { + log_debug("We are in an initrd, not doing any updates."); + return false; + } + if (!path_is_absolute(c->parameter)) { log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c->parameter); return true;