Merge pull request #14177 from keszybz/use-initrd.target
Use initrd.target in the initramfs
This commit is contained in:
commit
b51d61fec6
|
@ -38,6 +38,7 @@
|
|||
<filename>hibernate.target</filename>,
|
||||
<filename>hybrid-sleep.target</filename>,
|
||||
<filename>suspend-then-hibernate.target</filename>,
|
||||
<filename>initrd.target</filename>,
|
||||
<filename>initrd-fs.target</filename>,
|
||||
<filename>initrd-root-device.target</filename>,
|
||||
<filename>initrd-root-fs.target</filename>,
|
||||
|
@ -202,14 +203,16 @@
|
|||
<varlistentry>
|
||||
<term><filename>default.target</filename></term>
|
||||
<listitem>
|
||||
<para>The default unit systemd starts at bootup. Usually,
|
||||
this should be aliased (symlinked) to
|
||||
<filename>multi-user.target</filename> or
|
||||
<filename>graphical.target</filename>.</para>
|
||||
<para>The default unit systemd starts at bootup. Usually, this should be aliased (symlinked) to
|
||||
<filename>multi-user.target</filename> or <filename>graphical.target</filename>. See
|
||||
<citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
|
||||
more discussion.</para>
|
||||
|
||||
<para>The default unit systemd starts at bootup can be
|
||||
overridden with the <varname>systemd.unit=</varname> kernel
|
||||
command line option.</para>
|
||||
<para>The default unit systemd starts at bootup can be overridden with the
|
||||
<varname>systemd.unit=</varname> kernel command line option, or more conveniently, with the short
|
||||
names like <varname>single</varname>, <varname>rescue</varname>, <varname>1</varname>,
|
||||
<varname>3</varname>, <varname>5</varname>, …; see
|
||||
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -341,6 +344,15 @@
|
|||
is active as long as the system is running.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><filename>initrd.target</filename></term>
|
||||
<listitem>
|
||||
<para>This is the default target in the initramfs, similar to <filename>default.target</filename>
|
||||
in the main system. It is used to mount the real root and transition to it. See
|
||||
<citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
|
||||
more discussion.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><filename>initrd-fs.target</filename></term>
|
||||
<listitem>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#define SPECIAL_DEFAULT_TARGET "default.target"
|
||||
#define SPECIAL_INITRD_TARGET "initrd.target"
|
||||
|
||||
/* Shutdown targets */
|
||||
#define SPECIAL_UMOUNT_TARGET "umount.target"
|
||||
|
|
|
@ -1997,20 +1997,36 @@ static int do_queue_default_job(
|
|||
const char **ret_error_message) {
|
||||
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
const char* default_unit;
|
||||
Job *default_unit_job;
|
||||
Unit *target = NULL;
|
||||
int r;
|
||||
|
||||
log_debug("Activating default unit: %s", arg_default_unit);
|
||||
if (arg_default_unit)
|
||||
default_unit = arg_default_unit;
|
||||
else if (in_initrd())
|
||||
default_unit = SPECIAL_INITRD_TARGET;
|
||||
else
|
||||
default_unit = SPECIAL_DEFAULT_TARGET;
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, arg_default_unit, NULL, &target);
|
||||
log_debug("Activating default unit: %s", default_unit);
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, default_unit, NULL, &target);
|
||||
if (r < 0 && in_initrd() && !arg_default_unit) {
|
||||
/* Fall back to default.target, which we used to always use by default. Only do this if no
|
||||
* explicit configuration was given. */
|
||||
|
||||
log_info("Falling back to " SPECIAL_DEFAULT_TARGET ".");
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, SPECIAL_DEFAULT_TARGET, NULL, &target);
|
||||
}
|
||||
if (r < 0) {
|
||||
log_info("Falling back to rescue target: " SPECIAL_RESCUE_TARGET);
|
||||
log_info("Falling back to " SPECIAL_RESCUE_TARGET ".");
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, SPECIAL_RESCUE_TARGET, NULL, &target);
|
||||
if (r < 0) {
|
||||
*ret_error_message = r == -ERFKILL ? "Rescue target masked"
|
||||
: "Failed to load rescue target";
|
||||
*ret_error_message = r == -ERFKILL ? SPECIAL_RESCUE_TARGET " masked"
|
||||
: "Failed to load " SPECIAL_RESCUE_TARGET;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
@ -2222,15 +2238,6 @@ static int load_configuration(
|
|||
return r;
|
||||
}
|
||||
|
||||
/* Initialize default unit */
|
||||
if (!arg_default_unit) {
|
||||
arg_default_unit = strdup(SPECIAL_DEFAULT_TARGET);
|
||||
if (!arg_default_unit) {
|
||||
*ret_error_message = "Failed to set default unit";
|
||||
return log_oom();
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the show status setting if it hasn't been set explicitly yet */
|
||||
if (arg_show_status == _SHOW_STATUS_INVALID)
|
||||
arg_show_status = SHOW_STATUS_YES;
|
||||
|
|
|
@ -126,7 +126,15 @@ static int generate_wants_symlinks(void) {
|
|||
|
||||
STRV_FOREACH(u, arg_wants) {
|
||||
_cleanup_free_ char *p = NULL, *f = NULL;
|
||||
const char *target = arg_default_unit ?: SPECIAL_DEFAULT_TARGET;
|
||||
const char *target;
|
||||
|
||||
/* This should match what do_queue_default_job() in core/main.c does. */
|
||||
if (arg_default_unit)
|
||||
target = arg_default_unit;
|
||||
else if (in_initrd())
|
||||
target = SPECIAL_INITRD_TARGET;
|
||||
else
|
||||
target = SPECIAL_DEFAULT_TARGET;
|
||||
|
||||
p = strjoin(arg_dest, "/", target, ".wants/", *u);
|
||||
if (!p)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "sd-event.h"
|
||||
#include "sd-journal.h"
|
||||
|
||||
#include "time-util.h"
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
|
||||
#include "sd-dhcp-server.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dhcp-internal.h"
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include "fd-util.h"
|
||||
#include "in-addr-util.h"
|
||||
#include "io-util.h"
|
||||
#include "sd-id128.h"
|
||||
#include "siphash24.h"
|
||||
#include "string-util.h"
|
||||
#include "unaligned.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "generator.h"
|
||||
#include "mkdir.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "special.h"
|
||||
#include "specifier.h"
|
||||
#include "strv.h"
|
||||
|
||||
|
@ -116,7 +117,7 @@ static int generate(void) {
|
|||
return log_error_errno(r, "Failed to create unit file %s: %m", p);
|
||||
|
||||
/* And now redirect default.target to our new target */
|
||||
p = strjoina(arg_dest, "/default.target");
|
||||
p = strjoina(arg_dest, "/" SPECIAL_DEFAULT_TARGET);
|
||||
if (symlink("kernel-command-line.target", p) < 0)
|
||||
return log_error_errno(errno, "Failed to link unit file kernel-command-line.target → %s: %m", p);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef struct BusWaitForJobs BusWaitForJobs;
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include "io-util.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "io-util.h"
|
||||
#include "time-util.h"
|
||||
|
||||
/* Make sure not to make this smaller than the maximum coredump size.
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
#include <errno.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "bus-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "def.h"
|
||||
#include "env-util.h"
|
||||
#include "log.h"
|
||||
#include "process-util.h"
|
||||
#include "sd-bus.h"
|
||||
#include "signal-util.h"
|
||||
#include "special.h"
|
||||
|
||||
static int reload_manager(sd_bus *bus) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
|
@ -57,7 +59,7 @@ static int start_default_target(sd_bus *bus) {
|
|||
"StartUnit",
|
||||
&error,
|
||||
NULL,
|
||||
"ss", "default.target", "isolate");
|
||||
"ss", SPECIAL_DEFAULT_TARGET, "isolate");
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to start default target: %s", bus_error_message(&error, r));
|
||||
|
|
Loading…
Reference in a new issue