diff --git a/src/core/unit.c b/src/core/unit.c index ce0b197e6b..7964863470 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1055,6 +1055,16 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) { if (!MANAGER_IS_SYSTEM(u->manager)) return 0; + /* For the following three directory types we need write access, and /var/ is possibly on the root + * fs. Hence order after systemd-remount-fs.service, to ensure things are writable. */ + if (!strv_isempty(c->directories[EXEC_DIRECTORY_STATE].paths) || + !strv_isempty(c->directories[EXEC_DIRECTORY_CACHE].paths) || + !strv_isempty(c->directories[EXEC_DIRECTORY_LOGS].paths)) { + r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_REMOUNT_FS_SERVICE, true, UNIT_DEPENDENCY_FILE); + if (r < 0) + return r; + } + if (c->private_tmp) { const char *p; diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in index d3022856f2..6f7967fd00 100644 --- a/units/systemd-backlight@.service.in +++ b/units/systemd-backlight@.service.in @@ -12,7 +12,6 @@ Description=Load/Save Screen Backlight Brightness of %i Documentation=man:systemd-backlight@.service(8) DefaultDependencies=no Conflicts=shutdown.target -After=systemd-remount-fs.service Before=sysinit.target shutdown.target [Service] diff --git a/units/systemd-coredump@.service.in b/units/systemd-coredump@.service.in index 951faa62a1..d1ece27074 100644 --- a/units/systemd-coredump@.service.in +++ b/units/systemd-coredump@.service.in @@ -12,7 +12,7 @@ Description=Process Core Dump Documentation=man:systemd-coredump(8) DefaultDependencies=no Conflicts=shutdown.target -After=systemd-remount-fs.service systemd-journald.socket +After=systemd-journald.socket Requires=systemd-journald.socket Before=shutdown.target diff --git a/units/systemd-pstore.service.in b/units/systemd-pstore.service.in index 89f34afe34..6e4827f03c 100644 --- a/units/systemd-pstore.service.in +++ b/units/systemd-pstore.service.in @@ -13,8 +13,8 @@ Documentation=man:systemd-pstore(8) ConditionDirectoryNotEmpty=/sys/fs/pstore ConditionVirtualization=!container DefaultDependencies=no -Wants=systemd-remount-fs.service -After=systemd-remount-fs.service +Conflicts=shutdown.target +Before=sysinit.target shutdown.target [Service] Type=oneshot @@ -23,4 +23,4 @@ RemainAfterExit=yes StateDirectory=systemd/pstore [Install] -WantedBy=systemd-remount-fs.service +WantedBy=sysinit.target diff --git a/units/systemd-rfkill.service.in b/units/systemd-rfkill.service.in index 3abb958310..af2042f1e5 100644 --- a/units/systemd-rfkill.service.in +++ b/units/systemd-rfkill.service.in @@ -13,7 +13,7 @@ Documentation=man:systemd-rfkill.service(8) DefaultDependencies=no BindsTo=sys-devices-virtual-misc-rfkill.device Conflicts=shutdown.target -After=sys-devices-virtual-misc-rfkill.device systemd-remount-fs.service +After=sys-devices-virtual-misc-rfkill.device Before=shutdown.target [Service] diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in index f0486a70ab..92ee94582c 100644 --- a/units/systemd-timesyncd.service.in +++ b/units/systemd-timesyncd.service.in @@ -13,7 +13,7 @@ Documentation=man:systemd-timesyncd.service(8) ConditionCapability=CAP_SYS_TIME ConditionVirtualization=!container DefaultDependencies=no -After=systemd-remount-fs.service systemd-sysusers.service +After=systemd-sysusers.service Before=time-set.target sysinit.target shutdown.target Conflicts=shutdown.target Wants=time-set.target time-sync.target