> Can you test whether this compiles and fixes #782522 ? Done that now, the patch works for me. And #782522 remains fixed for initramfs-tools. (Actually I tested a slightly modified version of the patch, with debug output. Attached.)
> Not sure if we also need to address #782522 for dracut, i.e., how can we > generate the flag file when systemd generates the fsck service in the > initramfs? It seems this is not needed for /usr, systemd is smart enough to remember that the file system has already been checked. But the name of the fsck service changes for the root file system between initramfs and main system, therefore it is still checked twice with dracut+systemd.
From: Michael Biebl <bi...@debian.org> Date: Fr, 15 Jan 2016 07:03:23 +0200 Subject: [PATCH] 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. Closes: #782522 --- 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 cb3d9dc..1557fb2 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -188,6 +188,7 @@ static int add_mount( *filtered = NULL; _cleanup_fclose_ FILE *f = NULL; int r; + struct stat sb; assert(what); assert(where); @@ -241,9 +242,13 @@ static int add_mount( fprintf(f, "Before=%s\n", post); if (passno != 0) { - r = generator_write_fsck_deps(f, arg_dest, what, where, fstype); - if (r < 0) - return r; + if (streq(where, "/usr") && stat("/run/initramfs/fsck-usr", &sb) == 0) + log_info("Skipping fsck for /usr as it has been checked already."); + else { + r = generator_write_fsck_deps(f, arg_dest, what, where, fstype); + if (r < 0) + return r; + } } fprintf(f, diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in index 4162983..0668107 100644 --- a/units/systemd-fsck-root.service.in +++ b/units/systemd-fsck-root.service.in @@ -13,6 +13,7 @@ After=systemd-readahead-collect.service systemd-readahead-replay.service Before=local-fs.target shutdown.target ConditionPathIsReadWrite=!/ +ConditionPathExists=!/run/initramfs/fsck-root [Service] Type=oneshot