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>
Tue, 12 Oct 2021 20:39:59 +0000 (21:39 +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 b6582c9538ac15077a4791c08b8139db1c1b1b60..e1a1200649c007ef79a51910522cc5b444793f29 100644 (file)
@@ -357,6 +357,7 @@ static int add_mount(
         _cleanup_strv_free_ char **wanted_by = NULL, **required_by = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         int r;
+        struct stat sb;
 
         assert(what);
         assert(where);
@@ -440,9 +441,13 @@ static int add_mount(
                 fprintf(f, "Before=%s\n", post);
 
         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;
+                }
         }
 
         r = generator_write_blockdev_dependency(f, what);
index cfdb086f922d96e788ba6c00f8fb3f17db5a0f85..36f3981b841e69e95d6c2188aa1fc768acf4f5b7 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