[PATCH f17-branch 5/5] Fix kickstart failure if ks is on the same disk as stage2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not too hard really - just check to see if the disk is already mounted,
and don't bother mounting it again if it is.
---
 dracut/anaconda-lib.sh      |    8 ++++++++
 dracut/fetch-kickstart-disk |   19 ++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh
index 59ee06b..c469555 100755
--- a/dracut/anaconda-lib.sh
+++ b/dracut/anaconda-lib.sh
@@ -80,6 +80,14 @@ disk_to_dev_path() {
     esac
 }
 
+dev_is_mounted() {
+    local dev mnt etc
+    while read dev mnt etc; do
+        [ "$dev" = "$1" ] && echo $mnt && return 0
+    done < /proc/mounts
+    return 1
+}
+
 when_diskdev_appears() {
     local dev="${1#/dev/}" cmd=""; shift
     cmd="/sbin/initqueue --settled --onetime --unique --name $1-$dev $*"
diff --git a/dracut/fetch-kickstart-disk b/dracut/fetch-kickstart-disk
index ee4f226..9650241 100755
--- a/dracut/fetch-kickstart-disk
+++ b/dracut/fetch-kickstart-disk
@@ -11,13 +11,22 @@ path="${2:-/ks.cfg}"
 [ -b "$dev" ] || exit 1
 
 info "anaconda: fetching kickstart from $dev:$path"
-tmpmnt=$(mkuniqdir /run/install tmpmnt)
-if mount -o ro $dev $tmpmnt; then
-    cp $tmpmnt$path /tmp/ks.cfg
-    umount $tmpmnt
+mnt="$(dev_is_mounted $dev)"
+
+if [ -n "$mnt" ]; then
+    cp $mnt$path /tmp/ks.cfg
+else
+    tmpmnt="$(mkuniqdir /run/install tmpmnt)"
+    if mount -o ro $dev $tmpmnt; then
+        cp $tmpmnt$path /tmp/ks.cfg
+        umount $tmpmnt
+        rmdir $tmpmnt
+    fi
+fi
+
+if [ -f /tmp/ks.cfg ]; then
     parse_kickstart /tmp/ks.cfg
     run_kickstart
 else
     warn "Can't get kickstart from $dev:$path"
 fi
-rmdir $tmpmnt
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux