Blob Blame History Raw
From 38111b96223816bdc48930830f59d0fc674db895 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 16 May 2012 11:24:42 +0200
Subject: [PATCH] systemd: store switch-root.conf in /run/initramfs

Store switch-root.conf in /run/initramfs/switch-root.conf, so that the
service does not fail in ExecPost after switching to the real root.
---
 modules.d/98systemd/dracut-pre-pivot.sh |    4 ++--
 modules.d/98systemd/switch-root.service |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules.d/98systemd/dracut-pre-pivot.sh b/modules.d/98systemd/dracut-pre-pivot.sh
index 272b293..a8e9fc1 100755
--- a/modules.d/98systemd/dracut-pre-pivot.sh
+++ b/modules.d/98systemd/dracut-pre-pivot.sh
@@ -27,12 +27,12 @@ for i in "$(getarg real_init=)" "$(getarg init=)"; do
     __p=$(readlink -f "${NEWROOT}/${i}")
     if [ -x "$__p" ]; then
         INIT="$i"
-        echo "NEWINIT=\"$INIT\"" > /etc/switch-root.conf
+        echo "NEWINIT=\"$INIT\"" > /run/initramfs/switch-root.conf
         break
     fi
 done
 
-echo "NEWROOT=\"$NEWROOT\"" >> /etc/switch-root.conf
+echo "NEWROOT=\"$NEWROOT\"" >> /run/initramfs/switch-root.conf
 
 udevadm control --stop-exec-queue
 systemctl stop systemd-udev.service
diff --git a/modules.d/98systemd/switch-root.service b/modules.d/98systemd/switch-root.service
index 0c41eb0..2abfc90 100644
--- a/modules.d/98systemd/switch-root.service
+++ b/modules.d/98systemd/switch-root.service
@@ -11,6 +11,6 @@ DefaultDependencies=no
 
 [Service]
 Type=oneshot
-EnvironmentFile=/etc/switch-root.conf
+EnvironmentFile=/run/initramfs/switch-root.conf
 ExecStart=/usr/bin/systemctl --force switch-root ${NEWROOT} ${NEWINIT}
 ExecStopPost=-/usr/bin/systemctl isolate default.target