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)
committerMichael Biebl <biebl@debian.org>
Sat, 25 Jan 2020 17:53:23 +0000 (17:53 +0000)
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 6fd6fbdf1ccdf542b8cf6ae6b7ac3a16d36ff723..3679fad9298b0023d6609a669561a945d1018f1c 100644 (file)
@@ -308,6 +308,7 @@ static int add_mount(
                 *where_escaped = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
+        struct stat sb;
 
         assert(what);
         assert(where);
@@ -391,9 +392,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 bea6c168af18a07eff1447fe95fa609146fb5a89..49df0316ae6687df226ec7d5642ef377395e361e 100644 (file)
@@ -16,6 +16,7 @@ Before=local-fs.target shutdown.target
 Wants=systemd-fsckd.socket
 After=systemd-fsckd.socket
 ConditionPathIsReadWrite=!/
+ConditionPathExists=!/run/initramfs/fsck-root
 
 [Service]
 Type=oneshot