]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fsck: no emergency.target on nofail mounts
authorScott Lamb <slamb@slamb.org>
Wed, 21 Jul 2021 17:03:49 +0000 (10:03 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Nov 2021 10:58:12 +0000 (11:58 +0100)
Also describe failure behavior more precisely in the manpage.
Fixes #20237.

man/systemd-fsck@.service.xml
src/fsck/fsck.c
units/systemd-fsck-root.service.in

index 035382913f3ea48eba837b73788dbea3f9cc1e01..aa0d8b12aed1a11b0d6d8985507ca0835fde9d0c 100644 (file)
     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>
index cd7adfaeb962aa37947ec5e63447c9058aa719ad..745d01ff502f50f77802e98dc0617868559cedb7 100644 (file)
@@ -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.");
         }
 
index 6897f13159e97831a224c9006a8400693e0fb84d..8378df84c71887bf1843de4b533de5cf3aa4f9a5 100644 (file)
@@ -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