]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto-generator: honour rootfstype= and rootflags= kernel cmdline option
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Dec 2022 08:47:46 +0000 (09:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Dec 2022 21:15:02 +0000 (22:15 +0100)
Even if root= is not specified on the kernel cmdline, we should honour
the other rootXYZ= options.

Fixes: #8411
See: #17034

man/kernel-command-line.xml
man/systemd-gpt-auto-generator.xml
src/gpt-auto-generator/gpt-auto-generator.c

index fcab0a90f40a6d3ec5c155eaf05200733467bac0..545dc40798ae803bab86783f64bf155069b1f64d 100644 (file)
         <term><varname>rw</varname></term>
 
         <listitem>
-          <para>Configures the root file system and its file system
-          type and mount options, as well as whether it shall be
-          mounted read-only or read-write initially. For details,
-          see
+          <para>Configures the root file system and its file system type and mount options, as well as
+          whether it shall be mounted read-only or read-write initially. For details, see
           <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+
+          <para>If <varname>root=</varname> is not set (or set to <literal>gpt-auto</literal>) the automatic
+          root partition discovery implemented by
+          <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+          will be in effect. In this case <varname>rootfstype=</varname>, <varname>rootflags=</varname>,
+          <varname>ro</varname>, <varname>rw</varname> will be interpreted by
+          <command>systemd-gpt-auto-generator</command>.</para>
         </listitem>
       </varlistentry>
 
index 3b166b87f90dbad02d745874cead8d837d1a6e8a..4ccc80994d0a0bbaaaf164f5e78c78580eab3c0f 100644 (file)
 
       <varlistentry>
         <term><varname>root=</varname></term>
+        <term><varname>rootfstype=</varname></term>
+        <term><varname>rootflags=</varname></term>
 
-        <listitem><para>When used with the special value <literal>gpt-auto</literal>, automatic discovery of
-        the root partition based on the GPT partition type is enabled.  Any other value disables this
-        generator.</para></listitem>
+        <listitem><para>When <varname>root=</varname> is used with the special value
+        <literal>gpt-auto</literal> (or if the parameter is not used at all), automatic discovery of the root
+        partition based on the GPT partition type is enabled. Any other value disables this
+        logic.</para>
+
+        <para>The <varname>rootfstype=</varname> and <varname>rootflags=</varname> are used to select the
+        file system type and options when the root file system is automatically discovered.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index f2f6cc1a53d901c9e2fc147acc7b75795dea165c..d697a9b362ca15737ccd345faa9ea5a7e2973e05 100644 (file)
 static const char *arg_dest = NULL;
 static bool arg_enabled = true;
 static bool arg_root_enabled = true;
+static char *arg_root_fstype = NULL;
+static char *arg_root_options = NULL;
 static int arg_root_rw = -1;
 
+STATIC_DESTRUCTOR_REGISTER(arg_root_fstype, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_root_options, freep);
+
 static int add_cryptsetup(
                 const char *id,
                 const char *what,
@@ -622,10 +627,10 @@ static int add_root_mount(void) {
                         "root",
                         "/dev/gpt-auto-root",
                         in_initrd() ? "/sysroot" : "/",
-                        NULL,
+                        arg_root_fstype,
                         /* rw= */ arg_root_rw > 0,
                         /* growfs= */ false,
-                        NULL,
+                        arg_root_options,
                         "Root Partition",
                         in_initrd() ? SPECIAL_INITRD_ROOT_FS_TARGET : SPECIAL_LOCAL_FS_TARGET);
 #else
@@ -801,6 +806,21 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
 
                 arg_root_enabled = false;
 
+        } else if (streq(key, "rootfstype")) {
+
+                if (proc_cmdline_value_missing(key, value))
+                        return 0;
+
+                return free_and_strdup_warn(&arg_root_fstype, value);
+
+        } else if (streq(key, "rootflags")) {
+
+                if (proc_cmdline_value_missing(key, value))
+                        return 0;
+
+                if (!strextend_with_separator(&arg_root_options, ",", value))
+                        return log_oom();
+
         } else if (proc_cmdline_key_streq(key, "rw") && !value)
                 arg_root_rw = true;
         else if (proc_cmdline_key_streq(key, "ro") && !value)