diff options
author | Scott Lamb <slamb@slamb.org> | 2021-07-21 10:03:49 -0700 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-11-10 11:58:12 +0100 |
commit | 4b499063acd64c7d5249a110d8eb7dc23d7b3e2b (patch) | |
tree | 0200fcb4786be7d337b0b530564f2886eae5084b | |
parent | 899acf5c2d4b89caa891d05ccfa4be828a999c2d (diff) | |
download | systemd-4b499063acd64c7d5249a110d8eb7dc23d7b3e2b.tar.gz |
fsck: no emergency.target on nofail mounts
Also describe failure behavior more precisely in the manpage.
Fixes #20237.
-rw-r--r-- | man/systemd-fsck@.service.xml | 15 | ||||
-rw-r--r-- | src/fsck/fsck.c | 7 | ||||
-rw-r--r-- | units/systemd-fsck-root.service.in | 2 |
3 files changed, 16 insertions, 8 deletions
diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml index 035382913f..aa0d8b12ae 100644 --- a/man/systemd-fsck@.service.xml +++ b/man/systemd-fsck@.service.xml @@ -55,9 +55,18 @@ the filesystem should actually be checked based on the time since last check, number of mounts, unclean unmount, etc.</para> - <para>If a file system check fails for a service without - <option>nofail</option>, emergency mode is activated, by isolating - to <filename>emergency.target</filename>.</para> + <para><filename>systemd-fsck-root.service</filename> will activate + <filename>reboot.target</filename> if <filename>/sbin/fsck</filename> + returns the "System should reboot" condition, or + <filename>emergency.target</filename> if <filename>/sbin/fsck</filename> + returns the "Filesystem errors left uncorrected" condition.</para> + + <para><filename>systemd-fsck@.service</filename> will fail if + <filename>/sbin/fsck</filename> returns with either "System should reboot" + or "Filesystem errors left uncorrected" conditions. For filesystems + listed in <filename>/etc/fstab</filename> without <literal>nofail</literal> + or <literal>noauto</literal> options, <literal>local-fs.target</literal> + will then activate <filename>emergency.target</filename>.</para> </refsect1> <refsect1> diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index cd7adfaeb9..745d01ff50 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -52,7 +52,7 @@ static void start_target(const char *target, const char *mode) { return; } - log_info("Running request %s/start/replace", target); + log_info("Running request %s/start/%s", target, mode); /* Start these units only if we can replace base.target with it */ r = sd_bus_call_method(bus, @@ -412,10 +412,7 @@ static int run(int argc, char *argv[]) { /* System should be rebooted. */ start_target(SPECIAL_REBOOT_TARGET, "replace-irreversibly"); return -EINVAL; - } else if (exit_status & (FSCK_SYSTEM_SHOULD_REBOOT | FSCK_ERRORS_LEFT_UNCORRECTED)) - /* Some other problem */ - start_target(SPECIAL_EMERGENCY_TARGET, "replace"); - else + } else if (!(exit_status & (FSCK_SYSTEM_SHOULD_REBOOT | FSCK_ERRORS_LEFT_UNCORRECTED))) log_warning("Ignoring error."); } diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in index 6897f13159..8378df84c7 100644 --- a/units/systemd-fsck-root.service.in +++ b/units/systemd-fsck-root.service.in @@ -14,6 +14,8 @@ DefaultDependencies=no Conflicts=shutdown.target Before=local-fs.target shutdown.target ConditionPathIsReadWrite=!/ +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly [Service] Type=oneshot |