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>
Thu, 18 Mar 2021 19:59:14 +0000 (19:59 +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 55a8242fcfc40d90321b2eb5343fe6b727455854..777ae5f49159daa7a1de53b69e5e91cb63888419 100644 (file)
@@ -310,6 +310,7 @@ static int add_mount(
                 *where_escaped = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
+        struct stat sb;
 
         assert(what);
         assert(where);
@@ -387,9 +388,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