1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

gpt-auto-generator: also honor systemd.swap=no

This commit is contained in:
David Tardon 2023-05-25 09:03:10 +02:00 committed by Daan De Meyer
parent 30765fcb16
commit 9a2982b687
2 changed files with 25 additions and 0 deletions

View File

@ -284,6 +284,14 @@
<citerefentry><refentrytitle>systemd-remount-fs.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>systemd.swap=</varname></term>
<listitem><para>Takes a boolean argument or enables the option if specified without an argument.
If disabled, automatic discovery of swap partition(s) based on GPT partition type is disabled.
Defaults to enabled.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -41,6 +41,7 @@
static const char *arg_dest = NULL;
static bool arg_enabled = true;
static bool arg_root_enabled = true;
static bool arg_swap_enabled = true;
static char *arg_root_fstype = NULL;
static char *arg_root_options = NULL;
static int arg_root_rw = -1;
@ -350,6 +351,9 @@ static int add_partition_swap(DissectedPartition *p) {
assert(p);
assert(p->node);
if (!arg_swap_enabled)
return 0;
/* Disable the swap auto logic if at least one swap is defined in /etc/fstab, see #6192. */
r = fstab_has_fstype("swap");
if (r < 0)
@ -891,6 +895,19 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
else if (proc_cmdline_key_streq(key, "systemd.image_policy"))
return parse_image_policy_argument(optarg, &arg_image_policy);
else if (proc_cmdline_key_streq(key, "systemd.swap")) {
r = value ? parse_boolean(value) : 1;
if (r < 0)
log_warning_errno(r, "Failed to parse swap switch \"%s\", ignoring: %m", value);
else
arg_swap_enabled = r;
if (!arg_swap_enabled)
log_debug("Disabling swap partitions auto-detection, systemd.swap=no is defined.");
}
return 0;
}