summaryrefslogtreecommitdiffstats
path: root/debian/patches/debian/Skip-filesystem-check-if-already-done-by-the-initram.patch
blob: c8192750f770fc010b0343184928e7dc8172acc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From: Nis Martensen <nis.martensen@web.de>
Date: Tue, 19 Jan 2016 22:01:43 +0100
Subject: Skip filesystem check if already done by the initramfs

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
---
 src/fstab-generator/fstab-generator.c | 11 ++++++++---
 units/systemd-fsck-root.service.in    |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 63f0f36..8b3c732 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -368,6 +368,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);
@@ -455,9 +456,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);
diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in
index 4b1cd43..07590fd 100644
--- a/units/systemd-fsck-root.service.in
+++ b/units/systemd-fsck-root.service.in
@@ -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