} 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);
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");
}
fprintf(f,
- "Requires=%1$s\n"
- "After=%1$s\n",
- fsck);
+ "%1$s=%2$s\n"
+ "After=%2$s\n",
+ dep, fsck);
}
return 0;