summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-21 09:47:46 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-21 22:15:02 +0100
commitcf451f382a6ebf6ad34b36939ed4f8dee1c04e61 (patch)
treedf7342798ef1450b96cde6e8771fe58c45f79fc9
parentec6267e8620845bad7b402a0689b425f8ca44fe5 (diff)
downloadsystemd-cf451f382a6ebf6ad34b36939ed4f8dee1c04e61.tar.gz
gpt-auto-generator: honour rootfstype= and rootflags= kernel cmdline option
Even if root= is not specified on the kernel cmdline, we should honour the other rootXYZ= options. Fixes: #8411 See: #17034
-rw-r--r--man/kernel-command-line.xml13
-rw-r--r--man/systemd-gpt-auto-generator.xml12
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c24
3 files changed, 40 insertions, 9 deletions
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index fcab0a90f4..545dc40798 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -336,11 +336,16 @@
<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>
diff --git a/man/systemd-gpt-auto-generator.xml b/man/systemd-gpt-auto-generator.xml
index 3b166b87f9..4ccc80994d 100644
--- a/man/systemd-gpt-auto-generator.xml
+++ b/man/systemd-gpt-auto-generator.xml
@@ -244,10 +244,16 @@
<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>
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index f2f6cc1a53..d697a9b362 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -40,8 +40,13 @@
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)