[systemd-devel] [PATCH] fstab-generator: introduce rd.weak_sysroot to bypass failures in sysroot.mount

WANG Chao chaowang at redhat.com
Tue Jul 30 08:31:45 PDT 2013


On 07/30/13 at 09:51am, Vivek Goyal wrote:
> On Tue, Jul 30, 2013 at 07:53:11PM +0800, WANG Chao wrote:
> > If specified kernel command line rd.weak_sysroot, fstab-generate will
> > generate a weaker version of sysroot.mount:
> >  - It's not required by initrd-root-fs.target.
> >  - It's not before initrd-root-fs.target.
> > 
> > So that failure in the weaker sysroot.mount will not fail
> > initrd-root-fs.target. And systemd will try continue rather than
> > entering isolated emergency mode.
> > 
> > Signed-off-by: WANG Chao <chaowang at redhat.com>
> 
> Chao, so why rd.action_on_fail=continue is not sufficient here? So if
> mounting root fails, and if rd.action_on_fail=continue, then systemd
> should just continue.

rd.action_on_fail is a check condition switch for
dracut-emergency.service. It only controls whether the emergency service
can be started or not.

If sysroot.mount fails, initrd-root-fs.target won't be reached. Our
kdump script running under dracut-pre-pivot.service, which has a
dependency list:

dracut-pre-pivot.service
 -> initrd.target
  -> initrd-root-fs.target
   -> sysroot.mount

If rd.action_on_fail=continue isn't set, a failing sysroot.mount will
trigger emergency service and emergency service is started. Kdump fails.

If rd.action_on_fail=continue is set, a failing sysroot.mount will also
trigger emergency service, but emergency service wouldn't be started.
Because that service is switched off and can't be started. Then systemd
will hang (we haven't reached initrd-root-fs.target yet) because the
left services will only run after initrd-root-fs.target.

> 
> Or it will be considered an initramfs parameter and we need to come
> up with a new one for systemd?

dracut can't do it. systemd is hard-coded to mount root (sysroot.mount).

> 
> Or may be if rd.action_on_fail is set, it automtically does some
> action which conveys to systemd to continue after failures.

rd.action_on_fail is just simply mask emergency.service. It can't let
systemd continue against failures.

Thanks,
WANG Chao

> 
> Thanks
> Vivek
> 
> > ---
> >  man/kernel-command-line.xml           | 10 ++++++++++
> >  man/systemd-fstab-generator.xml       | 10 ++++++++++
> >  src/fstab-generator/fstab-generator.c |  5 ++++-
> >  3 files changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
> > index a4b7d13..0c2e97d 100644
> > --- a/man/kernel-command-line.xml
> > +++ b/man/kernel-command-line.xml
> > @@ -274,6 +274,16 @@
> >                          </varlistentry>
> >  
> >                          <varlistentry>
> > +                                <term><varname>rd.weak_sysroot</varname></term>
> > +
> > +                                <listitem>
> > +                                        <para>Configures the sysroot.mount
> > +                                        logic in initrd. For details, see
> > +                                        <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
> > +                                </listitem>
> > +                        </varlistentry>
> > +
> > +                        <varlistentry>
> >                                  <term><varname>modules-load=</varname></term>
> >                                  <term><varname>rd.modules-load=</varname></term>
> >  
> > diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml
> > index 4bd25bf..de0ed2f 100644
> > --- a/man/systemd-fstab-generator.xml
> > +++ b/man/systemd-fstab-generator.xml
> > @@ -101,6 +101,16 @@
> >                                  the initrd.  </para></listitem>
> >                          </varlistentry>
> >  
> > +                        <varlistentry>
> > +                                <term><varname>rd.weak_sysroot</varname></term>
> > +
> > +                                <listitem><para>If specified, systemd will
> > +                                ingore failures in sysroot.mount and try to
> > +                                continue rather than enter emergency mode.
> > +                                It is honored only by initial RAM disk
> > +                                (initrd). </para></listitem>
> > +                        </varlistentry>
> > +
> >                  </variablelist>
> >          </refsect1>
> >  
> > diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
> > index c17299f..449e725 100644
> > --- a/src/fstab-generator/fstab-generator.c
> > +++ b/src/fstab-generator/fstab-generator.c
> > @@ -492,6 +492,7 @@ static int parse_new_root_from_proc_cmdline(void) {
> >          char *w, *state;
> >          int r;
> >          size_t l;
> > +        bool weak = false;
> >  
> >          r = read_one_line_file("/proc/cmdline", &line);
> >          if (r < 0) {
> > @@ -544,6 +545,8 @@ static int parse_new_root_from_proc_cmdline(void) {
> >  
> >                          free(opts);
> >                          opts = o;
> > +                } else if (streq(word, "rd.weak_sysroot")) {
> > +                        weak=true;
> >                  }
> >          }
> >  
> > @@ -558,7 +561,7 @@ static int parse_new_root_from_proc_cmdline(void) {
> >          }
> >  
> >          log_debug("Found entry what=%s where=/sysroot type=%s", what, type);
> > -        r = add_mount(what, "/sysroot", type, opts, 0, false, false, false,
> > +        r = add_mount(what, "/sysroot", type, opts, 0, false, weak, false,
> >                        false, NULL, NULL, NULL, SPECIAL_INITRD_ROOT_FS_TARGET, "/proc/cmdline");
> >  
> >          return (r < 0) ? r : 0;
> > -- 
> > 1.8.3.1


More information about the systemd-devel mailing list