From: Harald Hoyer Date: Wed, 10 Jun 2015 17:28:31 +0000 (+0200) Subject: dmsquash-live: install a sysroot.mount generator for systemd X-Git-Tag: 042~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ff624df9f3f300a008711d114a8769464a054db;p=thirdparty%2Fdracut.git dmsquash-live: install a sysroot.mount generator for systemd otherwise systemd uses its own sysroot.mount line --- diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh index b632f6a41..a0a9ab98b 100755 --- a/modules.d/90dmsquash-live/dmsquash-live-root.sh +++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh @@ -268,7 +268,10 @@ if [ -n "$ROOTFLAGS" ]; then fi ln -s /dev/mapper/live-rw /dev/root -printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh + +if [ -z "$DRACUT_SYSTEMD" ]; then + printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh +fi need_shutdown diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh index a113c3ff7..19396a736 100755 --- a/modules.d/90dmsquash-live/module-setup.sh +++ b/modules.d/90dmsquash-live/module-setup.sh @@ -31,6 +31,7 @@ install() { inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh" inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root" inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan" + inst_script "$moddir/dmsquash-generator.sh" $systemdutildir/system-generators/dracut-dmsquash-generator # should probably just be generally included inst_rules 60-cdrom_id.rules inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service" diff --git a/modules.d/90dmsquash-live/parse-dmsquash-live.sh b/modules.d/90dmsquash-live/parse-dmsquash-live.sh index bcd42984a..0386d3427 100755 --- a/modules.d/90dmsquash-live/parse-dmsquash-live.sh +++ b/modules.d/90dmsquash-live/parse-dmsquash-live.sh @@ -13,7 +13,7 @@ if [ "${root%%:*}" = "live" ] ; then liveroot=$root fi -[ "${liveroot%%:*}" = "live" ] || return +[ "${liveroot%%:*}" = "live" ] || return 1 modprobe -q loop @@ -49,9 +49,14 @@ case "$liveroot" in live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg]) [ -f "${root#live:}" ] && rootok=1 ;; esac + +[ "$rootok" = "1" ] || return 1 + info "root was $liveroot, is now $root" # make sure that init doesn't complain [ -z "$root" ] && root="live" wait_for_dev -n /dev/mapper/live-rw + +return 0 diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh index 2589919d6..5910ce75f 100755 --- a/modules.d/98dracut-systemd/rootfs-generator.sh +++ b/modules.d/98dracut-systemd/rootfs-generator.sh @@ -22,17 +22,17 @@ generator_wait_for_dev() fi _name=$(dev_unit_name "$1") - if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then - [ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants - ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device + if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then + [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants + ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device fi - if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then - mkdir -p /run/systemd/generator/${_name}.device.d + if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then + mkdir -p "$GENERATOR_DIR"/${_name}.device.d { echo "[Unit]" echo "JobTimeoutSec=$_timeout" - } > /run/systemd/generator/${_name}.device.d/timeout.conf + } > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf fi } @@ -45,8 +45,8 @@ generator_mount_rootfs() [ -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 + [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR" + if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then { echo "[Unit]" echo "Before=initrd-root-fs.target" @@ -57,11 +57,11 @@ generator_mount_rootfs() echo "What=$1" echo "Options=${_flags}" echo "Type=${_type}" - } > /run/systemd/generator/sysroot.mount + } > "$GENERATOR_DIR"/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 + if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then + [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires + ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount fi } @@ -91,6 +91,8 @@ case "$root" in rootok=1 ;; esac +GENERATOR_DIR="$1" + if [ "${root%%:*}" = "block" ]; then generator_wait_for_dev "${root#block:}" "$RDRETRY" strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"