Works for me... booted with "ro" on the kernel cmdline: $ systemctl status systemd-fsck-root.service ● systemd-fsck-root.service - File System Check on Root Device Loaded: loaded (/usr/lib/systemd/system/systemd-fsck-root.service; static; vendor preset: disabled) Active: inactive (dead) since Mi 2015-05-06 15:37:58 CEST; 1min 44s ago Docs: man:systemd-fsck-root.service(8) Main PID: 144 (code=exited, status=0/SUCCESS) CGroup: /system.slice/systemd-fsck-root.service
[ 1.440568] systemd[1]: Starting Root File System Check Placeholder... [ 1.445484] systemd[1]: Started Root File System Check Placeholder. […] [ 1.786864] systemd[1]: Starting File System Check on /dev/gpt-auto-root... [ 1.804183] systemd[1]: Started File System Check on /dev/gpt-auto-root. [ 2.015962] systemd[1]: Mounting /sysroot... […] [ 2.294428] systemd[1]: Switching root. […] [ 2.570286] systemd[1]: Stopped Switch Root. […] [ 2.571714] systemd[1]: Stopped File System Check on Root Device. [ 2.571859] systemd[1]: Stopping File System Check on Root Device... […] [ 2.624669] systemd[1]: Started Remount Root and Kernel File Systems. Although "Stopping File System Check on Root Device" is strange... On 06.05.2015 07:26, Zbigniew Jędrzejewski-Szmek wrote: > In the initramfs, we run systemd-fsck@<sysroot-device>.service. > In the real system we run systemd-fsck-root.service. Generate > a fake systemd-fsck-root.service if we are running a unit check > for the root file system. We don't really care if the real fsck unit > fails, because the failure will be handled in some other way. > > This fake unit is created and pulled in only when we actually plan to > check the file system for /sysroot. This way we avoid having an > active/exited systemd-fsck-root.service in the main filesystem if > we didn't do anything. > > https://bugzilla.redhat.com/show_bug.cgi?id=1201979 > > C.f. 956eaf2b8d6c9999024705ddadc7393bc707de02. > --- > Something like this? > > TODO | 5 ----- > src/shared/generator.c | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 30 insertions(+), 5 deletions(-) > > diff --git a/TODO b/TODO > index 430a354e84..cc827701f0 100644 > --- a/TODO > +++ b/TODO > @@ -113,9 +113,6 @@ Features: > * Maybe add support for the equivalent of "ethtool advertise" to .link files? > http://lists.freedesktop.org/archives/systemd-devel/2015-April/030112.html > > -* fstab-generator should generate systemd-fsck-root.service when > - running in the initrd, and operate on the right device. > - > * .timer units should optionally support CLOCK_BOOTTIME in addition to > CLOCK_MONOTONIC > > * create a btrfs qgroup for /var/lib/machines, and add all container > @@ -153,8 +150,6 @@ Features: > * Introduce $LISTEN_NAMES to complement $LISTEN_FDS, containing a > colon separated list of identifiers for the fds passed. > > -* when the fstab-generator runs in the initrd, it should create a /dev/null > mask for systemd-fsck-root.service, to avoid that the the root fs is fsck'ed > twice. > - > * maybe introduce WantsMountsFor=? Usecase: > > http://lists.freedesktop.org/archives/systemd-devel/2015-January/027729.html > > diff --git a/src/shared/generator.c b/src/shared/generator.c > index 2dc34bf738..813ce1af9a 100644 > --- a/src/shared/generator.c > +++ b/src/shared/generator.c > @@ -28,8 +28,32 @@ > #include "generator.h" > #include "path-util.h" > #include "fstab-util.h" > +#include "fileio.h" > #include "dropin.h" > > +static int write_fsck_root_service(const char *dir) { > + const char *unit; > + int r; > + > + unit = strjoina(dir, "/systemd-fsck-root.service"); > + log_debug("Creating %s.", unit); > + > + r = write_string_file_atomic(unit, > + "# Automatically generated by a systemd-fstab-generator or > similar\n\n" > + "[Unit]\n" > + "Description=Root File System Check Placeholder\n" > + "DefaultDependencies=no\n" > + "Before=shutdown.target\n" > + "\n" > + "[Service]\n" > + "ExecStart=/bin/true\n" > + "Type=oneshot\n" > + "RemainAfterExit=yes\n"); > + if (r < 0) > + log_warning_errno(errno, "Failed to write unit file %s: %m", > unit); > + return r; > +} > + > int generator_write_fsck_deps( > FILE *f, > const char *dir, > @@ -79,6 +103,12 @@ int generator_write_fsck_deps( > "RequiresOverridable=%1$s\n" > "After=%1$s\n", > fsck); > + > + if (in_initrd() && path_equal(where, "/sysroot")) { > + (void) write_fsck_root_service(dir); > + fprintf(f, > + "Wants=systemd-fsck-root.service\n"); > + } > } > > return 0; > _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel