mirror of
https://github.com/systemd/systemd.git
synced 2024-11-24 10:43:35 +08:00
fstab-generator: handle systemd.swap= command-line argument
Don't generate swap units if set to false The inverse of this argument is present as "noswap" on Debian sysvinit Ref:4422988cb4/debian/vars.sh (L34)
4422988cb4/debian/src/initscripts/etc/init.d/mountall.sh (L78)
Fixes https://github.com/systemd/systemd/issues/6686
This commit is contained in:
parent
392a2d5148
commit
567a530760
@ -198,6 +198,15 @@
|
||||
automatically populate <filename>/etc</filename>, and also <filename>/var</filename> in case of
|
||||
<literal>systemd.volatile=yes</literal>.</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, causes the generator to ignore
|
||||
any swap devices configured in <filename>/etc/fstab</filename>.
|
||||
Defaults to enabled.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -40,6 +40,7 @@ typedef enum MountpointFlags {
|
||||
static const char *arg_dest = NULL;
|
||||
static const char *arg_dest_late = NULL;
|
||||
static bool arg_fstab_enabled = true;
|
||||
static bool arg_swap_enabled = true;
|
||||
static char *arg_root_what = NULL;
|
||||
static char *arg_root_fstype = NULL;
|
||||
static char *arg_root_options = NULL;
|
||||
@ -98,6 +99,11 @@ static int add_swap(
|
||||
assert(what);
|
||||
assert(me);
|
||||
|
||||
if (!arg_swap_enabled) {
|
||||
log_info("Swap unit generation disabled on kernel command line, ignoring fstab swap entry for %s.", what);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (access("/proc/swaps", F_OK) < 0) {
|
||||
log_info("Swap not supported, ignoring fstab swap entry for %s.", what);
|
||||
return 0;
|
||||
@ -896,6 +902,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
arg_volatile_mode = m;
|
||||
} else
|
||||
arg_volatile_mode = VOLATILE_YES;
|
||||
|
||||
} else if (streq(key, "systemd.swap")) {
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r < 0)
|
||||
log_warning("Failed to parse systemd.swap switch %s. Ignoring.", value);
|
||||
else
|
||||
arg_swap_enabled = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user