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?
Yes ;) Let me test 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 [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
