From 8aeec251e350be27090ffddf4d2ef063ad428219 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 9 May 2012 11:07:46 +0200
Subject: [PATCH] rootfs-block/block-genrules.sh: install systemd mount unit
---
modules.d/95rootfs-block/block-genrules.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/modules.d/95rootfs-block/block-genrules.sh b/modules.d/95rootfs-block/block-genrules.sh
index 1e6827a..fe6e331 100755
--- a/modules.d/95rootfs-block/block-genrules.sh
+++ b/modules.d/95rootfs-block/block-genrules.sh
@@ -13,5 +13,22 @@ if [ "${root%%:*}" = "block" ]; then
printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
+ if [ -d /lib/systemd/system/ ]; then
+ echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
+ {
+ echo '[Unit]'
+ echo 'Description=New Root File System'
+ echo 'DefaultDependencies=no'
+ echo 'Before=switch-root.service'
+ echo '[Mount]'
+ echo "What=${root#block:}"
+ echo "Where=$NEWROOT"
+
+ } >/lib/systemd/system/${NEWROOT#/}.mount
+
+ mkdir -p /lib/systemd/system/switch-root.target.wants
+ ln -s ../${NEWROOT#/}.mount /lib/systemd/system/switch-root.target.wants/${NEWROOT#/}.mount
+ fi
+
wait_for_dev "${root#block:}"
fi