Skip filesystem check if already done by the initramfs
authorNis Martensen <nis.martensen@web.de>
Tue, 19 Jan 2016 21:01:43 +0000 (22:01 +0100)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 20 Sep 2018 22:47:19 +0000 (23:47 +0100)
Newer versions of initramfs-tools already fsck and mount / and /usr in
the initramfs. Skip the filesystem check in this case.

Based on a previous patch by Michael Biebl <biebl@debian.org>.

Closes: #782522
Closes: #810748
Gbp-Pq: Topic debian
Gbp-Pq: Name Skip-filesystem-check-if-already-done-by-the-initram.patch

src/fstab-generator/fstab-generator.c
units/systemd-fsck-root.service.in

index 482229b4a53fd3cccdce03f904de7bf43d49d69b..1a7281e08d536f3478b4d9e3dab0c29e2db1aa80 100644 (file)
@@ -300,6 +300,7 @@ static int add_mount(
                 *where_escaped = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
+        struct stat sb;
 
         assert(what);
         assert(where);
@@ -377,9 +378,13 @@ static int add_mount(
         }
 
         if (passno != 0) {
-                r = generator_write_fsck_deps(f, dest, what, where, fstype);
-                if (r < 0)
-                        return r;
+                if (streq(where, "/usr") && stat("/run/initramfs/fsck-usr", &sb) == 0)
+                        ; /* skip /usr fsck if it has already been checked in the initramfs */
+                else {
+                        r = generator_write_fsck_deps(f, dest, what, where, fstype);
+                        if (r < 0)
+                                return r;
+                }
         }
 
         fprintf(f, "\n[Mount]\n");
index 3cc60e5b997d8bae920ad37274a8f2763b596123..172a952d6d9aa097d466674f22b0f88f783e247a 100644 (file)
@@ -15,6 +15,7 @@ Wants=systemd-fsckd.socket
 Before=local-fs.target shutdown.target
 After=systemd-fsckd.socket
 ConditionPathIsReadWrite=!/
+ConditionPathExists=!/run/initramfs/fsck-root
 
 [Service]
 Type=oneshot