chiark / gitweb /
fsck-root: only run when requested in fstab
authorTom Gundersen <teg@jklm.no>
Sat, 19 Oct 2013 09:38:42 +0000 (11:38 +0200)
committerTom Gundersen <teg@jklm.no>
Sat, 19 Oct 2013 10:23:17 +0000 (12:23 +0200)
fsck-root is redundant in case an initrd is used, or in case the rootfs
is never remounted 'rw', so the new default is the correct behavior for
most users. For the rest, they should enable it in fstab.

Makefile.am
man/systemd-fsck@.service.xml
src/fstab-generator/fstab-generator.c

index ca01179e82e0e3b360eabfe9363241ea79594807..a29a32a5d2d5de2f66d62fc419278a5a99d287c8 100644 (file)
@@ -4447,7 +4447,6 @@ SYSINIT_TARGET_WANTS += \
        systemd-update-utmp.service
 LOCAL_FS_TARGET_WANTS += \
        systemd-remount-fs.service \
-       systemd-fsck-root.service \
        tmp.mount
 MULTI_USER_TARGET_WANTS += \
        getty.target \
index 17bd1c027b898d138501a573c3bd91c74be3fdbb..811392b19ad0853254148fba1a8da72b647550a1 100644 (file)
@@ -63,7 +63,9 @@
                 check. <filename>systemd-fsck-root.service</filename> is
                 responsible for file system checks on the root
                 file system. The root file system check is performed
-                before the other file systems.</para>
+                before the other file systems. Either service is enabled
+                at boot if passno in <filename>/etc/fstab</filename> for
+                the filesystem is set to a value greater than zero.</para>
 
                 <para><filename>systemd-fsck</filename> will
                 forward file system checking progress to the
index 77247dee5e786bab7a68cd9cbfe264d926cb0d0b..78d7609c6c14b83842f9eabe118cb0bda4b17454 100644 (file)
@@ -210,17 +210,29 @@ static int add_mount(
                         post);
 
         if (passno > 0) {
-                _cleanup_free_ char *fsck = NULL;
+                if (streq(where, "/")) {
+                        lnk = strjoin(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET, ".wants/", "systemd-fsck-root.service", NULL);
+                        if (!lnk)
+                                return log_oom();
 
-                fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
-                if (!fsck)
-                        return log_oom();
+                        mkdir_parents_label(lnk, 0755);
+                        if (symlink("systemd-fsck-root.service", lnk) < 0) {
+                                log_error("Failed to create symlink %s: %m", lnk);
+                                return -errno;
+                        }
+                } else {
+                        _cleanup_free_ char *fsck = NULL;
 
-                fprintf(f,
-                        "Requires=%s\n"
-                        "After=%s\n",
-                        fsck,
-                        fsck);
+                        fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
+                        if (!fsck)
+                                return log_oom();
+
+                        fprintf(f,
+                                "Requires=%s\n"
+                                "After=%s\n",
+                                fsck,
+                                fsck);
+                }
         }
 
 
@@ -248,6 +260,7 @@ static int add_mount(
 
         if (!noauto) {
                 if (post) {
+                        free(lnk);
                         lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
                         if (!lnk)
                                 return log_oom();