From afacf3fc8af0090620383228c6c84345ad63b6f8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Jul 2019 16:18:28 +0200 Subject: [PATCH] =?utf8?q?generator:=20downgrade=20Requires=3D=20=E2=86=92?= =?utf8?q?=20Wants=3D=20of=20fsck=20from=20/usr=20mount=20unit?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes #5099 --- src/shared/generator.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/shared/generator.c b/src/shared/generator.c index 6524d98..5b57168 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -164,7 +164,7 @@ int generator_write_fsck_deps( } else { _cleanup_free_ char *_fsck = NULL; - const char *fsck; + const char *fsck, *dep; if (in_initrd() && path_equal(where, "/sysroot")) { r = write_fsck_sysroot_service(dir, what); @@ -172,7 +172,15 @@ int generator_write_fsck_deps( return r; fsck = SPECIAL_FSCK_ROOT_SERVICE; + dep = "Requires"; } else { + /* When this is /usr, then let's add a Wants= dependency, otherwise a Requires= + * dependency. Why? We can't possibly unmount /usr during shutdown, but if we have a + * Requires= from /usr onto a fsck@.service unit and that unit is shut down, then + * we'd have to unmount /usr too. */ + + dep = !in_initrd() && path_equal(where, "/usr") ? "Wants" : "Requires"; + r = unit_name_from_path_instance("systemd-fsck", what, ".service", &_fsck); if (r < 0) return log_error_errno(r, "Failed to create fsck service name: %m"); @@ -181,9 +189,9 @@ int generator_write_fsck_deps( } fprintf(f, - "Requires=%1$s\n" - "After=%1$s\n", - fsck); + "%1$s=%2$s\n" + "After=%2$s\n", + dep, fsck); } return 0; -- 2.7.4