summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
diff options
context:
space:
mode:
authorjandob2016-02-05 21:02:48 +0100
committerjandob2016-02-05 21:02:48 +0100
commit5aa3f9c307aa243e75bb617d4fc81cae459cdae4 (patch)
treee6aa357f6e2eda445c6c52438fddd5307c1b162b /builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
parentadd shutdown break (diff)
downloadsystemd-init-5aa3f9c307aa243e75bb617d4fc81cae459cdae4.tar.gz
systemd-init-5aa3f9c307aa243e75bb617d4fc81cae459cdae4.tar.xz
systemd-init-5aa3f9c307aa243e75bb617d4fc81cae459cdae4.zip
support systemd shutdown pivot root back to initramfs
Diffstat (limited to 'builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh')
-rw-r--r--builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
new file mode 100644
index 00000000..1e9366e2
--- /dev/null
+++ b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
@@ -0,0 +1,24 @@
+#!/bin/env bash
+# Dracut may not be installed on the new root. Thus copy all services over.
+systemdsystemunitdir="$(
+ dirname "$(find / -name dracut-mount.service -type f -print -quit)")"
+mkdir --parents "${NEWROOT}/${systemdsystemunitdir}"
+for file in \
+ dracut-cmdline.service \
+ dracut-initqueue.service \
+ dracut-mount.service \
+ dracut-pre-mount.service \
+ dracut-pre-pivot.service \
+ dracut-pre-trigger.service \
+ dracut-pre-udev.service; do
+ cp "${systemdsystemunitdir}/$file" \
+ "${NEWROOT}/${systemdsystemunitdir}/$file"
+ ln -s ../"$file" \
+ "${NEWROOT}/${systemdsystemunitdir}/initrd.target.wants/$file"
+done
+
+# Needed to be able to go back to dracut at system shutdown.
+mkdir /temp_mnt
+mount --bind / /temp_mnt/
+cp -rT /temp_mnt /run/initramfs
+umount /temp_mnt && rmdir /temp_mnt