ostree-prepare-root.service: Run earlier in initrd

Previously, we were preparing the root very late in the boot process;
right before we switch root. The issue with that is that most services
in the initrd that run `After=initrd-root-fs.target` expect that
`/sysroot` already points to the rootfs we'll be pivoting to. Running
this late violates that assumption.

This patch fixes this by making `ostree-prepare-root.service` instead
run right after `sysroot.mount` (the physical sysroot mounted by
systemd) but still before `initrd-root-fs.target` (which is the target
signalling that `/sysroot` is now valid and ready).

This should make it easier to integrate OSTree with other initrd
services such as Ignition.

Related: https://github.com/dustymabe/ignition-dracut/issues/20

Closes: #1759
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-10-18 16:44:05 -04:00 committed by Atomic Bot
parent ae99b9ccdc
commit a4a49724d6
2 changed files with 4 additions and 5 deletions

View File

@ -36,7 +36,7 @@ depends() {
install() { install() {
dracut_install /usr/lib/ostree/ostree-prepare-root dracut_install /usr/lib/ostree/ostree-prepare-root
inst_simple "${systemdsystemunitdir}/ostree-prepare-root.service" inst_simple "${systemdsystemunitdir}/ostree-prepare-root.service"
mkdir -p "${initdir}${systemdsystemconfdir}/initrd-switch-root.target.wants" mkdir -p "${initdir}${systemdsystemconfdir}/initrd-root-fs.target.wants"
ln_r "${systemdsystemunitdir}/ostree-prepare-root.service" \ ln_r "${systemdsystemunitdir}/ostree-prepare-root.service" \
"${systemdsystemconfdir}/initrd-switch-root.target.wants/ostree-prepare-root.service" "${systemdsystemconfdir}/initrd-root-fs.target.wants/ostree-prepare-root.service"
} }

View File

@ -22,9 +22,8 @@ DefaultDependencies=no
ConditionKernelCommandLine=ostree ConditionKernelCommandLine=ostree
ConditionPathExists=/etc/initrd-release ConditionPathExists=/etc/initrd-release
OnFailure=emergency.target OnFailure=emergency.target
After=initrd-switch-root.target After=sysroot.mount
Before=initrd-switch-root.service Before=initrd-root-fs.target
Before=plymouth-switch-root.service
[Service] [Service]
Type=oneshot Type=oneshot