dracut/0104-Generate-fallback-mount-unit-for-root-filesystem.patch
Marcus Meissner d695f6da8a Accepting request 239877 from home:hreinecke:branches:Base:System
- Print stored dracut commandline during initramfs build
  * Add: 0101-Print-stored-dracut-commandline-during-initramfs-bui.patch
- Align dev_unit_name() with systemd's function
  * Add: 0102-Align-dev_unit_name-with-systemd-s-function.patch
- Fixup missing separators in rootfs-block cmdline
  * Add: 0103-Fixup-missing-separators-in-rootfs-block-cmdline.patch
- Generate fallback mount unit for root filesystem (bnc#855258)
  * Add: 0104-Generate-fallback-mount-unit-for-root-filesystem.patch
- 95iscsi: parse output from iscsiadm correctly (bnc#886199)
  * Add: 0105-95iscsi-parse-output-from-iscsiadm-correctly.patch

OBS-URL: https://build.opensuse.org/request/show/239877
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=169
2014-07-09 12:01:24 +00:00

71 lines
2.3 KiB
Diff

From 7bbe5a2608be72ecc51c3a28f0da1ddaf522e293 Mon Sep 17 00:00:00 2001
From: Thorsten Behrens <tbehrens@suse.com>
Date: Mon, 7 Jul 2014 01:14:45 +0200
Subject: Generate fallback mount unit for root filesystem
If kernel cmdline has no root= provided, *and* the initrd carries
a default value, create a systemd mount unit to have it available
in /sysroot
References: bnc#855258
Signed-off-by: Thorsten Behrens <tbehrens@suse.com>
---
modules.d/98systemd/rootfs-generator.sh | 34 ++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
index a2b71ff..13428da 100755
--- a/modules.d/98systemd/rootfs-generator.sh
+++ b/modules.d/98systemd/rootfs-generator.sh
@@ -37,6 +37,35 @@ generator_wait_for_dev()
fi
}
+generator_mount_rootfs()
+{
+ local _type=$2
+ local _flags=$3
+ local _name
+
+ [ -z "$1" ] && return 0
+
+ _name=$(dev_unit_name "$1")
+ [ -d /run/systemd/generator ] || mkdir -p /run/systemd/generator
+ if ! [ -f /run/systemd/generator/sysroot.mount ]; then
+ {
+ echo "[Unit]"
+ echo "Before=initrd-root-fs.target"
+ echo "RequiresOverridable=systemd-fsck@${_name}.service"
+ echo "After=systemd-fsck@${_name}.service"
+ echo "[Mount]"
+ echo "Where=/sysroot"
+ echo "What=$1"
+ echo "Options=${_flags}"
+ echo "Type=${_type}"
+ } > /run/systemd/generator/sysroot.mount
+ fi
+ if ! [ -L /run/systemd/generator/initrd-root-fs.target.requires/sysroot.mount ]; then
+ [ -d /run/systemd/generator/initrd-root-fs.target.requires ] || mkdir -p /run/systemd/generator/initrd-root-fs.target.requires
+ ln -s ../sysroot.mount /run/systemd/generator/initrd-root-fs.target.requires/sysroot.mount
+ fi
+}
+
root=$(getarg root=)
case "$root" in
block:LABEL=*|LABEL=*)
@@ -63,6 +92,9 @@ case "$root" in
rootok=1 ;;
esac
-[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}" "$RDRETRY"
+if [ "${root%%:*}" = "block" ]; then
+ generator_wait_for_dev "${root#block:}" "$RDRETRY"
+ grep -q 'root=' /proc/cmdline || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
+fi
exit 0
--
1.8.4.5