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, 2 Jan 2024 10:44:49 +0000 (11:44 +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 016f3baa7f849fe566763ba0e2c83c696601a647..f63a1d1470dbbfa4fb2bd15a59bd6be6b12967fc 100644 (file)
@@ -519,6 +519,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);
@@ -604,9 +605,13 @@ static int add_mount(
                 fprintf(f, "Before=%s\n", target_unit);
 
         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 ca9c7cefb3bccbf158141b05b2cf2d60ff2a2e2b..27783a9c824288518cce44f3fcfdf8e0f167f195 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
 OnFailure=emergency.target
 OnFailureJobMode=replace-irreversibly