diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 6d8c873ca5..7355b135e9 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -131,11 +131,15 @@
umount.target in order to be stopped during shutdown.
Mount units referring to local file systems automatically gain
- an After= dependency on local-fs-pre.target.
+ an After= dependency on local-fs-pre.target, and a
+ Before= dependency on local-fs.target unless
+ mount option is set.
Network mount units
automatically acquire After= dependencies on remote-fs-pre.target,
- network.target and network-online.target. Towards the latter a
+ network.target and network-online.target, and gain a
+ Before= dependency on remote-fs.target unless
+ mount option is set. Towards the latter a
Wants= unit is added as well.
diff --git a/src/core/mount.c b/src/core/mount.c
index 6df5d60ee1..be02e05f09 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -453,6 +453,7 @@ static int mount_add_default_dependencies(Mount *m) {
const char *after, *before;
UnitDependencyMask mask;
MountParameters *p;
+ bool nofail;
int r;
assert(m);
@@ -471,6 +472,7 @@ static int mount_add_default_dependencies(Mount *m) {
return 0;
mask = m->from_fragment ? UNIT_DEPENDENCY_FILE : UNIT_DEPENDENCY_MOUNTINFO_DEFAULT;
+ nofail = m->from_fragment ? fstab_test_yes_no_option(m->parameters_fragment.options, "nofail\0" "fail\0") : false;
if (mount_is_network(p)) {
/* We order ourselves after network.target. This is
@@ -501,9 +503,11 @@ static int mount_add_default_dependencies(Mount *m) {
before = SPECIAL_LOCAL_FS_TARGET;
}
- r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true, mask);
- if (r < 0)
- return r;
+ if (!nofail) {
+ r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, before, true, mask);
+ if (r < 0)
+ return r;
+ }
r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, after, true, mask);
if (r < 0)