diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 54b07e3004..4d85b6aec0 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -139,6 +139,9 @@ PrivateDevices= below, as it may change the setting of DevicePolicy=. + Units making use of RootImage= automatically gain an + After= dependency on systemd-udevd.service. + diff --git a/src/basic/special.h b/src/basic/special.h index 0eb3f3a368..19ee30cd41 100644 --- a/src/basic/special.h +++ b/src/basic/special.h @@ -82,6 +82,7 @@ #define SPECIAL_QUOTAON_SERVICE "quotaon.service" #define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service" #define SPECIAL_VOLATILE_ROOT_SERVICE "systemd-volatile-root.service" +#define SPECIAL_UDEVD_SERVICE "systemd-udevd.service" /* Services systemd relies on */ #define SPECIAL_DBUS_SERVICE "dbus.service" diff --git a/src/core/unit.c b/src/core/unit.c index f8fb01e3b1..242309e47f 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1079,6 +1079,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { return r; } + if (c->root_image) { + /* We need to wait for /dev/loopX to appear when doing RootImage=, hence let's add an + * implicit dependency on udev */ + + r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_UDEVD_SERVICE, true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return r; + } + if (!IN_SET(c->std_output, EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE, EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE,